goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
24.03k stars 2.24k forks source link

html5 looping stops when in background on mobile #1194

Open lunatic-hombre opened 5 years ago

lunatic-hombre commented 5 years ago

It appears to be caused by some timeout javascript happening behind the scenes for the seamless looping, because browsers will not execute background javascript outside of web workers.

I can work around the issue by using straight javascript calls to the audio element API with loop=true instead of using Howler.

When investigating, I saw the audio elements under _sounds[0]._node had loop=true, so I'm a bit confused why it's not working.

aareeph commented 4 years ago

Hi @lunatic-hombre, have you got any fix? I faced the same issue in Howler library that audio doesn't play in loop when Android browser window is in background or phone is locked.

lunatic-hombre commented 4 years ago

Yes and no, my solution to the problem was to stop using howler.

aareeph commented 4 years ago

@lunatic-hombre which library you used instead? I am trying native HTML5 audio player but looping isn't seamless.

lunatic-hombre commented 4 years ago

Currently using a HTML5 node as a MediaElementAudioSourceNode in Web Audio API. I don't think the looping is seamless though.

aareeph commented 4 years ago

Ok, I'll give it a try and few other things as well and update you in case of any success. :)

lunatic-hombre commented 4 years ago

One other thing of note that I've discovered recently - MediaElementAudioSourceNode doesn't work on the new version of iOS (iOS 13). I submitted a feedback entry a few weeks ago but haven't gotten any response.

aareeph commented 4 years ago

It seems that iOS is giving hard time to web developers. I need to play two audios simultaneously even when the app goes in background. Unfortunately iOS had been a real disappointment as compared to Android. Play/Pause controls in Notifications, Call interruptions etc. are more stable in Android as compared to iOS.