File size: 782 Bytes
931a864 08fc755 931a864 08fc755 931a864 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import gradio as gr
import os
def play_media(media_file):
os.system("mkdir uploads")
file_path = os.path.join("uploads", media_file.name)
with open(file_path, "wb") as file:
file.write(media_file.data)
return file_path
def ui():
with gr.Blocks() as media_player:
gr.Markdown("# Powerful Media Player")
with gr.Tab("Upload"):
with gr.Row():
media_file = gr.File(label="Upload Media")
upload_button = gr.Button("Upload")
with gr.Tab("Player"):
with gr.Row():
media_display = gr.Video(label="Media Player")
upload_button.click(play_media, inputs=media_file, outputs=media_display)
return media_player
media_player = ui()
media_player.launch() |