How to Pause Audio Recording?

Hi,

I have created page where user can record there audio and play it once they uploaded on there dashboard - https://bridgegap.web-stepup.com/version-test/blank-page

I have created the repeating group where users can see there audio files and play it.

For playing the audio file of that current file, I have used JavaScript

I am not able to figure out the code for pausing the audio file.

Does anybody have solution or code for this?

Viewer link - Bridge Gap | Bubble Editor

Have you tried audio.pause() ? See - HTML DOM Audio pause() Method.

Alternatively, you could use an HTML element for your audio player - it would look something like this and handle play/pause ‘natively’.

Hi,

I have tried this method but is not working.

Hi,

If you haven’t already done so, try giving your audio element an id after creating it. So …

var audio = new Audio('yourUrl');
audio.setAttribute('id','myAudio');
audio.play();

Then when you want to pause it you can do …

var audio = getElementById('myAudio');
audio.pause();
1 Like

Still doesn’t work.

Hi,

I have tried this code, but its not working.
Please see - Learningcatalyst | Bubble Editor

I am not understanding its playing the audio but I cannot able to pause it.

Hi @wsu.app18 and @nate4 ,

Apologies - you’re right, my code above does not work. First of all, the first line of the second bit should have been document.getElementById. Even then, it still doesn’t work because you actually need to display the created audio element on the page before you can get it to pause it.

I still think my earlier suggestion of using an actual media element with built-in controls is cleaner but if you really must have your own icons/buttons to control the audio, I have created an example here. I hope it is self-explanatory and that it helps.

1 Like

Is the HTML AUDIO Element an " </> HTML " visual element or a Group?

It is a visual HTML element.

This topic was automatically closed after 70 days. New replies are no longer allowed.