Closed aareeph closed 6 years ago
The onpause event only fires if you specifically say 'pause' on a sound. It doesn't happen automatically when you press the home screen. Take a look at the Page Visibility API - you can detect when the page is not longer visible and then pause / mute any sounds yourself
Thanks for your response @themoonrat.
I am sorry I wasn't clear about my question. Please find the attached image of iOS Control Center. My audio is Play/Resumed when I press the Play/Pause button in Control Center but the onpause event doesn't fire up in the code.
I need to let the audio play in background and therefore I think Page Visibility API wouldn't me of much use in my scenario.
Thanks!
ahhh, sorry, misunderstood.
I believe this may be an issue with what iOS is doing. When you are pausing / resuming via the control centre, you are not going via the Howler API, you are going via the os. Therefore Howler events won't be emitted
I think this is the case :) Try using html5 setting enabled?
Yes I've Html5 enabled, but it's still not working as expected.
I noticed in SoundCloud website that the song Play/Pause from the Control Center and it's state is also reflected in the web page immediately. So I think there's some way to fire events to Safari. Right now I am not sure which audio library they are using but I think they have handled this scenario well.
Thanks! :)
For me window.requestAnimationFrame()
and Howler's seek()
method did the trick. My code keeps watching audio position and as soon as I start receiving same seek()
position for few seconds it means that the audio is paused from iOS Control Center.
I am trying to listen to onpause event when user presses the Pause button on iOS Control Center but it doesn't fire the onpause event. I am trying it on iOS Safari.
Is there a way to listen to the even from iOS Control Center?
Thanks!