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