Liveipltv / app.py
Hackerytboy's picture
Create app.py
bec3444 verified
raw
history blame contribute delete
991 Bytes
import gradio as gr
import requests
def video_player():
# Fetch quality links from Flask backend
try:
response = requests.get("http://127.0.0.1:7860/get_links")
response.raise_for_status()
links = response.json()
except Exception as e:
return f"Error fetching video links: {e}"
# HTML for Video.js player
video_html = f"""
<video id="video-player" class="video-js vjs-default-skin" controls autoplay width="800" height="450">
<source src="{links['720']}" type="application/x-mpegURL">
</video>
<script src="https://vjs.zencdn.net/8.3.0/video.min.js"></script>
<script>
const player = videojs('video-player');
player.play();
</script>
"""
return gr.HTML(video_html)
# Gradio interface
demo = gr.Interface(
fn=video_player,
inputs=[],
outputs="html",
title="Professional HLS Player"
)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7861)