jPlayer - “就绪”事件未在IE 7中触发

时间:2014-02-19 22:31:08

标签: javascript jquery html5 jplayer

就像标题所说,我有一个在Chrome和Firefox中运行的脚本,但不是IE。这个实现的几个独特之处是:1)jQuery的多个版本(使用noConflict),以及2)jPlayer使用的大部分资产都是通过脚本生成的。

标记

<a class="audio-trigger" data-type="mp3" data-loop="false" href="/path.to.mp3">Listen</a>

JS(在document.ready函数中)

// Initialize audio 
if ($('.audio-trigger').length) {

    //get jQuery 1.10.2 for jPlayer
    $.getScript('/rsc/js/libs/jquery-1.10.2.min.js', function () {
        $.getScript('/rsc/js/libs/jplayer-2.5.0.min.js', function () {

            //jPlayer noConflict option is restricted to strings that contain the term jQuery
            var jQuery1102 = jQuery.noConflict(true);
            console.log('jQuery ' + $.fn.jquery + ' has been restored to global, and jQuery ' + jQuery1102.fn.jquery + ' has been preserved.');

            //create pause button and audio container
            var pause = '<a class="audio-pause" href="javascript:;">Pause | <span class="audio-currentTime"></span> / <span class="audio-duration"></span></a><div class="audio-play-area"></div>';
            jQuery1102('.audio-trigger').after(pause);

            //get audio link
            var audioLink = jQuery1102('.audio-trigger').attr('href');

            //Init jPlayer
            jQuery1102('.audio-play-area').jPlayer( {
                ready: function() {
                    jQuery1102(this).jPlayer('setMedia', {
                        mp3: audioLink
                    });
                },
                swfPath: '/rsc/js/libs',
                supplied: jQuery1102('.audio-trigger').data('type'),
                cssSelectorAncestor: '',
                cssSelector: {
                    play: '.audio-trigger',
                    pause: '.audio-pause',
                    currentTime: '.audio-currentTime',
                    duration: '.audio-duration'
                },
                noConflict: 'jQuery1102',
                loop: jQuery1102('.audio-trigger').data('loop'),
                errorAlerts: true
            });
        });
    });
}

最后,当我点击音频触发器时...... 错误

Attempt to issue media playback commands, while no media url is set. 
Use setMedia() to set the media URL 
Context: play 

我的.swf路径名称100%准确,并且在任何浏览器中都没有引发其他错误。

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我发现服务器上的.swf已经过时了。更新它修复了问题。 Womp womp。