When I first open my app Spotify music stops after that when I go back and turn on the music and come back to the my app, it works fine. I am using react-native video library for Splash screen and video doesn't have audio and also muted by component props. Is there any way to keep music alive when I open my app?
Asked
Active
Viewed 322 times
2 Answers
0
Recently i face this problem,
i think you are using
- react-native-video
- react-native-camera
These 2 libraries pause the playback music
so you need to follow these steps to resolve this problem,
react-native-video
ignoreSilentSwitch Controls the iOS silent switch behavior
ignoreSilentSwitch: "obey" - Don't play audio if the silent switch is set
mixWithOthers: "mix" - Audio from this video mixes with audio from other apps.
code Snippet:
<Video
....
ignoreSilentSwitch="obey"
mixWithOthers={'mix'}
....
/>
react-native-camera
<RNCamera
.....
captureAudio={false}
.....
/>

Mirza Hayat
- 284
- 5
- 11
0
Add this in your AppDelegate.m
#import <AVFoundation/AVFoundation.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 19 '23 at 11:50
-
i have tried to add the AVFoundation package for IOS, but when i compile the React Native App its create some issue AVAudioSession not found. – Mirza Hayat May 11 '23 at 08:08