Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jPlayer stops on calling jQuery.load() method to refresh content on chrome but works on firefox

I am using jPlayer to play audio. We need the play to be uninterrupted. For this, we are using the jQuery.load() method to load page content and replacing the content on the page.

We are not refreshing the jPlayer content in any way.

The code works fine in firefox and jPlayer plays audio without interruption. But on chrome and safari, jPlayer stops and then restarts just after the execution of the jquery load method.

Also, when I run the code on local machine, their is no interruption in any browser. Only when I run the code on the server their is an interruption.

We need the music to be without interruptions.

My code is as below:

function loadContent(pagePath) {
    //Method called on menu click to load content without page refresh
    //Loading the said page (pagePath - relative path of page)
    jQuery('#containerDiv').fadeOut(200, function() {
    jQuery('#waitingDiv').show();
        jQuery(this).empty();
        jQuery(this).load(pagePath, function() {
        jQuery(this).fadeIn(200, function() {
            jQuery('#waitingDiv').hide();
        });
    });
    });
}

//JPlayer initiation code on first page load
jQuery("#jquery_jplayer_1").jPlayer({
    ready: function () {
        jQuery(this).jPlayer("setMedia", {mp3: '../'+path});
    },
    swfPath: "../swf",
    supplied: "mp3",
    wmode: "window"
});

ANy suggestions?

Thanks Akhilesh Aggarwal

like image 589
Akhilesh Aggarwal Avatar asked Nov 13 '22 14:11

Akhilesh Aggarwal


1 Answers

Try moving the JPlayer initiation code above the loadContent function

like image 169
Ian Avatar answered Nov 15 '22 07:11

Ian