I have search all about the setting song info for airplay, look like simple, but I still can not make my app work well.
I use MPMoviePlayerController to play an audio.
And I have also read AirPlay overview in developer.apple.com.
I have set the following code in my view
- (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;
}
}
and also set nowplayinginfo before playing music (have tried set this after playing music also)
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];
and I have set the background mode for playing audio in plist.
but there is no title, artist and album info on my TV.
Did I miss something? or there is something conflict?