Detecting which audio track is playing on device in iOS Swift
Asked Answered
C

2

6

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?

Carolann answered 18/2, 2015 at 10:40 Comment(2)
Would the song information come specifically from the iTunes library, or other apps such as Spotify and Soundcloud as well?Photoflash
I was hoping to get access to this information regardless of the source. I've looked into the AVPlayer class reference, but my understanding is that it only supports management of media running from your own application and not globally. Some AVPlayer properties do however look like they could be used such as currentItem but I can't find any examples that make sense to me.Carolann
P
4

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.

Perish answered 26/2, 2015 at 19:39 Comment(0)
R
0

It is not about your ask, but it is about theme.

I made a code to get information about track in Itunes Media, and if you need get album art or correctly track name or artist, well I think it is will help you. The code is free to use in github.

ItunesSearch

Retrogressive answered 4/3, 2015 at 20:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.