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:
But when playing music in my app user can't do it. Slider isn't active:
How can i enable these feature in my app?
You can change track position with help of MPRemoteCommandCenter on iOS 9.1 and higher.
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_0) {
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
[commandCenter.changePlaybackPositionCommand setEnabled:true];
[commandCenter.changePlaybackPositionCommand addTarget:self action:@selector(changedThumbSliderOnLockScreen:)];
}
and method
- (MPRemoteCommandHandlerStatus)changedThumbSliderOnLockScreen:(MPChangePlaybackPositionCommandEvent *)event
{
// change position
[self setCurrentPlaybackTime:event.positionTime];
// update MPNowPlayingInfoPropertyElapsedPlaybackTime
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
return MPRemoteCommandHandlerStatusSuccess;
}