Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting which audio track is playing on device in iOS Swift

I'm creating a mood tracking app that, among other things, should use information about the songs the user listens to. Specifically, I'm interested in just extracting the titles that are otherwise visible from the locked screen view, when a track is playing. I've search the interwebs and have had no luck finding a solution to access this data using Swift.

Can anyone help?

like image 228
Ulf Aslak Avatar asked Oct 20 '22 17:10

Ulf Aslak


1 Answers

The short answer is no.

You may be able to retrieve song information from the iTunes library (if it's not a shared song using Home Sharing). Read about MPMusicPlayerController for more information. Specially the nowPlayingItem is probably what you're looking for.

However, most third-party applications such as Spotify, Deezer or Pandora will most likely have implemented their own player, which does not integrate with the iPod music player. This blog post also covers some of the details.

like image 78
Steffen D. Sommer Avatar answered Oct 22 '22 22:10

Steffen D. Sommer