4

我已经搜索了所有关于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 中播放音频的背景模式。
但我的电视上没有标题、艺术家和专辑信息。我错过了什么?还是有什么冲突?

4

0 回答 0