First I want to discuss the scenario happening in snapchat.
In snapchat when you start recording video and song is running in background; It allows continue that song while recording video and after you record that video you can also able to hear that song in background.
I am using SCRecorder for recording video and capture image with my custom layout . Now in that I want to do just like above scenario but problem is whenever I start recording the video in background song is stopped playing.
SCRecorder is using AVCaptureSession
for recording video.
So how can I resolve this two problem:
Launch Snapchat (with the music still playing), navigate to the camera tab, and hold the big record button down to record your video message. It will record all the music your device is playing at the same time.
App Permissions Whether you're using iPhone or Android, head over to your phone's settings and make sure that the Microphone permissions are on. If you're having trouble recording audio, or even if you can't hear it, turn the permissions on and restart the application.
Here is what i used to allow background music play with SCRecorder library. Hope this help for you too.
Write this code in your AppDelegate class within didFinishLaunchingWithOptions method -
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers|AVAudioSessionCategoryOptionDefaultToSpeaker|AVAudioSessionCategoryOptionAllowBluetooth error:nil];
[session setActive:YES error:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
After this write below line in SCRecorder libaray's 'SCRecorder.m' file within prepare method after initialising AVCaptureSession.
session.automaticallyConfiguresApplicationAudioSession = NO;
If you are not a SCRecorder library user, then write above line just after initialising AVCaptureSession in your class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With