MediaElementJs Firefox闪回后备“this.pluginApi.pauseMedia不是函数”

时间:2012-04-02 16:57:47

标签: mediaelement.js

我在mediaelementjs的实施中遇到了问题。我需要一个链接列表来改变视频源。问题是我第二次点击悬停链接时,每次点击播放按钮时,debbugger都会说“this.pluginApi.pauseMedia不是函数”。这种情况发生在具有闪回后备的Firefox中。 这是我改变视频的代码:

<script type="text/javascript">
var player = null;
var videoCounter = 0;
var videoSubsLang = 'es';


function loadVideo(videoSource){
    if(player != null){
        //player.pause();
    }

    player = null;

    if(typeof(videoSource)==='undefined') videoSource = '';

    var videoURL = 'video.mp4';

    $("#mep_"+videoCounter).remove();

    var htmlVideo = '<video width="512" height="384" src="'+videoURL+'" id="player" poster="video.jpg" controls="controls" preload="auto">';
    htmlVideo += '<track kind="subtitles" src="video_en.srt" srclang="en" />';
    htmlVideo += '<object width="512" height="384" type="application/x-shockwave-flash" data="js/player_mejs/flashmediaelement.swf">';
    htmlVideo += '<param name="movie" value="js/player_mejs/flashmediaelement.swf" />';
    htmlVideo += '<param name="flashvars" value="controls=true&file='+videoURL+'" />';
    htmlVideo += '</object>';
    htmlVideo += '</video>';

    $('#tutsVideoHolder').append(htmlVideo);


    player = new MediaElementPlayer('#player', {startLanguage: videoSubsLang, features: ['playpause','progress','current','duration','tracks','volume','fullscreen'], translationSelector: false,
        success: function (mediaElement) { 
            alert('success');
            // add event listener
           mediaElement.addEventListener('pause', function(e) {
                 alert('pause');
            }, true);

           mediaElement.addEventListener('pause', function(e) {
                 alert('pause');   
            }, true);

        }
    });
    videoCounter++;

}

$(document).ready(function(){

    player = new MediaElementPlayer('#player', {startLanguage: 'en', features: ['playpause','progress','current','duration','tracks','volume','fullscreen'], translationSelector: false});

});

</script>

我的HTML就是这样:

<div id="tutsVideoHolder" class="tuts_video_holder left">    
    <video width="512" height="384" id="player" poster="poster.jpg" controls="controls">
        <source src="video.mp4" type="video/mp4"/>

        <track kind="subtitles" src="video_subs.vtt" srclang="en" />

        <object width="320" height="240" type="application/x-shockwave-flash" data="js/player_mejs/flashmediaelement.swf">
            <param name="movie" value="js/player_mejs/flashmediaelement.swf" />
            <param name="flashvars" value="controls=true&file=video.mp4" />

            <img src="poster.jpg" width="320" height="240" title="No video playback capabilities" />
        </object>
    </video>        
</div>

请帮帮我! :)

1 个答案:

答案 0 :(得分:0)

您正在禁用视频元素或其父元素,因此当您尝试设置src时,mediaplayerjs元素被禁用。我建议不要隐藏或显示视频,而是更改视频元素或其父级的z-index。