HTML5视频未加载Chrome,但在打开开发人员控制台时可以使用 [英] HTML5 video not loading in chrome, but works when the developer console is opened up
问题描述
我正在为客户端开发网络应用,HTML5视频标记存在问题。
I am working on a web app for a client, and there is a problem with the HTML5 video tag.
问题是视频无法加载在chrome中,但适用于Safari,Firefox和IE。
The problem is that the video won't load in chrome, but works on Safari, Firefox and IE.
所以我开始使用chrome进行调试,但我发现如果我在打开控制台的情况下刷新页面,视频会加载。但是当我关闭控制台并刷新时,视频将无法加载......
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:
有多种类型的视频,mp4和webm。 componentDidMount中的
,用相同的代码替换视频。
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>
推荐答案
我发现我的问题是我启用了自动播放功能,但是使用chrome的新策略,除非视频被静音,否则不允许自动播放,因此添加静音属性可以解决问题。
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.
这篇关于HTML5视频未加载Chrome,但在打开开发人员控制台时可以使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!