MediaElement播放器“成功”回调没有被执行并且可能“结束”了。如果使用 Flash 回退,事件不会触发
我使用以下代码嵌入视频:
$('#trailer-dialog').mediaelementplayer({
enablePluginDebug: false,
// remove or reorder to change plugin priority
plugins: ['flash','silverlight'],
// specify to force MediaElement to use a particular video or audio type
type: '',
// path to Flash and Silverlight plugins
pluginPath: '/build/',
// name of flash file
flashName: 'flashmediaelement.swf',
// name of silverlight file
silverlightName: 'silverlightmediaelement.xap',
// default if the <video width> is not specified
defaultVideoWidth: 1240,
// default if the <video height> is not specified
defaultVideoHeight: 679,
// overrides <video width>
pluginWidth: -1,
// overrides <video height>
pluginHeight: -1,
// rate in milliseconds for Flash and Silverlight to fire the timeupdate event
// larger number is less accurate, but less strain on plugin->JavaScript bridge
timerRate: 250,
success: function (mediaElement, domObject) {
// add event listener
mediaElement.addEventListener('ended', trailerEnded, false);
// call the play method
mediaElement.play();
},
// fires when a problem is detected
error: function () {
}
});
这是事件触发时要执行的函数:
function trailerEnded(e){
e.target.stop();
$.cookie('trailer_played', 'true');
$('#wrapper').css('display', 'block');
$('#trailer').css('display', 'none');
alert('test');
}
它正在能够显示 htm5 视频的浏览器中执行。但在使用 Flash Fallback 的 IE 6-8 中,它不起作用。
有什么想法可以解决这个问题吗?
谢谢
卢卡斯
i use the following code to embed a video:
$('#trailer-dialog').mediaelementplayer({
enablePluginDebug: false,
// remove or reorder to change plugin priority
plugins: ['flash','silverlight'],
// specify to force MediaElement to use a particular video or audio type
type: '',
// path to Flash and Silverlight plugins
pluginPath: '/build/',
// name of flash file
flashName: 'flashmediaelement.swf',
// name of silverlight file
silverlightName: 'silverlightmediaelement.xap',
// default if the <video width> is not specified
defaultVideoWidth: 1240,
// default if the <video height> is not specified
defaultVideoHeight: 679,
// overrides <video width>
pluginWidth: -1,
// overrides <video height>
pluginHeight: -1,
// rate in milliseconds for Flash and Silverlight to fire the timeupdate event
// larger number is less accurate, but less strain on plugin->JavaScript bridge
timerRate: 250,
success: function (mediaElement, domObject) {
// add event listener
mediaElement.addEventListener('ended', trailerEnded, false);
// call the play method
mediaElement.play();
},
// fires when a problem is detected
error: function () {
}
});
this is the function to be executed when the event fires:
function trailerEnded(e){
e.target.stop();
$.cookie('trailer_played', 'true');
$('#wrapper').css('display', 'block');
$('#trailer').css('display', 'none');
alert('test');
}
it is being executed in browsers which are able to display htm5 videos. but in IE 6-8 which use the flash fallback it doesn't work.
any ideas to fix this?
thanks
lukas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
升级您的 mediaelementjs 版本 - 最新版本为我解决了这个问题。
Upgrade your version of mediaelementjs - latest version solved this for me.