如何从控制中心控制向前和向后搜索?
How to control seeking forward and backward from control center?
我真的试着打开它,但没有成功;)有什么办法可以做到这一点吗?
这是我设置远程控制的方式:
private func setupRemoteControl() {
commandCenter.previousTrackCommand.isEnabled = false
commandCenter.nextTrackCommand.isEnabled = false
commandCenter.skipBackwardCommand.isEnabled = false
commandCenter.skipForwardCommand.isEnabled = false
commandCenter.seekForwardCommand.isEnabled = true
commandCenter.seekBackwardCommand.isEnabled = true
commandCenter.changePlaybackPositionCommand.isEnabled = true
commandCenter.playCommand.isEnabled = true
commandCenter.pauseCommand.isEnabled = true
commandCenter.playCommand.addTarget(self, action: #selector(play))
commandCenter.pauseCommand.addTarget(self, action: #selector(pause))
}
我错过了什么?
暂停和播放效果完美。
事件处理程序
您需要为所有要接收的事件添加处理程序:
commandCenter.changePlaybackPositionCommand.addTarget(handler: { (event) in
// Handle position change
return MPRemoteCommandHandlerStatus.success
})
Apple 文档
... To respond to a particular event, register a handler with the appropriate MPRemoteCommand object.
https://developer.apple.com/documentation/mediaplayer/mpremotecommand
我真的试着打开它,但没有成功;)有什么办法可以做到这一点吗?
这是我设置远程控制的方式:
private func setupRemoteControl() {
commandCenter.previousTrackCommand.isEnabled = false
commandCenter.nextTrackCommand.isEnabled = false
commandCenter.skipBackwardCommand.isEnabled = false
commandCenter.skipForwardCommand.isEnabled = false
commandCenter.seekForwardCommand.isEnabled = true
commandCenter.seekBackwardCommand.isEnabled = true
commandCenter.changePlaybackPositionCommand.isEnabled = true
commandCenter.playCommand.isEnabled = true
commandCenter.pauseCommand.isEnabled = true
commandCenter.playCommand.addTarget(self, action: #selector(play))
commandCenter.pauseCommand.addTarget(self, action: #selector(pause))
}
我错过了什么?
暂停和播放效果完美。
事件处理程序
您需要为所有要接收的事件添加处理程序:
commandCenter.changePlaybackPositionCommand.addTarget(handler: { (event) in
// Handle position change
return MPRemoteCommandHandlerStatus.success
})
Apple 文档
... To respond to a particular event, register a handler with the appropriate MPRemoteCommand object.
https://developer.apple.com/documentation/mediaplayer/mpremotecommand