nstudio / nativescript-audio

:microphone: NativeScript plugin to record and play audio :musical_note:
Other
150 stars 104 forks source link

Keep audio playing when phone is locked? (iOS) #127

Open NL33 opened 6 years ago

NL33 commented 6 years ago

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.

rigor789 commented 6 years ago

@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.

NL33 commented 6 years ago

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?

bradmartin commented 6 years ago

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 😄 .

LucyTurtle commented 4 years ago

@bradmartin any updates on this?

mehdinourollah commented 4 years ago

@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 ?

ormedo commented 4 years ago

Any updates of that merge @bradmartin ?