Html Chrome 中的 HTML5 <video> 标签不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10757347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:39:00  来源:igfitidea点击:

HTML5 <video> tag in Chrome doesn't work

htmlgoogle-chromevideo

提问by Borja

I have noticed a strange problem with the HTML5 <video/>tag in Chrome.

我注意到<video/>Chrome 中的 HTML5标签有一个奇怪的问题。

Using this, it works fine:

使用它,它工作正常:

<video poster="023.png" autoplay controls>
<source src="todojunto.mp4" type="video/mp4"  />
</video>

This only plays the sound, no video:

这只播放声音,不播放视频:

<video poster="023.png" autoplay >
<source src="todojunto.mp4" type="video/mp4"  />
</video>

If I remove the posterattribute, it works again.

如果我删除该poster属性,它会再次工作。

All other browsers (even IE9...!) works perfectly, and I can't seem to find the reason.

所有其他浏览器(甚至 IE9...!)都可以完美运行,我似乎找不到原因。

Any ideas/help?

任何想法/帮助?

Thanks

谢谢

回答by micnic

Video tag's attributes should be specified for strict standard implementation:

应为严格的标准实现指定视频标签的属性:

<video poster="023.png" autoplay="autoplay" controls="controls">
    <source src="todojunto.mp4" type="video/mp4"  />
</video>

If this doesn't work, there is something changed in your browser's preferences

如果这不起作用,则浏览器的首选项发生了变化

回答by mpb

I'm surprised your video even shows up. Chrome stopped supporting mp4. You should use a .webm file when working with Chrome for html5 videos.

我很惊讶你的视频竟然出现了。Chrome 停止支持 mp4。使用 Chrome 处理 html5 视频时,您应该使用 .webm 文件。

回答by Marlon Marlon

You need to use muted=""; it does work for video

你需要使用muted=""; 它确实适用于视频

<div class="wrap">
 <video width="auto" height="400px" autoplay="" loop="" muted="">
       <source src="Video.mp4"  type="video/mp4">
    <source src="Video.ogg" type="video/ogg">
 </video>
</div>

回答by Fyntasia

I've encountered the same error. I fixed it by adding the preload="auto" tag.

我遇到了同样的错误。我通过添加 preload="auto" 标签修复了它。

<video autoplay loop preload="auto" poster="023.png">
    <source src="todojunto.mp4" type="video/mp4" />
</video>

Don't know if this will work for you, and it's been some time since you asked the question. But maybe this will help someone in the future!

不知道这是否适合你,而且你问这个问题已经有一段时间了。但也许这会对将来的某人有所帮助!

回答by DragonKnight

I just converted it to ogv and works well in all browsers. I had problem with firefox but no issues anymore. It was also showing a gray background but now, now anymore. here is my code: you can see it in eargo.com/products

我只是将它转换为 ogv 并且在所有浏览器中都运行良好。我在使用 Firefox 时遇到问题,但不再有问题。它也显示灰色背景,但现在,现在不再。这是我的代码:您可以在eargo.com/products 中看到它

<video class="" style="" autoplay loop>
            <source class="" src="video.ogv" >
            <source class="" src="video.mov" >
            <source class="" src="video.mp4" >
</video>

you may see it after 5-7-2015.

您可能会在 5-7-2015 之后看到它。