3

I am trying to play a list of songs from apple music using their track_id.

playlist is of type [String] and the app plays all songs in the queue.

It always starts with the first song as well, but after that everything is random each time. It acts the same way when I use the applicationMusicPlayer. Any help?

self.player = MPMusicPlayerController.systemMusicPlayer()
self.player.beginGeneratingPlaybackNotifications()
self.player.repeatMode = MPMusicRepeatMode.None
self.player.shuffleMode = MPMusicShuffleMode.Off
self.player.setQueueWithStoreIDs(playlist)
self.player.shuffleMode = MPMusicShuffleMode.Off
self.player.play()
David Schumann
  • 13,380
  • 9
  • 75
  • 96
  • 2
    I have found a hacky way to do it: Adding an observer to MPMusicPlayerControllerNowPlayingItemDidChangeNotification and setting the shuffleMode to Off every time the item changes. It's ridiculous but it works. – David Schumann Sep 23 '16 at 18:09
  • Thank you David, I set shuffle mode off before preparetoplay() and it's working. I am using applicationQueuePlayer. – Mahesh Cheliya May 07 '20 at 21:39
  • I found it needs be set after setting the queue and before calling play. – RunLoop Mar 07 '21 at 08:50

0 Answers0