Last active
December 16, 2020 20:25
-
-
Save BroFox86/ffc36d5e8649dee3f37468a624ce0804 to your computer and use it in GitHub Desktop.
[Pause audio] Pause previous track when the next track starts playing #media
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
// Pause current track when another track starts playing. | |
document.addEventListener("play", ({ target }) => { | |
const audios = document.querySelectorAll("audio"); | |
for ( const audio of audios ) { | |
if ( audio !== target ) { | |
audio.pause(); | |
} | |
} | |
}, true | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment