How to pause the audio with javascript?


#1

Hello i’ve a code to play audio with an audioplayer, but if the user goes to another screen with the (Back arrow <) the audio still continues. How do i pause this audio with a onclick event? Does anyone know?

javascript:void( $(’[data-label=“audioPlayer”]’).append("<audio controls id=‘player’><source src=‘https://docs.google.com/uc?export=open&id=11NdWruFqIrM8xNdh2lVNN-LAlT7Rfhpz’ type=‘audio/mp3’>Your browser does not support the audio element.</audio>") );


#2

Solved javascript:void( $("#player")[0].pause() );


#3

Minor point, but you don’t need the void(&()) unless you are directly changing a page element.


closed #4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.