How do I autostop the first audio/media clip once the first one is playing? | XM Community
Solved

How do I autostop the first audio/media clip once the first one is playing?

  • 26 May 2020
  • 1 reply
  • 4 views

I want to have three different audio clips on a page for comparison. I would like it so that if the user presses the button to play audio clip 2 while audio clip 1 is playing, audio clip one pauses or stops so that there is only one audio clip playing at a time. Is this possible?

PS: I should have API access in a day or two if that allows for this feature!

icon

Best answer by rondev 27 May 2020, 00:08

View original

1 reply

Userlevel 7
Badge +22

Put this code in the JS onReady function:
jQuery("audio").bind("play",function (){
jQuery("audio").not(this).each(function (index, audio) {
audio.pause();
});
});

Leave a Reply