I am developing a Ionic app that includes a music player. It works well but when I lock my screen in an iOS device the music stops. I've searched some solution but haven't found one, is there a quick solution or a plugin enabling this or should I need to find someone to code a Cordova plugin to enable this?
Asked
Active
Viewed 1,604 times
1
-
may be helpfull http://stackoverflow.com/questions/10429204/how-to-handle-background-audio-playing-while-ios-device-is-locked-or-on-another – Sa E Chowdary Dec 06 '16 at 06:09
-
Thank you very much, but are you sure that I can use it in a Ionic app? The code seems to be written in Swift. – TheoF Dec 06 '16 at 13:54
1 Answers
2
We used this plugin: https://github.com/AubreyHewes/cordova-background-audio
ionic plugin add nl.kingsquare.cordova.background-audio --save
# OR
ionic plugin add https://github.com/AubreyHewes/cordova-background-audio.git --save # latest

JanP
- 1,579
- 2
- 16
- 27
-
Do you have the same thing working on both Android and iOS platform? This one is only for iOS... – TheoF Dec 10 '16 at 00:44
-
Yes, unfortunately you'll have to use two plugins. For Android we use https://github.com/homerours/cordova-music-controls-plugin. And this one is Android and Windows only! You can make a distinction in your config.xlm by placing them in the right `
` tags and in your project (Android needs some coding) by putting it in a `if (ionic.Platform.isAndroid()) {...}` statement. Maybe one day, I will make a plugin for both, but that didn't fit in my projects budget. So, right now functionality is a bit different. – JanP Dec 10 '16 at 09:13