【问题标题】:MPNowPlayingInfoCenter not show media info in iOS 8MPNowPlayingInfoCenter 在 iOS 8 中不显示媒体信息
【发布时间】:2016-01-28 07:45:07
【问题描述】:

我尝试使用此代码在锁屏和控制中心显示媒体信息,但它没有显示任何内容:

Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");

if (playingInfoCenter) {


    NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];


    MPMediaItemArtwork *albumArt = [[MPMediaItemArtwork alloc] initWithImage: [UIImage imagedNamed:@"AlbumArt"]];

    [songInfo setObject:@"Audio Title" forKey:MPMediaItemPropertyTitle];
    [songInfo setObject:@"Audio Author" forKey:MPMediaItemPropertyArtist];
    [songInfo setObject:@"Audio Album" forKey:MPMediaItemPropertyAlbumTitle];
    [songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
    [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];

}

我也设置了FirstResponding,但仍然没有看到任何东西。

- (void) viewDidAppear: (BOOL) animated
{
    [super viewDidAppear:animated];
    [self becomeFirstResponder];
    NSLog(@"is first resp: %i",[self isFirstResponder]);

    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    // Initialize the AVAudioSession here.

    [[UIApplication sharedApplication] endReceivingRemoteControlEvents];

}

- (BOOL) canBecomeFirstResponder
{
    return YES;
}

我该如何解决这个问题?谢谢

【问题讨论】:

    标签: ios objective-c iphone media-player mpnowplayinginfocenter


    【解决方案1】:

    您是否开启了如下所示的“音频、AirPlay 和画中画”?

    【讨论】:

      猜你喜欢
      • 2015-07-17
      • 1970-01-01
      • 1970-01-01
      • 2014-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多