问题
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:
Use the nowPlayingInfo
dictionary on MPNowPlayingInfoCenter.defaultCenter()
:
let t = MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo[MPMediaItemPropertyTitle]
MPNowPlayingInfoCenter
class reference here.
来源:https://stackoverflow.com/questions/33163272/i-need-to-know-how-to-get-information-about-which-player-is-currently-streaming