Can't seem to get .pause() in HTML iframe to work

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 :slight_smile:

I figured it out. Just n00b problems :slight_smile:
I just needed to create my audio element outside of/before my “if” statement. I thought I had read that variables created inside of an “if” are still accessible in the following “else” but either I misread that, or that’s not the case with this combination of HTML audio/iframe/postmessage/heck-if-I-know.