Skip to content

Instantly share code, notes, and snippets.

@jerosoler
Created May 16, 2023 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerosoler/17a48e7683c66d5b01be0a1bba1b6970 to your computer and use it in GitHub Desktop.
Save jerosoler/17a48e7683c66d5b01be0a1bba1b6970 to your computer and use it in GitHub Desktop.
Stop others players playing with wave-audio-path-player
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