nativescript-audio icon indicating copy to clipboard operation
nativescript-audio copied to clipboard

Keep audio playing when phone is locked? (iOS)

Open NL33 opened this issue 6 years ago • 6 comments

Right now, on iOS (could be android too), if the audio is playing and then locked, the audio stops playing. Using init from url in case relevant. Is there a way to keep the audio playing when the phone is locked?

This is similar to this issue: https://github.com/nstudio/nativescript-audio/issues/19. I did not see a resolution there. Thanks.

NL33 avatar Oct 05 '18 17:10 NL33

@NL33 not possible with the current implementation, you need to run a background service and play audio through it. Media playback on android is a nightmare, I had to write a background service and a media notification in java once, and it took me at least a week before I got it working.

I haven't checked yet, but with the new androidX stuff, it might be easier to get it working in native code.

I remember that iOS was easier.

rigor789 avatar Oct 05 '18 18:10 rigor789

Thanks. I am hoping it is possible without going into the "long running tasks" background execution processes--that appears to be a deeper change to the app than I hope would be necessary.

I also see that @bradmartin said in #19: "The plugin should continue playing if you lock the device screen or minimize the app. " Maybe there is some other way?

NL33 avatar Oct 05 '18 19:10 NL33

I actually have the source to do background audio with this plugin. nStudio did it for a client over a year ago and the client approved merging it into the main audio plugin (this one) so the community benefits from it. Right now it's just a lack of time merging the code and trying to minimize any major issues 😄 .

bradmartin avatar Oct 12 '18 04:10 bradmartin

@bradmartin any updates on this?

LucyTurtle avatar Dec 11 '19 19:12 LucyTurtle

@bradmartin It's working on iOS simulator ( stays playing on background [ even if it's locked or go to background ] but NOT on real device . I wonder why ?

mehdinourollah avatar Jan 27 '20 11:01 mehdinourollah

Any updates of that merge @bradmartin ?

ormedo avatar Feb 19 '20 11:02 ormedo