davidfig / cordova-allow-background-audio

Cordova plugin that allows background audio to continue to play while app is running
MIT License
4 stars 6 forks source link

iOS 12, iPhone 8+: audio stops playing when I send app to the background #1

Open stevesobol opened 5 years ago

stevesobol commented 5 years ago

despite the use of the plugin...

After observing that it didn't work, and Googling around a bit, I also turned on the following Background Modes: Audio, AirPlay and Picture-in-Picture and (as suggested by one or two people) Voice Over IP.

No love. :(

davidfig commented 5 years ago

Does the app stop playing or the background music?

This plugin only ensures that background music can play over the app. It doesn’t change how sounds play in the app. The issue may be your sound library. What are you using?

stevesobol commented 5 years ago

HTML5

stevesobol commented 5 years ago

And I'm not sure what the answer to the first question is.

stevesobol commented 5 years ago

If the problem is indeed that the app is stopping, is there a way to prevent that from happening in Cordova? I'm already using the Insomnia plugin and it works perfectly on Android.

davidfig commented 5 years ago

What the plugin does is change the iOS value that stops background music from playing from other sources while your app is active. It does not alter what your app actually plays.

Cordova provides a resume event in the document.addEventListener('resume', handler). You can use this to reactivate playing music or sounds. Here's the documentation: https://cordova.apache.org/docs/en/latest/cordova/events/events.html

Try re-initializing the sounds on the resume event.

stevesobol commented 5 years ago

I must be missing something. Will that allow the audio to keep playing when I send the app to the background? Clarify, please...?

davidfig commented 5 years ago

Ah. You have the wrong plugin. This plugin provides the opposite functionality: it allows background music to play even when the app has its own sounds. Normally an app with sound will halt any background music.