0

I'm having problems with finding out information or a documentation on how to open the music app with a specific album and playing it.

The closest I found right now is

        let url = URL(string: "music://")
    UIApplication.shared.open(url!, options: [:], completionHandler: nil)

I've tried a few combinations with the path and options but no luck, it always just opens the app and does nothing beyond that.

I initially thought this would open through the MPMediaPlayer but that just plays it in the app and is now what I need.

ab1428x
  • 794
  • 2
  • 8
  • 20

1 Answers1

2

You want the MPMusicPlayerController systemMusicPlayer.

https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller

It is the Music app.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Can't believe I missed this... Thank you! – ab1428x Aug 12 '18 at 15:53
  • Note that it won't physically _switch_ to the Music app, though you can do that in the way you were already doing it if you really need to. – matt Aug 12 '18 at 15:53
  • It actually does switch for me. Only thing is it doesn't prompt the view to the album, it just stays wherever I was previously browsing. – ab1428x Aug 12 '18 at 15:55
  • Oh well yeah, it switches because I left the old code there! So you are absolutely right – ab1428x Aug 12 '18 at 15:57