Get current playing song from Spotify iOS app

Viewed 5921

I'm trying to get info about the current playing song in Spotify iOS app. The scenario is as follows: Open Spotify iOS app, start playing a song. Put the app in background and open my iOS app. Is there any way I could get the song playing on Spotify, in my iOS app?

I have tried using the nowPlayingItem property as described in this post, but it didn't work: On iPhone: Find out what song is currently playing? (in the iPod music player)

I have tried using the [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo as described in this post, but it didn't work: Is there a way to access the currently played track while the iPhone is connected to an accessory?

I have seen the same question asked in this post on apple developer forums: https://devforums.apple.com/message/903640#903640.

Has anyone encountered this problem? Have you found a viable solution?

Thanks,

4 Answers

With the latest version of the Spotify iOS SDK (introduced around Sep 2018) you can now subscribe for player events and detect when a new track starts playing.

For more info check their the quick-start tutorial.

First you need to connect spotify app to your app then you can get from SPTAppRemotePlayerState?.track.uri from this you get uri

Related