I’d like to use an HTML iframe to play a couple audio files. I can get the playback to work just fine. But so far I can’t get .pause() to work for stopping the audio. I’ve tried a couple different implementations but here is how I’m currently trying to pause the audio:
Here’s the HTML
And here’s the JS:
export function buttonEndCall_click ( event ) {
$w ( “#audioDataBase” ). onReady ( () => {
//Get the total number of items in the database
const numberOfAudios = $w ( “#audioDataBase” ). getTotalCount ();
//Get all the database items
$w ( “#audioDataBase” ). getItems ( 0 , numberOfAudios )
. then ( ( result ) => {
let items = result . items ;
//Retrieve all the audio urls from the items array and puts them into a new array
var audioURLs = items . map ( item => item [ “audioLink” ]);
$w ( '#html3' ). postMessage ( "stop|" + items [ 0 ]. audioLink );
} )
. **catch** ( ( err ) => {
**let** errMsg = err . message ;
**let** errCode = err . code ;
} );
} );
}
This whole .postMessage string-split setup works well when triggering audio to play with .play(). But I’m stumped trying to stop the audio once it’s started playing. Please show me the error in my wicked ways