I want to mute and unmute audio on dynamic pages. I have audio on dynamic pages, which plays audio on submit button. I used below codes to mute audio, but problem is that, t he code works only for that particular page. W hen a user moves to next dynamic pages, the audio is not mute and user has to mute the audio again. I want to mute all site audio when a user click the mute option and same with unmute option.
I have used below code in dynamic page,
let box307 = $w( “#box307” ).global; // true
$w( “#audio1” ).mute();
and
$w( " #audio1 " ).mute();
I have tested above codes separately but could not mute sound on all dynamic pages.
(the audio sound " #audio1 " is not connected to any database)
Hey!
From what I understand, you need to mute the audio before redirection. Try to do it using onClick of the button that forwards you to the next dynamic page.
Corvid Tutorial: Adding Custom Interactivity with Events
Also, did you try to use Site tab of the Code Panel to make it work?
(Site : When an element appears on all your site pages and you want to add functionality to it that will be consistent across your site, add that code in the Site tab.)
I would recommend using conditional statements to check if the audio is currently playing and mute it when needed.
https://www.wix.com/corvid/reference/$w.AudioPlayer.html#isPlaying
Hello, thank you for commenting. I will look into conditional statements in more details to check about this.