jPlayer - "ready"事件未在 IE 7 中触发



就像标题所说的那样,我有一个脚本可以在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% 准确的,并且任何浏览器中都没有抛出其他错误。

提前感谢您的帮助!

我发现服务器上的.swf已过时。更新它解决了这个问题。窝囊。

最新更新