Tuesday, 2 April 2019

How to 10 second forward or backward in Spotify player

I am trying to add(move forward) 10 second song duration or minus(move backward) 10 second in Spotify player but i am really confused how to add or minus.

When i m trying to use this code the song is not changed duration

// forward button action 
@IBAction func moveFrdBtnAction(_ sender: Any) {
  SpotifyManager.shared.audioStreaming(SpotifyManager.shared.player, didSeekToPosition: TimeInterval(10))
}

// spotify delegate method seekToPosition
func audioStreaming(_ audioStreaming: SPTAudioStreamingController!, didSeekToPosition position: TimeInterval) {
    player?.seek(to: position, callback: { (error) in
        let songDuration = audioStreaming.metadata.currentTrack?.duration as Any as! Double
        self.delegate?.getSongTime(timeCount: Int(songDuration)+1)
    })
}

We are making a music application using the same SDK in both the platforms (Android & iOS), the seekToPosition method of the Spotify SDK is working correctly in the Android version, however, it is not working in the iOS one.The delegate method calls itself but the music stops.

Can you kindly let us know why this scenario is happening, and what should we do to run it on the iOS devices as well.

Can someone please explain to me how to solve this , i've tried to solve this but no results yet.

Any help would be greatly appreciated.

Thanks in advance.



from How to 10 second forward or backward in Spotify player

No comments:

Post a Comment