放送用の設定曲情報をすべて検索しましたが、一見シンプルに見えますが、それでもアプリをうまく動作させることができません。
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でオーディオを再生するためのバックグラウンドモードを設定しました。
しかし、私のテレビにはタイトル、アーティスト、アルバムの情報がありません。私は何か見落としてますか?または何か競合がありますか?