Question:
How to auto play audio in a loop?
Product:
Wix Studio, Wix Audio element and Velo
What are you trying to achieve:
I have certain audio files on my site, which when played should repeat with a 1 second delay in between until user pauses or goes to the pre/next audio. This audio is a short lesson to teach certain language (and repetitions help my users).
What have you already tried:
- I have an Wix audio element called
#audioPlayer3
- User presses play
- After the first play ends, it fires a OnEnded event
- In OnEnded event, I fire another $w.(“#audioPlayer3”).play();
Audio does not replay.
Additional information:
This audio is inside a repeater
Each item in the repeater is loaded from a collection
Each item consists of certain display text and an audio file (mp3).
It works ok for the first item in the repeater. When I navigate to the next items (by the prev/next buttons, it plays only once).
Any help to achieve this is appreciated.
My live site:
Browser Chrome/Brave
Device: Laptop or iPhone
My code snippet:
export function audioPlayer3_ended(event) {
// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
// Add your code for this event here:
//console.log("Audio ended. Asking to play again", "curRep = ", curRep);
$w('#audioPlayer3').play();
return;
}