1
votes

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
sorry but I do not need to play nothing in my app. My app is running and other app (Player, Spotify, Napster, ...) is playing something. I want to know the title of the song which is playing in those apps to show it in my appLuis Abós

1 Answers

0
votes

Use the nowPlayingInfo dictionary on MPNowPlayingInfoCenter.defaultCenter():

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

MPNowPlayingInfoCenter class reference here.