Ulf Aslak Ulf Aslak - 1 year ago 92
Swift Question

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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download