Forum Academy Marketplace Showcase Pricing Features

Run Javascript audio PLAY/STOP with RG

Greetings,

I need help to recognise the played audio in the BG without making the sound repeatedly played when clicked on PLAY button in one script in a repeating group.

Screen Shot 2021-08-09 at 2.02.23 AM

Looking for a solution to PLAY/STOP audio accordingly.

Thank you

You will need an audio element that is universally accessible to various Bubble elements (like buttons within an RG)

My approach would be creating a custom HTML element with an HTML5 audio element with a custom id (id=“myAudio”)

And then the custom Javascript runs on button click. In this JS, it controls the audio by referring to it with this custom id (myAudio).

In your screenshot, it looks like you’re creating it within a JS action, but it may not be accessible from elsewhere since it’s scope is limited to the section or function it is in.

1 Like

@blurapps Great approach and less headaches

Grabbed an HTML element and added a button that calls that function JS when clicked with document.getElementById(‘my-audio’), and now it is not looping but the problem is that if i clicked on other cell, the audio played in the BG together.

No loop - Solved
different cell function - Still played together

Did you put the HTML Element in the RG?
If so, put it outside the RG.

If not, you could add a ‘stop’ action before each ‘play’ action on every button click

@blurapps Yes inner HTML, Otherwise i can’t recognise the audio for each RG listing.

Regarding your suggestion “you could add a ‘stop’ action before each ‘play’ action on every button click” Interesting, I did not think that way simple and will get back to you for update after finishing other functionality first.

@blurapps Unfortunately, we can’t make an action before the function since i use the same button and html element with togglePlay including FALSE/TRUE.

The suggestion is like implementing myAudio.currentTime = 0; for the current cell.

What we should do is to stop the loaded server audio’s except from current.

1 Like