Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
def video_player():
|
5 |
+
# Fetch quality links from Flask backend
|
6 |
+
try:
|
7 |
+
response = requests.get("http://127.0.0.1:7860/get_links")
|
8 |
+
response.raise_for_status()
|
9 |
+
links = response.json()
|
10 |
+
except Exception as e:
|
11 |
+
return f"Error fetching video links: {e}"
|
12 |
+
|
13 |
+
# HTML for Video.js player
|
14 |
+
video_html = f"""
|
15 |
+
<video id="video-player" class="video-js vjs-default-skin" controls autoplay width="800" height="450">
|
16 |
+
<source src="{links['720']}" type="application/x-mpegURL">
|
17 |
+
</video>
|
18 |
+
<script src="https://vjs.zencdn.net/8.3.0/video.min.js"></script>
|
19 |
+
<script>
|
20 |
+
const player = videojs('video-player');
|
21 |
+
player.play();
|
22 |
+
</script>
|
23 |
+
"""
|
24 |
+
|
25 |
+
return gr.HTML(video_html)
|
26 |
+
|
27 |
+
# Gradio interface
|
28 |
+
demo = gr.Interface(
|
29 |
+
fn=video_player,
|
30 |
+
inputs=[],
|
31 |
+
outputs="html",
|
32 |
+
title="Professional HLS Player"
|
33 |
+
)
|
34 |
+
|
35 |
+
if __name__ == "__main__":
|
36 |
+
demo.launch(server_name="0.0.0.0", server_port=7861)
|