Swift - 打开音乐应用程序并播放特定专辑

Swift - open the music app and play specific album

我在查找有关如何使用特定专辑打开音乐应用程序并播放它的信息或文档时遇到问题。

我现在找到的最接近的是

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

我已经尝试了一些路径和选项的组合,但没有成功,它总是只是打开应用程序,除此之外什么都不做。

我最初认为这可以通过 MPMediaPlayer 打开,但它只是在应用程序中播放,现在正是我需要的。

您需要 MPMusicPlayerController systemMusicPlayer

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

音乐应用。