iOS 8.4 MPNowPlayingInfoCenter 跳过/上一个消失

标签 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

感谢您的帮助!

最佳答案

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

[[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 {}

关于iOS 8.4 MPNowPlayingInfoCenter 跳过/上一个消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31303695/

相关文章:

ios - CLLocationManager didEnterRegion、didExitRegion 和 didDetermineState 的委托(delegate)方法未在 iOS 8.4(设备)上调用

ios - 当 allowsPickingMultipleItems = true 时,MPMediaPickerController 不指示选择

ios - 重建时持久存储条目保留但数据为空

ios - 使用 UICollectionView 观察 Realm - 竞争条件

iphone - UIView的旋转中心

ios - iOS 中的 GPUImage 二值化

iphone - UIWebView 的内容高度在使用 mathjax 时返回错误值

ios - 委托(delegate)消息是否必须始终将 void 作为返回类型?

ios - 在当前 vc 之上呈现 vc 后,第二次出现白屏。第一次没收到

pie-chart - ios 中动态值的饼图