javascript - Wait for jPlayer to finish loading files before continuing loop -


I am using jQuery Audio Player 'jPlayer', I have a loop that creates many japplers unique instances, For each installation, which assigns them, click on 'Japplayer Play' on the second part of the document. The problem is that the japlayer uses an internal ready: function () {} to specify and load the audio path. I want to end this function before continuing the loop. Must have to wait for.

Pseudocode is something like this:

  for making loop {making JAPlayer's devel; Assign the audio file to Immediate and Ready () to JPlayer; // To run the file, one has to wait before continuing on the click event; }  

I'm sure it's about using queues, but I do not know how it will be implemented. Any help would be most appreciated!

You can try to do something like this:

Function Input Player (PlayerQue) {if (Player Que Length> gt; {var player = playerQueue.pop (); // Get our options hash for this running var container = $ ('& lt; div id = "' + player.container + '" & gt; & lt; / div & gt;') Apendeau ('body'); $ (Container) Japlayer ({ready: function} {var _e = this.element; _e.jPlayer ('setFile', player.file); tim timer = set interval (function () {if (_e.jPlayer ('== 100) { $ (Player.control). (Function () {// specify your handler} // next player init}}, 500);}, / * ... other options ... invoke ...) ;}} InlayPlayer ([Container: 'Audio-1', File: 'For Yuri / File', Control: '# Button-1'}, {Container: 'Audio-2', File: 'uri / for / File ', control:' # button-2 '}, {container:' audio-3 ', file:' uri / for / file ', control:' # button-3 '}, {contain : 'Audio-4', file: 'uri / for / file', control: '# button-4'}]);

In fact, we get rid of a clear loop and Instead, use the ready-to-use function to forward the creation frequency through the initplayer function. Using an array, we can use pop , which We will get that last element of the array, while it will also be removed from the array. We think the load percentage of every 500 ms player After donating 100 percent of the weight, we wait for the call to initPlayer .

This is just a suggestion and a lot of work may be required ... Ive never used the japlayer and are blindfolded by the documents so it is not expected to work outside the box: -).


Comments