如果使用Flash回退,MediaElement播放器的“success”回调不会被执行,可能也不会触发“ended”事件。

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

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

这段代码在能够显示HTML5视频的浏览器中运行。但是在使用Flash回退的IE 6-8中无法正常工作。

有没有解决方法?

谢谢。

Lukas

1个回答

0

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


我在2.9.5版本仍然存在问题。 - Filipiz
我在2.18.1版本中仍然遇到了这个问题,但我肯定在以前的网站上解决过。有人解决了吗? - Mr_Chimp

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接