我有一个小问题-我在我的网站上有一个HTML5视频,它在FF,Chrome,Safari中运行良好。但是,如果我将autoplay=设置为“自动播放”,它只会在IE中显示视频。不知何故,它没有显示海报img -你可以在这里看到它,http://test.jsworldmedia.com/只需按下查看视频。有人知道哪里出问题了吗?
代码是:
<video id="videoContainer" width="932" height="524" controls="controls" poster="/media/13037/big_buck_bunny_poster.jpg">
<source src="http://test.jsworldmedia.com/media/13010/big_buck_bunny.mp4" type="video/mp4" />
<source src="http://test.jsworldmedia.com/media/13555/big_buck_bunny.ogv" type="video/ogg" />
<source src="http://test.jsworldmedia.com/media/13034/big_buck_bunny.webm" type="video/webm" />
<object id="flash_fallback_1" class="vjs-flash-fallback" width="932" height="524" type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
<param name="allowfullscreen" value="true" />
<param name="flashvars" value="config={'playlist':['http://test.jsworldmedia.com/media/13037/big_buck_bunny_poster.jpg', {'url': 'http://test.jsworldmedia.com/media/13010/big_buck_bunny.mp4','autoPlay':false,'autoBuffering':true}]}" />
<img src="http://test.jsworldmedia.com/media/13037/big_buck_bunny_poster.jpg" width="932" height="542" alt="" title="No video playback capabilities." />
</object>
</video>发布于 2011-12-09 22:03:28
如果加载了某些视频,则IE9会覆盖海报图像,这是默认设置。如果添加preload="none"属性,海报图像将在IE9中工作。
不是很理想。
编辑I‘s written about this,也向W3C提交了一份bug report,因为我认为它需要更改。
发布于 2012-07-14 02:23:31
我发现poster属性太不一致了。对我来说,preload="none"只修复了IE9的问题。
你最好编辑你的视频,使海报图像成为视频的第一帧。
我是这个Video for Everybody站点的铁杆粉丝,它准确地概述了应该如何使用回退来实现html5 <video>标签。作者特别谈到了poster属性,提到了不一致的支持和iOS 3.x中的一个主要错误,作为将海报图像编码到视频的第一帧的原因。
您还可以查看VideoJs,它将处理许多跨浏览器的问题。
EDIT (2012-11-04): VideoJ可能不是一个好的选择,IE 9报告了一些主要问题。
发布于 2014-03-04 18:56:05
我也有同样的问题。为了让海报在IE8和IE9中工作,我做了以下工作。
在html文件中,在视频元素下面添加一个图片,海报为src:
<img id="video-poster" width="460px" height="260px" src="img/video_poster.jpg">在css文件中添加:
#video-poster {position: absolute; z-index: 600; display: none;}`请注意,父对象在css position: relative中需要
在JS文件中添加:
/**
* fix the following issue: "video preview not showing properly on IE8 and IE9"
*/
(function ($) {
var browserIEInfo = navigator.userAgent.match(/MSIE (([0-9]+)(\.[0-9]+)?)/);
if (browserIEInfo === null || parseInt(browserIEInfo[2]) > 9){
return;
}
if (parseInt(browserIEInfo[2]) < 9 && !isFlashSupported()) {
return;
}
var video = $('video'); // use element id if there is more than 1 video
var videoPoster = $('#video-poster');
$( window ).resize(function() {
fixVideoCoverPosition();
});
fixVideoCoverPosition();
videoPoster.show();
videoPoster.click(function() {
video.get(0).play()
});
video.on('playing', function() {
videoPoster.hide();
});
video.on('ended', function() {
videoPoster.show();
});
function isFlashSupported() {
var hasFlash = false;
try {
new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
} catch (e) {
var mimeTypes = navigator.mimeTypes;
if (mimeTypes
&& mimeTypes['application/x-shockwave-flash'] !== undefined
&& mimeTypes['application/x-shockwave-flash']['enabledPlugin']
) {
hasFlash = true;
}
}
return hasFlash;
}
function fixVideoCoverPosition() {
var videoPosition = video.position();
video.width();
$('#video-poster').css({
top: videoPosition.top,
left: videoPosition.left,
width: video.width(),
height: video.height()
});
}
}(jQuery));https://stackoverflow.com/questions/8445965
复制相似问题