rFlex / SCRecorder

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

Recording video with volume buttons ? #267

Open fraxool opened 8 years ago

fraxool commented 8 years ago

Hello!

I was thinking about a good new feature for this awesome library : the ability to record segments with the volume buttons, just like in the Snapchat app for example.

I have tried to implement this feature by myself, by "observing" the volume buttons with this code (Swift) :

NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("volumeChanged:"), name: "AVSystemController_SystemVolumeDidChangeNotification", object: nil)

func volumeChanged(notification: NSNotification) {
    print(notification);
}

But I am not able to detect when the volume buttons are released. Do you know how I could do that so we can use volume buttons to record ?

Thanks! Axe

moofaces commented 8 years ago

@lapat @jlalvarez18 @germ4n has anyone figured this out yet?

twomedia commented 8 years ago

This simple library works well: https://github.com/blladnar/RBVolumeButtons

Also see this blog post on how to use the above library: http://fredandrandall.com/blog/2011/11/18/taking-control-of-the-volume-buttons-on-ios-like-camera/

twomedia commented 8 years ago

Just one note though, Apple should approve apps using the volume buttons IF it's used only with video/photo capturing. I believe if you use it anywhere else for another function they will reject it...

fresh83 commented 8 years ago

This is very interesting

mjgaylord commented 8 years ago

I've used the RBVolumeButtons library before. It works, but the only side effect of using it, is sometimes you will see the volume HUD appear. It's not a big deal, but there doesn't seem to be any way around it.

aprato commented 8 years ago

As far as the code I've seen so far this is the closest: https://github.com/jpsim/JPSVolumeButtonHandler/blob/master/JPSVolumeButtonHandler/JPSVolumeButtonHandler.m Nothing I've seen will let you know when the button itself is down or up only when the volume changes.