I’m working with the Spotify iOS SDK and having trouble with track switching. I set up two buttons that should play specific songs.
The first button plays Ed Sheeran’s “Shape of You”:
spotifyRemote.playerAPI?.play("spotify:track:7qiZfU4dY1lWllzX7mPBI3") { (response, err) in }
The second button plays Taylor Swift’s “Shake It Off”:
spotifyRemote.playerAPI?.play("spotify:track:5ghIJDpPoe3CfHMGu71E6T") { (response, err) in }
Initially everything works fine when I switch between these two tracks. However, when I let Ed Sheeran’s song finish, Spotify automatically starts playing a different track like Drake. Then when I let Taylor Swift’s song finish, another random track like Adele starts playing.
Now when I press my buttons, instead of getting Ed Sheeran and Taylor Swift, I get Drake and Adele - the tracks that played after the original ones ended.
I tried using spotifyRemote.playerAPI?.setRepeatMode(.track) but this doesn’t solve the problem. How can I make sure my buttons always play the exact tracks I want, regardless of what Spotify played automatically after those tracks ended?