와 상호 작용하지 않습니다, 나는 아직도 싶지는 또 다른 시도주고 : 나는 MPMediaItems
을 재생하기 위해 노력하고있어MPMusicPlayerController이 문제의 IST 여러 번 물어 나는이에 대한 만족스러운 답을 발견하지 않은 경우에도 원격 제어
을 MPMusicPlayerController
. 여태까지는 그런대로 잘됐다. iTunes 음악 또는 Apple 음악에서 파일을 재생하려면이 기능이 필요합니다. 다른 파일은 AVPlayer를 통해 재생됩니다. AVPlayer를 연주 노래에 대한 원격 제어를 처리
사용하여 아무런 문제가 없을 것으로 보인다 :
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
및
- (void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent
또한 재생을 시작하려면이 반응 배경
AVPlayerItemDidPlayToEndTimeNotification
를 검색 할 수 있습니다 다음 노래.
이 모든 노래를 MPMusicPlayerController
으로 재생하려고 시도하면 제대로 작동하지 않는 것 같습니다. 나는이 같은 곡을 연주하기 위해 노력하고있어 :
self.audioPlayer = [MPMusicPlayerController applicationMusicPlayer];
self.audioPlayer.repeatMode = MPMusicRepeatModeNone;
[self.audioPlayer setQueueWithItemCollection:[MPMediaItemCollection collectionWithItems:@[_playerItem]]];
주어진 관찰자를 사용 : 응용 프로그램이 포 그라운드에
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(playbackStateDidChange:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(playbackItemDidChange:) name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification object:nil];
[self.audioPlayer beginGeneratingPlaybackNotifications];
경우 그들이해야대로 관찰자라고합니다. 배경으로 들어가면 관찰자는 더 이상 전화하지 않습니다. 이 경우에는 노래의 끝 부분을 감지하여 다음 곡으로 건너 뛸 수 없습니다.
또한 리모콘이 작동하지 않습니다. 내가 사용 :
[MPRemoteCommandCenter sharedCommandCenter].playCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].playCommand addTarget:self action:@selector(remotePlay)];
[MPRemoteCommandCenter sharedCommandCenter].pauseCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].pauseCommand addTarget:self action:@selector(remoteStop)];
[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand addTarget:self action:@selector(loadPreviousSong)];
[MPRemoteCommandCenter sharedCommandCenter].nextTrackCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].nextTrackCommand addTarget:self action:@selector(loadNextSong)];
하지만 전경이나 백그라운드에서 이러한 주어진 선택기가 호출됩니다.
누구든지 내 문제를 해결할 수 있습니까? 말씀 드렸듯이 Apple Music 및 iTunes Match 트랙을 재생할 때 MPMusicPlayerController
을 사용해야합니다.
관련 질문 : 음악 앱이 항목의 실제 재생을 처리
- beginReceivingRemoteControlEvents not triggering events for Apple Music
- MPMusicPlayerController breaks lock screen controls
끔찍합니다. 이 문제를 해결할 수있는 유일한 방법은 Apple에 알려주는 것입니다. 버그 신고서를 제출 했습니까? – evenodd