设置nowplayingInfo显示歌曲标题,艺术家在airplay(苹果电视),不工作

时间:2014-09-05 10:19:38

标签: ios airplay mpnowplayinginfocenter

我已经搜索了所有关于airplay的设置歌曲信息,看起来很简单,但我仍然无法使我的应用程序正常运行。
我使用MPMoviePlayerController播放音频。 我还在developer.apple.com上阅读了AirPlay概述。

我在视图中设置了以下代码

- (BOOL) canBecomeFirstResponder {return YES;}
- (void) viewDidAppear: (BOOL) animated {
    [super viewDidAppear:animated];
    [ [UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    [self becomeFirstResponder];
}
- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
    if (receivedEvent.type == UIEventTypeRemoteControl) {
        switch (receivedEvent.subtype) {
            case UIEventSubtypeRemoteControlTogglePlayPause:
               // [self playPauseToggle: nil]
                break;
            case UIEventSubtypeRemoteControlNextTrack:
                [self nextTrack: nil]
                break;
     }
}

并且在播放音乐之前设置了nowplayinginfo(在播放音乐之后尝试设置了这个)

NSMutableDictionary *airPlaySongInfo = [[NSMutableDictionary alloc]init];
        [airPlaySongInfo setObject:@"hihi title"] forKey:MPMediaItemPropertyTitle];
        [airPlaySongInfo setObject:@"hihi artist"forKey:MPMediaItemPropertyArtist];
        [airPlaySongInfo setObject:@"hihi album" forKey:MPMediaItemPropertyAlbumTitle];
        [airPlaySongInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
        [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:airPlaySongInfo];


我已经设置了在plist中播放音频的背景模式 但我的电视上没有标题,艺术家和专辑信息。 我错过了什么?或者有什么冲突?

0 个答案:

没有答案