rFlex / SCRecorder

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
Apache License 2.0
3.06k stars 582 forks source link

How do I allow phone music to play while using SCRecorder? #127

Open mschettler opened 9 years ago

mschettler commented 9 years ago

Whenever I enable my SCRecorder for video, it stops the background music from playing

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];

does not work.

How can I keep the music playing like Snapchat now does?

mschettler commented 9 years ago

bump

huntermonk commented 9 years ago

I haven't been able to figure this out as well, any help is much appreciated.

StormFactory commented 9 years ago

I don't use Snapchat, so I'm not sure how they do it. Are you looking to be able to record a video while music plays so you can record audio and the music at the same time? For example like a karaoke app might do?

ghost commented 9 years ago

Correct, that is the desired effect. More specifically, I want audio from other apps to be playing while I record.

For example, I could have a song playing from spotify in the background while I record.

mschettler commented 9 years ago

@StormFactory yes, exactly! right now, there doesn't seem to be a way, and I might have to refactor out SCRecorder simply for this reason

mschettler commented 9 years ago

@StormFactory any idea? @maximillionnn @huntermonk

StormFactory commented 9 years ago

@huntermonk I need something similar on a project I'm starting this week so if I come up with a solution I will report back.

huntermonk commented 9 years ago

@StormFactory @mschettler Great, let me know if there's any way I can help.

(deleted duplicate acc with username maximillionnn)

huntermonk commented 9 years ago

Hey @StormFactory , did you figure anything out here?

MartinW commented 9 years ago

@StormFactory @mschettler @huntermonk Has anyone made progress on this? Thanks

huntermonk commented 9 years ago

No progress yet. I've also noticed that if you get a phone call while the recorder is open or a player is open, you get some odd behavior. Possibly related.

On Tue, Aug 18, 2015 at 10:59 AM, MartinW notifications@github.com wrote:

@StormFactory https://github.com/StormFactory @mschettler https://github.com/mschettler @huntermonk https://github.com/huntermonk Has anyone made progress on this? Thanks

— Reply to this email directly or view it on GitHub https://github.com/rFlex/SCRecorder/issues/127#issuecomment-132258678.

sumitsharma commented 9 years ago

I got some hint from Apple Documentation and Stackoverflow. If you try this then background music will start playing irrespective of your application is coming into fore background or going into background.

https://developer.apple.com/library/ios/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/ConfiguringanAudioSession/ConfiguringanAudioSession.html

http://stackoverflow.com/questions/28715597/allows-music-playback-during-recording-video-like-snapchat-ios/32416013#32416013

Now, the background music get pause for 1 sec and then continue onwards. This happens when you app come from background to foreground and vice versa.

Code Can be download from Github https://github.com/sumitsharma/SCRecorderDemo