简体   繁体   English

仅在Chrome中调试jPlayer初始化,在控制台中看不到网络或js错误

[英]Debugging jPlayer Initialization in Chrome only, no network or js errors seen in console

This streaming MP3 player had been working fine for 8 months. 这款流媒体MP3播放器已经运行了8个月。 It has developed an odd behavior in the last few weeks but only in Chrome- the first click of any "Listen" link anywhere on site produces expected console output and changes to the HTML in player area but stream does not start. 它在过去几周内出现了一种奇怪的行为,但仅在Chrome中 - 在网站上的任何地方首次点击任何“监听”链接都会产生预期的控制台输出并改变播放器区域中的HTML但流不会启动。 No network 404s, 403s etc are seen in console. 在控制台中看不到网络404s,403s等。 No JS errors are thrown in console except Flash fallback complaint which has always been thrown despite file being found where it is sought... 在控制台中没有抛出JS错误,除了Flash回退投诉,尽管文件被找到,但它总是被抛出...

This issue is not observed in IE, FF, or Windows Safari. 在IE,FF或Windows Safari中未观察到此问题。

Live site: http://itsneworleans.com/ 直播网站: http//itsneworleans.com/

Example link: 示例链接:

<a href="#top" ajax-data="/audio/episodes/2014_03_21_587_hello-swelo.mp3" ajax-data-id="587" ajax-data-alt="Happy Hour: Hello Swelo" class="playerLink ">Listen</a>

jPlayer init line 233 of http://itsneworleans.com/js/main.js http://itsneworleans.com/js/main.js的 jPlayer init第233行

$("#jquery_jplayer_1").jPlayer({
        supplied: "mp3",
        swfPath: "http://itsneworleans.com/js/jQuery.jPlayer.2.5.0",
        solution: "html,flash",
        wmode:"transparent",
        errorAlerts: true,
        ended: function () {
            console.log('ended event fired');
            $.getScript('/js/random_show.js.php');
        }
    });

Click function from http://itsneworleans.com/js/main.js line 245: 单击http://itsneworleans.com/js/main.js第245行中的函数:

$("body").on('click', '.playerLink', function() {
    if ($(this).attr('ajax-data')) {
        console.log("Playing " + $(this).attr('ajax-data'));

         ga('send', 'pageview', {'page': $(this).attr('ajax-data'),'title': document.title});
         console.log("Sending to GA " + $(this).attr('ajax-data'));

        $("#jquery_jplayer_1").jPlayer("setMedia", {
            mp3: $(this).attr('ajax-data')
        }).jPlayer("play");
        var chunks = $(this).attr('ajax-data-alt').split(':');
        var title = chunks[0] + ':<br>' + chunks[1];
        $('#playerTitle').html(title);
        $('#poplink').attr('ajax-data', $(this).attr('ajax-data-id'));

         var playtime = $("#jquery_jplayer_1").data("jPlayer").status.currentTime;
         $.ajax({
          type: "POST",
          url: "/inc/pcnter.php",
          data: {e:$(this).attr('ajax-data-id'), t:playtime, p:0}
        });

        if ($('#player').css('display') != 'block') {
            $('#player').css('display', 'block');
            $('#player').animate({"height":"80px"}, 1000);
        }
    }
});

Output: 输出:

Playing /audio/episodes/2014_03_21_587_hello-swelo.mp3 main.js:247
Sending to GA /audio/episodes/2014_03_21_587_hello-swelo.mp3 main.js:250
jPlayer 2.5.0 : id='jquery_jplayer_1' : Error!
jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: undefined is not a function
Check your swfPath option and that Jplayer.swf is there.
Context: http://itsneworleans.com/js/jQuery.jPlayer.2.5.0/Jplayer.swf 

I added a ready() function with console output. 我添加了一个带控制台输出的ready()函数。 I found it only fired on the second Listen link click. 我发现它只在第二个Listen链接点击时触发。

After some more searching based on that result I found this post : 经过一些基于该结果的搜索后,我发现了这篇文章

"check your styles. if your #jquery_jplayer_1 or its parent has display=none, ready event never fires in such browsers as opera or firefox. i mean flash object can't be hidden." “检查你的样式。如果你的#jquery_jplayer_1或者它的父级有display = none,就不会在opera或firefox之类的浏览器中触发就绪事件。我的意思是flash对象无法隐藏。”

I can't say why it had worked previously but what was happening was that jPlayer's Flash solution was failing to load because my player had display set to none. 我不能说为什么它以前有用,但发生的事情是jPlayer的Flash解决方案无法加载,因为我的播放器显示设置为无。

So now I have offscreened player via a negative margin-top and instead of animating height I animate margin-top. 因此,现在我通过负边距顶部筛选了球员,而不是动画高度我动画margin-top。 It's all working now. 现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM