I have a website with a custom audio recording when trying to leave the site. This is working fine, but the issue is that I also have a YouTube video that overlaps my audio.
I want to pause or mute my YouTube video when my audio starts playing, this is triggered by window.onbeforeunload
I tried to do so like this:
window.onbeforeunload = function () {
player.pauseVideo();
}
I already implemented the YouTube API and everything is working fine, but the pause is not being triggered. Any idea why?
Thanks!