Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1101709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:04:27+00:00 2026-05-17T01:04:27+00:00

I’m using the jQuery audio player ‘jPlayer’, I have a loop which creates a

  • 0

I’m using the jQuery audio player ‘jPlayer’, I have a loop which creates a number of jPlayer unique instances then assigns an on click ‘jPlayer play’ to another part of the document for each instance.. The problem is jPlayer uses an internal ready: function() {} to assign the audio path and load the file.. I need to wait for this function to finish before continuing the loop.

The pseudocode is something like this:

for loop{

create jPlayer div;

instantiate jPlayer and assign audio file in the ready(); // need to wait before continuing

assign an on click event to play file;
}

I’m convinced it’s about using queues but I wouldn’t know how to implement it? Any help would be most appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:04:27+00:00Added an answer on May 17, 2026 at 1:04 am

    You might try something like this:

    function initPlayer(playerQueue){
      if(playerQueue.length > 0) {
        var player = playerQueue.pop(); // get our options hash for this iteration
        var container = $('<div id="'+player.container+'"></div>').appendTo('body');
    
        $(container).jPlayer({
          ready: function(){
            var _e = this.element;
            _e.jPlayer('setFile', player.file);
            var timer = setInterval(function(){
                if(_e.jPlayer('getData', 'diag.loadPercent') == 100){
                   $(player.control).click(function(){
                      // assign your handler
                   });
                   clearInterval(timer); // clear the interval
                   initPlayer(playerQueue); // invoke the next player init
                }
            },500);
          },
          /* ... other options ... */
        });
      }
    }
    
    initPlayer([
      {container: 'audio-1', file: 'uri/for/file', control: '#button-1'},
      {container: 'audio-2', file: 'uri/for/file', control: '#button-2'},
      {container: 'audio-3', file: 'uri/for/file', control: '#button-3'},
      {container: 'audio-4', file: 'uri/for/file', control: '#button-4'}
    ]);
    

    Basically we get rid of the explicit loop and instead use the ready function itself to advance the build iteration via the initPlayer function. By usin an array we can use pop() which will get us that last element of the array while also removing it from the array. We wait to invoke initPlayer until after we get a load percent of 100 by polling the load percent of the player every 500 ms.

    This is only a suggestion and may need a lot of work… ive never used jPlayer and am flying blind from the documentation so dont expect it to work out of the box :-).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.