Music Won't Pause When Turning Switch Off

Hey, I have what seems to be a simple issue.

So I have a switch, I want it so when you press the switch, music plays in the background, and when the switch is turned off, the music stops. I’ve tried many things, but can’t seem to get this to work. The music just keeps going until it ends or switching pages. So how do I make it so it stops/pauses when the button is turned off?

Just in case you need the code, it may not be helpful, but here is what I’m using to START the music:

export function krakenperform_click(event) {$w("#videoBox2").play();  
}

Can anyone help me with this?

$w.onReady(() => {
$w('switch1').onChange(({target})=> {
target.checked ? $w('#video').play() : $w('#video').pause();
  })
})

It’s for a switch element . It’ll be a little bit different for a button.

Thank you, it works just fine. Appreciate the help!