iOS 8.4 MPNowPlayingInfoCenter skip / prev消失了

时间:2015-07-08 21:04:02

标签: ios iphone ios8.4

我正在制作音乐播放应用,在以前的iOS版本中,媒体播放器会显示播放/暂停以及跳过和上一页按钮。现在,通过8.4更新,显示的所有内容都是播放/暂停。我正在以通常的方式更新MPNowPlayingInfoCenter:

NSDictionary* nowPlayingInfo = @{
    MPMediaItemPropertyTitle:[self.currentSong title],
    MPMediaItemPropertyArtist:[self.currentSong artist],
    MPMediaItemPropertyPlaybackDuration:[NSNumber numberWithDouble:(double) self.duration],
    MPNowPlayingInfoPropertyElapsedPlaybackTime: [NSNumber numberWithDouble:(double)self.currentPlaybackTime],
    MPNowPlayingInfoPropertyPlaybackRate: self.isPlaying ? @1.0 : @0.0,
    MPMediaItemPropertyArtwork: mediaPlayerArtwork,
    MPNowPlayingInfoPropertyPlaybackQueueIndex: [NSNumber numberWithInteger:playQueue.queuePosition],
    MPNowPlayingInfoPropertyPlaybackQueueCount: [NSNumber numberWithInteger:playQueue.queueIDs.count] };
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:nowPlayingInfo];

但结果却是...... enter image description here

enter image description here

感谢您的帮助!

1 个答案:

答案 0 :(得分:5)

为了获得下一个和上一个按钮,您需要添加:

[[MPRemoteCommandCenter sharedCommandCenter].nextTrackCommand addTarget:self action:@selector(remoteNextPrevTrackCommandReceived:)];
[[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand addTarget:self action:@selector(remoteNextPrevTrackCommandReceived:)];

我在AppDelegate的

中添加了这个

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

如果您已经收到远程事件,则action方法可以为空:

-(void) remoteNextPrevTrackCommandReceived:(id)event {}