google / mesop

Build delightful web apps quickly in Python
https://google.github.io/mesop/
Apache License 2.0
4.3k stars 191 forks source link

Video Streaming Not Working with Video or Markdown Components #466

Open MarcoFerreiraPerson opened 2 weeks ago

MarcoFerreiraPerson commented 2 weeks ago

Describe the bug Video is not displaying using mesop video or markdown components while displaying using HTML video element.

To Reproduce

  1. Create an socket server hosting videos you want to host: Here is the code I used:
    
    import http.server
    import socketserver
    import os

PORT = 8003 DIRECTORY = "./videos"

Change the current working directory to serve files from './videos' directory

if not os.path.exists(DIRECTORY): os.makedirs(DIRECTORY) os.chdir(DIRECTORY)

Define the handler to serve files

Handler = http.server.SimpleHTTPRequestHandler

Start the server

with socketserver.TCPServer(("", PORT), Handler) as httpd: print(f"Serving at port {PORT}") httpd.serve_forever()

2. Create a mesop video component and link them to a video you are using

```py
me.video(
        src="http://localhost:8003/Mesop%20-%20Googles%20Tool%20to%20Build%20Python%20Web%20Apps.mp4",
    )

Visual: image

The link works in an HTML file:

<video controls width="640" height="360">
        <source src="http://localhost:8003/Mesop%20-%20Googles%20Tool%20to%20Build%20Python%20Web%20Apps.mp4" type="video/mp4">
        Your browser does not support the video tag.
    </video>

Visual image

Expected behavior I expect the video to be displayed in the video component.

Desktop System Info

Additional context The same issue happens using the markdown component with an HTML video tag.

I also noticed that it takes a considerable amount of time for it to display for the HTML file, however it never displays using mesop.

I do not get a request when using the mesop components 127.0.0.1 - - [18/Jun/2024 16:42:06] "GET /Mesop%20-%20Googles%20Tool%20to%20Build%20Python%20Web%20Apps.mp4 HTTP/1.1" 200 -

MarcoFerreiraPerson commented 2 weeks ago

The videos are private and on a separate machine, in this case for testing I hosted the videos on my local machine.