mardi 31 mars 2015

IOS Safari 8.1.3 WebAudio API doesn't stop in sleep mode

In HTML5 for IOS 8.1.3 Safari browser. I'm using a background music that continuously play in loop using AudioContext. On top of that, some voice over audio comes randomly for which I've used normal audio object (var _audio = new Audio()).


Everything working absolutely perfect as required. Now when I'm pressing the home button, the voice over stops immediately but the background music keeps on playing. Also if I resume the safari, voice over resumes playing from where it had stopped.


Couple of solutions came to my mind are:




  1. Don't use loop property for the context. On ended callback re-play the context. But this not possible in my situation.




  2. Use "pagehide" and "pageshow" event to know the browser going to or coming back from sleep. This is working for me but not on all devices. I'm checking this in multiple iPads and all of them are IOS 8. But strangely in some iPads the events are not getting trigger at all.




So I'm stuck here. Any suggestion would be appreciated. Thanks.


Aucun commentaire:

Enregistrer un commentaire