3

I am using the new Apple Music API with MPMusicPlayerController but play method doesn't work in the first time called, but after the second or third time.

My code is the following:

MPMusicPlayerController *appleMusicPlayer = /*access instantiated player*/;
[appleMusicPlayer setQueueWithStoreIDs:@[url]];
[appleMusicPlayer play];

The player is instantiated as follows:

_appleMusicPlayer = [MPMusicPlayerController applicationMusicPlayer];
_appleMusicPlayer.repeatMode = MPMusicRepeatModeNone;
_appleMusicPlayer.shuffleMode = MPMusicShuffleModeOff;
[_appleMusicPlayer beginGeneratingPlaybackNotifications];

The url passed in setQueueWithStoreIDs method is a NSString with a country-specific valid iTunesID. I provide you with a screenshot of NSLog output of url after above play method is called.

NSLog

Any help would be much appreciated.

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
ozzotto
  • 1,146
  • 3
  • 13
  • 30

1 Answers1

0

Make sure url is a string of the store ID!

You can get that here: https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/

evenodd
  • 2,026
  • 4
  • 26
  • 38