When playing a song with the ios 7 music app the user can use slider to change song position in the lock screen/the control center. Slider is active:
swift4 You can change track position with help of MPRemoteCommandCenter on iOS 9.1 and higher.
let commandCenter = MPRemoteCommandCenter.shared()
commandCenter.changePlaybackPositionCommand.isEnabled = true
commandCenter.changePlaybackPositionCommand.addTarget(
self, action:#selector(changePlaybackPositionCommand(_:)))
and method
@objc func changePlaybackPositionCommand(_ event:
MPChangePlaybackPositionCommandEvent) -> MPRemoteCommandHandlerStatus {
let time = event.positionTime
//use time to update your track time
return MPRemoteCommandHandlerStatus.success
}
Note that you have to do that for every command in commandCenter
if you want that commend to be enabled.