I need to know how to get information about which

2019-08-10 19:22发布

I can get information (artist, album, title) of the song that is currently playing with:

let t = MPMusicPlayerController().nowPlayingItem?.title

It works fine when the music is streaming from the iOS Music Player. However, when the streaming is from other source (Spotify, Napster, Youtube, Tuneinradio, etc.) I can not get information. How can I get this information for any app?

1条回答
太酷不给撩
2楼-- · 2019-08-10 20:06

Use the nowPlayingInfo dictionary on MPNowPlayingInfoCenter.defaultCenter():

let t = MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo[MPMediaItemPropertyTitle]

MPNowPlayingInfoCenter class reference here.

查看更多
登录 后发表回答