HTML5 video not loading in chrome, but works when the developer console is opened up

半城伤御伤魂 提交于 2019-12-02 04:53:49

问题


I am working on a web app for a client, and there is a problem with the HTML5 video tag.

The problem is that the video won't load in chrome, but works on Safari, Firefox and IE.

So I start debugging in chrome, but I found out that if I refresh the page with console opened, the video would load. But when I close the console and refresh, the video would not load...

Here are the few things I have tried:

Have multiple type of videos, in mp4 and webm. in componentDidMount, replace the video with the same code.

But none seems to work...

<div class="Top">
    <div class="video-container BGVideo">
        <video id="videobg" class="video-background" preload="true" loop="" autoplay="" poster="/img/azzura.jpg">
            <source src="/img/azzura.mp4">
            <source src="/img/azzura.webm">
        </video>
        <div class="video-overlay"></div>
        <div class="video-content">
            <div class="BGContent">
                <div class="scrollDown">
                    <a class="button"><i class="fa fa-chevron-down"></i></a>
                </div>
            </div>
        </div>
   </div>
</div>

回答1:


I figured out my problem was that I have autoplay enabled, but with chrome's new policy, autoplay isn't allowed unless it's the video is muted, so adding the muted attribute fix the problem.




回答2:


This worked fine for me.

Completed parameters loop="false" and autoplay="false" as you had them emptied e.g. loop="", etc.

<div class="Top">
    <div class="video-container BGVideo">
        <video id="videobg" class="video-background" preload="true" loop="false" autoplay="false" poster="">
            <source src="https://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4">
        </video>
        <div class="video-overlay"></div>
        <div class="video-content">
            <div class="BGContent">
                <div class="scrollDown">
                    <a class="button"><i class="fa fa-chevron-down"></i></a></div>
                </div>
            </div>
        </div>
    </div>


来源:https://stackoverflow.com/questions/50702236/html5-video-not-loading-in-chrome-but-works-when-the-developer-console-is-opene

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!