JSFiddle - React, Tailwind, and code Playground
HTML
<button id="play">Play</button>
<h2>In Android:</h2>
<ul>
<li>Add to Homescreen</li>
<li>Launch from Homescreen</li>
<li>Click Play</li>
<li>Background (or quit) the process</li>
<li>Notice how song still plays</li>
<li>Run from Homescreen again</li>
<li>Notice how there are now two songs playing</li>
<li>You may need to force quit OTHER browser windows before all songs stop playing</li>
</ul>
JavaScript
var song = new Audio('http://zyu.me:1337/audio/Evasion.ogg');
song.loop = 'loop';
button = document.getElementById('play');
button.addEventListener("click", function () {
song.play();
});
document.addEventListener('visibilitychange', function(){
if (document.hidden) {
// Document is hidden
// This re-initialize the audio element
// to release the audio focus
song.load();
}
else {
// Document is focused
}
},false);