react-native-sound icon indicating copy to clipboard operation
react-native-sound copied to clipboard

No audio player in background / locked screen [iOS, Android]

Open jelenamanot opened this issue 4 years ago • 8 comments

:beetle: Description

Hi, I have a question about having native audio player working on locked device screen or in background (in top bar). That doesn't work on both iOS & Android.

It behaves differently on iOS & Android. On iOS after locking screen - audio stops. On Android after locking screen - audio continues playing.

I would like something like this:

:beetle: What have you tried?

I tried setting Sound.setCategory('Playback'); together with updating Info.plist file, like this:

<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>

But that doesn't change anything.

Issue is with both:

  • [x] iOS
  • [x] Android

I'm using

  • [x] React Native CLI

Versions:

  • React Native Sound: 0.11.0
  • React Native: 0.61.5
  • iOS: 13
  • Android: 10

Problem occurs on both:

  • [x] Simulator
  • [x] Device

jelenamanot avatar Mar 16 '20 12:03 jelenamanot

same issues

dinhtrumdieu avatar Mar 17 '20 15:03 dinhtrumdieu

@jelenanesic It might help you react-native-track-player

bang9 avatar Mar 23 '20 06:03 bang9

@Bang9 I've found that, but that library uses old version of React Native.

jelenamanot avatar Mar 23 '20 07:03 jelenamanot

@Bang9 I've found that, but that library uses old version of React Native.

Why are you think so?

bang9 avatar Mar 23 '20 07:03 bang9

@Bang9 you can check it on their issue, since July they are trying to switch to RN 0.60.

jelenamanot avatar Mar 23 '20 09:03 jelenamanot

@jelenanesic hmm.. 🤔support RN 0.60 means migrate to AndroidX my product is working perfectly with RN 0.61.2 and RNTrackPlayer If you have a problem of AndroidX, you can resolve the issue using jetifier

bang9 avatar Mar 23 '20 10:03 bang9

are there any news on this issue?

juliangorge avatar Apr 01 '20 13:04 juliangorge

I know this error has been here for ages now. It would be nice if you would show your implementation for this because the steps you did , without updating the info.plist the music is playing on simulator but it was not working on the device. I took your info.plist code and the audio started running on screen lock in real device.

vishangj123 avatar Aug 04 '22 03:08 vishangj123