html - disable audio from keeping playing after lock screen or press home button in safari -
i'm working on project , in case need play audio using tag in web. found out audio won't stop after lock screen or press home button. keeps playing. there way disable that? btw tried simplest way audio won't stop. here's code:
<html> <body> <audio src="./movies/1.mp3" controls="controls"> browser not support audio element. </audio> </body> </html>
maybe. can listen event hitting home button or lock screen , pause()? don't know if possible.
make use of loop, check if user on webpage. store time.
here code jquery:
var lastseen var loop = function (){ lastseen = date.now() settimeout(loop, 50) } loop() var media = $('audio, video') media.each(function () { this.addeventlistener('timeupdate', function () { if(date.now() - lastseen > 100) { this.pause() } }, false) })
Comments
Post a Comment