Created
May 16, 2023 18:05
-
-
Save jerosoler/17a48e7683c66d5b01be0a1bba1b6970 to your computer and use it in GitHub Desktop.
Stop others players playing with wave-audio-path-player
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelector("body").addEventListener("click", (e) => { | |
if(e.target.tagName == "WAVE-AUDIO-PATH-PLAYER") { | |
const elementToPlay = e.target; | |
if(elementToPlay.audio.paused === false) { | |
const players = document.querySelectorAll("WAVE-AUDIO-PATH-PLAYER"); | |
players.forEach(ele => { | |
if(ele.audio.paused === false) { | |
ele.playPause(); | |
} | |
}); | |
elementToPlay.playPause(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment