同时有效作用区域:AppleTV、AirPlay投射,耳机线控,车载系统显示等位置
关键词:RemoteControl
设定代码
RemoteComtrol
会以事件方式通知到整个responder chain
,通常在responder chain
的末端UIApplication
(Swift下使用@UIApplicationMain
进行标记)中实现RemoteComtrol
事件处理最为合理。
UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
override func remoteControlReceivedWithEvent(event: UIEvent?){
switch event {
case is UIEventSubtypeRemoteControlPlay:
// play
case is UIEventSubtypeRemoteControlPause:
// pause
case is UIEventSubtypeRemoteControlStop:
// stop
}
}
UIEventSubtype 中定义的其他枚举事件类型
UIEventSubtypeRemoteControlPlay
UIEventSubtypeRemoteControlPause
UIEventSubtypeRemoteControlStop
UIEventSubtypeRemoteControlTogglePlayPause
UIEventSubtypeRemoteControlNextTrack
UIEventSubtypeRemoteControlPreviousTrack
UIEventSubtypeRemoteControlBeginSeekingBackward
UIEventSubtypeRemoteControlEndSeekingBackward
UIEventSubtypeRemoteControlBeginSeekingForward
UIEventSubtypeRemoteControlEndSeekingForward