Audio Player Problem

I’m having trouble getting the audio player to play when called. It seems to work sometimes and not others. This happens mostly when there are two or more audio players on the same page. Once an audio file is triggered in Velo, is there something I need to do to reset it so it doesn’t interfere with other audio players?

The official intended use of the Wix Audio Player is to have one player on a page. This does not mean it is not possible though.

If you take a look at the API reference for the Audio Player , you can test if perhaps using stop() or onEnded() maybe would allow you to stop one and start another or trigger the second only after the first has ended. I have not personally worked with this API, but that is where I would start.

Okay, I’ll try that and see if it will work.

Question: Why was the official intended use one per page? It would seem like having multiple on a page would be the normal use case scenario? I’m surprised more people haven’t found it to be an issue.

The recommendation in the link I provided is to use Wix Music if your business requires multiple audio players. I cannot say why the wix audio player does not include this functionality out of the box or if it will in the future, but you can create a Wishlist entry for it. If you do that, be sure to include why a feature like this would be important (detailed use case).

Thanks for your help Amanda. I was able to get it to work by using .stop() when the player go to onend. That seems to allow for multiple audioplayers at the same time.

Fantastic news! Do you mind posting your code here to show others how you solved this problem in case they come looking?

I created a piano keyboard with an audioPlayer above each key. I have a sequence.push() and a check() on the onEnded event to track if they click on the keys in the correct order. I just place a $w(‘#audioPlayer1’).stop() after the check.
Here is the code.

export function audioPlayer1_ended ( event ) {
sequence . push ( 1 )
check ();
$w ( ‘#audioPlayer1’ ). stop ()
}

Thank you for sharing with the community! Always appreciated