MediaElement播放器"成功"回调未被执行,如果使用闪回后备,则可能不会触发"已结束"事件

luk*_*sak 6 javascript flash jquery internet-explorer mediaelement.js

我使用以下代码嵌入视频:

$('#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 () {

        }

    });
Run Code Online (Sandbox Code Playgroud)

这是事件触发时要执行的函数:

function trailerEnded(e){
    e.target.stop();
    $.cookie('trailer_played', 'true');
    $('#wrapper').css('display', 'block');
    $('#trailer').css('display', 'none');
    alert('test');
}
Run Code Online (Sandbox Code Playgroud)

它正在浏览器中执行,能够显示htm5视频.但在使用闪回后备的IE 6-8中它不起作用.

任何想法来解决这个问题?

谢谢

卢卡斯

小智 0

升级您的 mediaelementjs 版本 - 最新版本为我解决了这个问题。