Get now playing track Apple Music API

Hi,


I'm developing an app that needs to retrieve information on the track the user is listening to in Apple Music, but what I found so far in the API documentation is fetching recent activity.


Does anyone know if Apple Music API provides this service?



Thanks.

Replies

Hey, I was searching for the same, but there is´nt a API for. Really sad... other streaming services have this

Now there is. Although this is not a "now" playing API, it is the closest.

https://developer.apple.com/documentation/applemusicapi/get_recently_played_tracks

The closest thing to this is by observing the SystemMusicPlayer.shared this class gives you queue and state instance properties . With the currentEntry.item of the queue you can get a Song or MusicVideo ID so you can use that to fetch the right content

More about SystemPlayer: https://developer.apple.com/documentation/musickit/systemmusicplayer

EDIT: Just noticed this was about the Apple Music API and not MusicKit