javascript Mp4 视频无法在 iPad 中播放
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3906558/
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
Mp4 video won't play in the iPad
提问by UXdesigner
Good day, I've been working on this project and learning how to place a video on the ipad, and all the other browsers.
美好的一天,我一直在研究这个项目并学习如何在 ipad 和所有其他浏览器上放置视频。
But after writing the code for this, I noticed that the only thing I get from the iPad is the first keyframe of the video, but the video is not playing. When I press the "Play" button that appears in that screen of the ipad, the video won't just play. Weird is, the script has an autoplay command.
但是在为此编写代码后,我注意到我从 iPad 上唯一得到的是视频的第一个关键帧,但视频没有播放。当我按下出现在 ipad 屏幕上的“播放”按钮时,视频不会播放。奇怪的是,该脚本有一个自动播放命令。
What is wrong with this script ? Is there a better way of doing this ? I've spent way too much time on this and I can't get it done. I checked this on Safari for Windows, Firefox, Internet Explorer and it works everywhere except for the iPad.
这个脚本有什么问题?有没有更好的方法来做到这一点?我在这上面花了太多时间,但我无法完成。我在 Windows、Firefox、Internet Explorer 的 Safari 上检查了这个,它在除 iPad 之外的任何地方都有效。
<video controls width="920px" height="560px" autoplay>
<!-- if Safari/Chrome-->
<source src="video.mp4" type="video/mp4" />
<source src="video.ogv" type="video/ogg" />
<!--If the browser doesn't understand the <video> element, then reference a Flash file. You could also write something like "Use a Better Browser!" if you're feeling nasty. (Better to use a Flash file though.)-->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="920" height="560" id="csSWF">
<param name="movie" value="video_controller.swf" />
<param name="quality" value="best" />
<param name="bgcolor" value="#1a1a1a" />
<param name="allowfullscreen" value="true" />
<param name="scale" value="showall" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="autostart=true&showstartscreen=false&color=0x1A1A1A,0x1A1A1A" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="video_controller.swf" width="920" height="560">
<param name="quality" value="best" />
<param name="bgcolor" value="#1a1a1a" />
<param name="allowfullscreen" value="true" />
<param name="scale" value="showall" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="autostart=true&showstartscreen=false&color=0x1A1A1A,0x1A1A1A" />
<!--<![endif]-->
<div id="noUpdate">
<p>The video content presented here, requires a more recent version of the Adobe Flash Player. If you are using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by <a href="http://www.adobe.com/go/getflashplayer">downloading here</a>.</p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("csSWF", "9.0.28", "expressInstall.swf");
</script>
</video>
回答by Shay Erlichmen
What are the spec of the mp4 video (resolution and profile)?. The iPad doesn't support all the varieties of mp4.
mp4 视频的规格是什么(分辨率和配置文件)?。iPad 并不支持所有种类的 mp4。
Did you try a simple html without the flash and the ogv source?
您是否尝试过没有 flash 和 ogv 源的简单 html?
It looks like your over sepc:
它看起来像你的超过 sepc:
iPad Supported Video Format
iPad 支持的视频格式
- H.264 video (up to 720p, 30 frames per second; main profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats)
- MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats.
- H.264 视频(最高 720p,每秒 30 帧;主配置文件级别 3.1,具有最高 160 Kbps、48kHz 的 AAC-LC 音频,.m4v、.mp4 和 .mov 文件格式的立体声音频)
- MPEG-4 视频,高达 2.5 Mbps,640 x 480 像素,每秒 30 帧,简单配置文件,带有高达 160 Kbps、48kHz 的 AAC-LC 音频,.m4v、.mp4 和 .mov 文件格式的立体声音频。
回答by UXdesigner
maybe it's better if you also specify the basic media codecs
如果您还指定基本媒体编解码器,也许会更好
<source src="video.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
回答by Jakob
Could this be it?
会是这样吗?
"iOS will not recognize the video if you include a poster attribute. The poster attribute of the element allows you to display a custom image while the video is loading, or until the user presses “play.” This bug is fixed in iOS 4.0, but it will be some time before users upgrade."
“如果您包含海报属性,iOS 将无法识别视频。元素的海报属性允许您在视频加载时显示自定义图像,或者直到用户按下“播放”。此错误已在 iOS 4.0 中修复,但用户升级还需要一段时间。”
Found it in Dive into HTML5

