3

I am currently working on a music app in react-native and I am using react-native video to render my audio. Here's the issue that I am facing:

I pause the audio from the app then I receive a call, then the music resumes automatically even when the app is in the background for hours and I get this log in the XCode for missing entitlements.

[MRNowPlaying] Ignoring setPlaybackState because application does not contain entitlement com.apple.mediaremote.set-playback-state for platform

Here's my code:

 <Video
              source={{
                uri: audio,
              }}
              volume={playerVolume}
              onLoadStart={() => {
                setLoadingPlayer(true);
              }}
              ref={homePlayerRef}
              paused={!playHomeAudio || !playingM || activeIndex !== index}
              onLoad={(data: any) => {
                setDuration(data.duration);
              }}
              onEnd={onEndInHome}
              // playInBackground={true}
              // playWhenInactive={true}
            />

Here's what I have tried:

I created a new Entitlement.plist file and added a key for com.apple.mediaremote.set-playback-state as Boolean with the value 0. But no change in the result.

Also, I tried to create an App.entitlements file with

<key>com.apple.mediaremote.set-playback-state</key>
<true/>

Thanks in advance.

sakshya73
  • 5,570
  • 5
  • 22
  • 41
  • May I know how do you solve this issue. I am facing the same issue in ios – Alex Aung Jun 25 '22 at 17:51
  • This was happening as we were using `react-native-music-controls` with `react-native-video` to render audio. `MusicControl.handleAudioInterruptions(true);` using this function we resolved this issue. But I don't remember this exactly. @AlexAung – sakshya73 Jun 29 '22 at 05:54
  • @saksha73 Thanks for reply. I am using audio_service for flutter. – Alex Aung Jun 29 '22 at 13:17
  • @AlexAung did you find a solution for this? I'm getting the same problem using Flutter too. – Steve Neal Jan 21 '23 at 22:27
  • Did you find any solution for this in iOS? I have the same problem with https://pub.dev/packages/just_audio_background – Muhammad Hassan Jun 12 '23 at 10:57

0 Answers0