问题我知道当我呼叫setSrc()
时,无论preload
标签指示什么,flash和html5播放器都会在开始播放新视频之前预加载整个视频。理想情况下,视频会在数据下载时开始播放。
/* code and comments trimmed for your viewing pleasure */
<video src="myvideo1.mp4" width="800" height="450" preload="none" smoothing autoplay></video>
<script>
var player = new MediaElementPlayer('video', {
enablePluginDebug: true,
plugins: ['flash','silverlight'],
defaultVideoWidth: 800, defaultVideoHeight: 450,
videoWidth: -1, videoHeight: -1,
loop: false,
features: ['playpause','progress','current','duration','fullscreen'],
success: function (mediaElement, domObject) {
mediaElement.play();
},
error: function () {
alert('error!');
}
});
var currentVid = 1;
var vidnames = new Array("(null)",
"myvideo1.mp4",
"myvideo2.mp4",
"myvideo3.mp4");
function switchvid (vidnum) {
currentVid = vidnum;
player.pause();
player.setSrc( vidnames[vidnum] );
player.play();
return false;
}
</script>
<A HREF="#" onClick="return switchvid(1)"><IMG SRC="ch01x.png"></A>
<A HREF="#" onClick="return switchvid(2)"><IMG SRC="ch02x.png"></A>
<A HREF="#" onClick="return switchvid(3)"><IMG SRC="ch03x.png"></A>
尝试了preload="none"
,preload
,preload="auto"
所有结果都相同...播放器在填充整个下载缓冲区时似乎挂起,然后开始播放。
答案 0 :(得分:0)
显然,load()函数处理这个问题。不清楚load()与PRELOAD属性(如果有的话)的关系,但对我来说它现在正在工作。
var player = new MediaElementPlayer('video', {
// etc
success: function (mediaElement, domObject) {
mediaElement.load();
mediaElement.play();
}
}
function switchvid (vidnum) {
currentVid = vidnum;
player.pause();
player.setSrc( vidnames[vidnum] );
player.load();
player.play();
return false;
}