Swift - open the music app and play specific album

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Swift - open the music app and play specific album



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.




1 Answer
1



You want the MPMusicPlayerController systemMusicPlayer.


systemMusicPlayer



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



It is the Music app.





Can't believe I missed this... Thank you!
– Andrew B
Aug 12 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 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.
– Andrew B
Aug 12 at 15:55






Oh well yeah, it switches because I left the old code there! So you are absolutely right
– Andrew B
Aug 12 at 15:57






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard