【问题标题】:iOS 8.4 MPNowPlayingInfoCenter skip/prev disappearediOS 8.4 MPNowPlayingInfoCenter 跳过/上一个消失了
【发布时间】:2015-09-27 00:20:52
【问题描述】:

我正在开发一个音乐播放应用程序,在以前的 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];

但结果是……

感谢您的帮助!

【问题讨论】:

    标签: ios iphone ios8.4


    【解决方案1】:

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

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

    我在 AppDelegate 中添加了这个

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

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

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

    【讨论】:

      猜你喜欢
      • 2014-01-07
      • 2015-09-21
      • 2015-10-14
      • 2018-10-22
      • 1970-01-01
      • 2015-06-27
      • 2012-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多