HTML Video causes all other links on the page to stop working on Chrome

时间:2015-09-14 15:43:31

标签: python html html5 flask html5-video

I am trying to make a very simple website for playing local videos but when ever the HTML Video tag loads a video all other links on the website stop working. The Chrome console shows that a 'pending' request is sent but my server never gets the request.

I am using Python/Flask as the backend. Flask just gets a directory listing and sends it my html jinja2 template. Everything works fine if the video does not load (like pointing to a video that does not exist), but if the video does load than all links under "available videos" stop working and I can not manual load one until I restart Flask.

          <h3>Available Videos</h3>
          <ul id="file_list" class="none">
          {% for file in files %}
            <li><a href="/{{ file }}">{{ file}}</a></li>
          {% endfor %}
          </ul>

          {% if video %}
          <h3><center>Playing {{ video }}<center></h2>
          <video width="640" height="480" controls="controls" preload="auto">
            <source src="../static/videos/{{ video }}" type="video/mp4">
            Your browser does not support the video tag
          </video>
          {% else %}
          <h2>Please select a video to play</h2>
          {% endif %}

And here is my Flask code:

@app.route("/")
@app.route("/<video>/")
def play_video(video=None):
    files = get_files(path=MEDIA_PATH)
    return render_template('video.html', video=video, files=files)

def get_files(path=MEDIA_PATH):
    files = []
    for filename in os.listdir(path):
        #files.append(filename.replace(".mp4", ""))
        files.append(filename)
    return files

Edit: this is only happening in Chrome, Firefox works just fine.

0 个答案:

没有答案