Update app.py
Browse files
app.py
CHANGED
@@ -146,19 +146,21 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
146 |
outputs=run_button
|
147 |
)
|
148 |
|
|
|
149 |
def update_video_embed(youtube_url):
|
150 |
if youtube_url:
|
151 |
try:
|
152 |
video_id = fetch_youtube_id(youtube_url)
|
153 |
-
|
|
|
154 |
except Exception as e:
|
155 |
print(f"Error embedding video: {e}")
|
156 |
-
return ""
|
157 |
|
158 |
youtube_input.change(
|
159 |
fn=update_video_embed,
|
160 |
inputs=[youtube_input],
|
161 |
-
outputs=[video_player]
|
162 |
)
|
163 |
|
164 |
|
|
|
146 |
outputs=run_button
|
147 |
)
|
148 |
|
149 |
+
)
|
150 |
def update_video_embed(youtube_url):
|
151 |
if youtube_url:
|
152 |
try:
|
153 |
video_id = fetch_youtube_id(youtube_url)
|
154 |
+
embed_html = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
|
155 |
+
return embed_html, gr.update()
|
156 |
except Exception as e:
|
157 |
print(f"Error embedding video: {e}")
|
158 |
+
return "",gr.update()
|
159 |
|
160 |
youtube_input.change(
|
161 |
fn=update_video_embed,
|
162 |
inputs=[youtube_input],
|
163 |
+
outputs=[video_player,audio_input]
|
164 |
)
|
165 |
|
166 |
|