Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created July 7, 2016 02:15
Show Gist options
  • Save quangtqag/8a731d30ecb75c2c64f2644ee05701f1 to your computer and use it in GitHub Desktop.
Save quangtqag/8a731d30ecb75c2c64f2644ee05701f1 to your computer and use it in GitHub Desktop.
//U@nCM: catch remote event here because it can be always the first responder.
// make sure we can recieve remote control events
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
[kSoundManager.musicPlayerVC remoteControlReceivedWithEvent:event];
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
//if it is a remote control event handle it correctly
if (event.type == UIEventTypeRemoteControl) {
if (event.subtype == UIEventSubtypeRemoteControlPlay) {
[self playMusic];
} else if (event.subtype == UIEventSubtypeRemoteControlPause) {
[self pauseMusic];
} else if (event.subtype == UIEventSubtypeRemoteControlTogglePlayPause) {
[self togglePlayPause];
} else if(event.subtype == UIEventSubtypeRemoteControlNextTrack) {
[self nextTrack];
} else if(event.subtype == UIEventSubtypeRemoteControlPreviousTrack) {
[self previousTrack];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment