1

I'm working on a camera app which gives the user the ability to record a video by pressing the volume button.

I'm able to detect when the volume button is pressed with this code :

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

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

However, I need to know when the volume button is released so I can stop the recording.

Do you know how I could do that ?

Thanks!

Saqib Omer
  • 5,387
  • 7
  • 50
  • 71
fraxool
  • 3,199
  • 4
  • 31
  • 57
  • Possible duplicate of [Detect volume button press and release iOS](http://stackoverflow.com/questions/14314207/detect-volume-button-press-and-release-ios) – ksa_coder Jan 28 '16 at 09:04
  • @ksa_coder not a dupicate. My question is different and I can't find a proper answer in this topic. – fraxool Jan 28 '16 at 09:07
  • Out of interest, have you seen clause 10.5 in the App Store review guidelines? https://developer.apple.com/app-store/review/guidelines/ – Paulw11 Jan 28 '16 at 09:19
  • @Paulw11 that's what I thought! So it is impossible to use volume buttons for recording purposes ? So why some other apps can do it ? – fraxool Jan 28 '16 at 09:24
  • 1
    It may be possible but you may well get rejected. Sometimes apps are approved before the guidelines change or sometimes the reviewers don't apply the guidelines consistently. I know apples camera app noises the volume buttons so it may be that apps that use the same framework also get this functionality and apple can't reject since it is their code – Paulw11 Jan 28 '16 at 09:25
  • This may not be exactly what you are looking for, but why not use the volume key as a toggle button? click for start and a click for ending. You may have to iron out a few kinks along the way, such as timing, double clicks, etc but it may work – Shravya Boggarapu Jan 09 '17 at 08:38
  • @Paulw11 I can confirm apple do allow this if used correctly. I've just included it in a camera app and it was accepted for release – TimWhiting Aug 29 '17 at 20:39

0 Answers0