A quick double-press is indeed a single user action, as this is the desired behaviour in almost any application which uses the headset control for input. It saves developers having to debounce, queue and parse incoming control events manually and is a Good Thing(tm)!
For this to work the system will introduce a small amount of lag while it waits for further user input. It should only take a few hundred milliseconds for this to complete, after which you'll receive the event in your code.
A long, painful, but hopefully useful example of double-press detection:
- User presses down on headset control
- System notices press, waits for release
- User releases headset control
- System notices release, detects time button was held down (long press vs short press) and queues single-press event
- System waits 200ms in case it is a double-press
- It is! User presses down on headset control
- System notices press, waits for release
- User releases headset control
- System converts queued single-press event into double-press event
- System waits 200ms in case it is a triple-press
- No user input within 200ms
- System fires double-press event and clears the queue
See how the delay is necessary for single/double/triple-press detection.
When the event reaches your application it will have a subtype which describes what type of click the user made:
let rc = event!.subtype
print("received remote control \(rc.rawValue)") // 101 = pause, 100 = play
switch rc {
case .RemoteControlTogglePlayPause:
// ..
case .RemoteControlPlay:
// ..
case .RemoteControlPause:
// ..
default:break
}
An answer on a similar question pointed out these event code integers will be something like;
100 = play
101 = pause
103 = single mic click
104 = double mic click
105 = triple mic click
etc ...