简体   繁体   English

iPad上的HTML5视频“黑屏”

[英]HTML5 Video “Black Screen” on iPad

I'm building a website that has videos embedded within them. 我正在建立一个内嵌视频的网​​站。 This website needs to cater for iPad users as well but I'm having trouble with the ol' video tag at the moment. 这个网站也需要迎合iPad用户,但我现在无法使用ol' video标签。 I have a video that plays fine in browsers but not on an iPad unfortunately. 我有一个视频可以在浏览器中播放,但不幸的是在iPad上播放。

I'm just getting a black screen with the iPad, and no error message to speak of. 我只是拿着iPad的黑屏,没有错误信息可言。

Here is my code for the video: 这是我的视频代码:

<video id="movie" width="790" height="250" controls >
    <source src="anim/intro.ipad.mp4"  type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
    <source src="anim/intro.webm" type='video/webm; codecs="vp8, vorbis"'>
    <source src="anim/intro.theora.ogv"  type='video/ogg; codecs="theora, vorbis"'>
</video>
<script>
    var v = document.getElementById("movie");
    v.onclick = function() {
        if (v.paused) {
            v.play();
        } else {
            v.pause();
        }
    };
</script>

The videos were all created following tutorials about HTML5 video. 这些视频都是在关于HTML5视频的教程之后创建的。 They were all encoded using preferred iPad settings on Miro Video converter. 它们都使用Miro Video转换器上的首选iPad设置进行编码。

Just incase this matters (I'm not sure it will) I'm testing the video on an iPad simulator. 只是因为这很重要(我不确定会不会)我在iPad模拟器上测试视频。

No matter what I do, I just can't get the video to play: 无论我做什么,我都无法播放视频:

在iPad模拟器上

Are you sure you got the encoding right? 你确定你的编码正确吗?
Try this to test it: 试试这个来测试一下:

<video src="anim/intro.ipad.mp4" controls>  
      Your browser does not support the video element.  
</video>  

is your .htaccess file serving up the particular video files correctly? 是你的.htaccess文件正确提供特定的视频文件?

Ensure your server is using the correct mime-types. 确保您的服务器使用正确的mime类型。 Firefox will not play the Ogg video if the mime-type is wrong. 如果mime-type错误,Firefox将不播放Ogg视频。 Place these lines in your .htaccess file to send the correct mime-types to browsers 将这些行放在.htaccess文件中,以将正确的mime-types发送到浏览器

AddType video/ogg  .ogv
AddType video/mp4  .mp4
AddType video/webm .webm

Reference: Video for Everybody 参考: 适合所有人的视频

Also, are you modifying the video element by using positioning? 另外,您是否使用定位修改视频元素? I've found that this creates this black video screen too. 我发现这也创造了这个黑色视频屏幕。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM