How can I programmatically disable song playback in the background of the Chrome Android process?
Here is a simple example of a page that plays a song in Chrome:
https://thomashunter.name/examples/chrome-audio-bug.html
var song = new Audio('song.ogg');
song.loop = 'loop';
button = document.getElementById('play');
button.addEventListener("click", function() {
song.play();
});
Notice how the song will continue to play in the background. Although this is good for a jukebox, it will make the player in the web game crazy.
Is there a way to turn off background playback of a single item Audioin Chrome? Or, is there at least a callback when the page loses focus, so I can start song.stop()?
source
share