私はオーディオ録音/再生アプリケーションを持っています。しかし、私は定期的に有線のiPhoneヘッドセットで再生/一時停止ボタンを使用すると、再生を一時停止したい。 は、だから私は、リモートイベントの処理を実装:remoteControlReceived(イベント:UIEvent?)トリガーされません
// MARK: Overrides
internal extension AppDelegate {
override func remoteControlReceived(with event: UIEvent?) {
super.remoteControlReceived(with: event)
/* some other logic */
}
}
それから私はapplication: didFinishLaunchingWithOptions:
で、リモートのイベント受信を開始:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
application.beginReceivingRemoteControlEvents()
becomeFirstResponder()
/* some other logic */
return true
}
しかし、いずれにせよremoteControlReceived(with event: UIEvent?)
をトリガーされることはありません。
はまた、私はMPRemoteCommandCenterを試してみました:
MPRemoteCommandCenter.shared().togglePlayPauseCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
return .success
}
が起動しません。
スイフトまたは客観的-c回答が受け付けられました。
どうしたのですか?または、私は何かを.plistに追加する必要がありますか?
はい、私はこれを試してみましたが、それもトリガしません。 –