Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video recording with background music playing, not paused #331

Open
toddoh opened this issue Jul 30, 2016 · 2 comments
Open

Video recording with background music playing, not paused #331

toddoh opened this issue Jul 30, 2016 · 2 comments

Comments

@toddoh
Copy link

toddoh commented Jul 30, 2016

I found multiple posts on here that disabling automaticallyConfiguresApplicationAudioSession (to NO) and adding AVAudioSession codes to AppDelegate would let SCRecorder to not pause background music. (#194 (comment))

However, when I disable that option, recorder stops working for video recording preset/mode, only photo mode works properly. I see that Snapchat and Vine supports video recording even with bg music playing.

Is there any solution for this?

@aprato
Copy link
Contributor

aprato commented Aug 2, 2016

The safest way I've found is to:

let sess = AVAudioSession.sharedInstance()
do {
            try sess.setActive(false)
            try sess.setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: [ .MixWithOthers, .DefaultToSpeaker ])
            try sess.setMode(AVAudioSessionModeVideoRecording)
            try sess.setActive(true)
        } catch let error as NSError {
            print("shared audio session error: \(error.localizedDescription)")
        }

before you set the recorder's session and call startRunning

@toddoh
Copy link
Author

toddoh commented Aug 8, 2016

Thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants