I have a released app that just started having trouble setting the nowPlayingItem on MPMusicPlayer for Apple Music tracks. This code works as expected for iTunes tracks on the device, but if the mediaitem set is an Apple Music track, a random track that is in the user's Apple Music library - but not in the current playerqueue - ends up playing. I suspect something has changed in iOS10.3.x or Apple Music is burbing just now. Anyone have ideas of how I could fix this?
Basic code is:
MPMusicPlayerController *musicPlayer;
[musicPlayer stop];
NSLog(@"*** trying to set nowplayingitem to %@", [UIAppDelegate.activeTrack.mediaitem valueForProperty:MPMediaItemPropertyTitle]);
musicPlayer.nowPlayingItem = UIAppDelegate.activeTrack.mediaitem ;
NSLog(@"nowplaying item is:%@", musicPlayer.nowPlayingItem.title);
[musicPlayer play];
if (![musicPlayer.nowPlayingItem.title isEqualToString:UIAppDelegate.activeTrack.name]){
NSLog(@">>>>>>> now playing does not equal current track so return and scratch head");
return;
}
2017-04-14 09:43:14.535079-0400 MyFitnessDJ[720:241825] *** trying to set nowplayingitem to Blame
2017-04-14 09:43:14.761134-0400 MyFitnessDJ[720:241825] nowplaying item is:(null)
2017-04-14 09:43:14.819226-0400 MyFitnessDJ[720:241825] >>>>>>> now playing does not equal current track so return and scratch head
Does anyone have any idea why the nowplaying item would not set to the correct Apple Music track with iOS10.3.x or could there be a burb in Apple Music?