Group Group Group Group Group Group Group Group Group

Change BPM value of Spotify Song Swift

I am trying to build an application that plays Spotify songs. I am really confused about how to change BPM(Beats Per Minute,) value of Spotify songs.
First Step: Login through Spotify.
Second Step: Get Current user all album.
Third Step: get album track.
Last Step: play track.
I have done All step with Spotify Delegates. but I want to change the BPM value of the track.
Can someone please explain to me how to change the BPM value?

Hi @dasssham, you can try changing the speed of the track using AVAudioPlayer and the instance property rate. For example,

let song = try! AVAudioPlayer(contentsOf: URL(fileURLWithPath: selectedPath), fileTypeHint: "mp3")
song.enableRate = true
song.prepareToPlay()
song.rate = 2 
song.play()

However according to Apple’s documentation “the available range is from 0.5 for half-speed playback through 2.0 for double-speed playback.”

Best,
Gina

Thank you for your reply, but i want to change BPM of Spotify song.

Hi @dasssham,
Are you aware of the Spotify public API for developers? It can be found here [https://developer.spotify.com/documentation/ios/]

and there is a sample project that can be found here [https://github.com/spotify/ios-sdk]

From a cursory glance, I cannot see an API for changing the playback speed.

cheers,

The BPM value is only a GET property that one is unable to change using the API. I am pretty sure changing it would also go against the Spotify Terms of Service/Developer ToS. I don’t know if/how other apps do it with Spotify but it may be worth reaching out to them as I doubt Spotify will change that.