本文介绍了如何更改锁定屏幕/控制中心的轨道位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用ios 7音乐应用程序播放歌曲时,用户可以使用滑块更改锁定屏幕/控制中心中的歌曲位置。滑块处于活动状态:
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?
推荐答案您可以在iOS 9.1及更高版本的MPRemoteCommandCenter的帮助下更改曲目位置。
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:)]; }和方法
- (MPRemoteCommandHandlerStatus)changedThumbSliderOnLockScreen:(MPChangePlaybackPositionCommandEvent *)event { // change position [self setCurrentPlaybackTime:event.positionTime]; // update MPNowPlayingInfoPropertyElapsedPlaybackTime [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo]; return MPRemoteCommandHandlerStatusSuccess; }更多推荐
如何更改锁定屏幕/控制中心的轨道位置?
发布评论