spotify / android-sdk

Spotify SDK for Android
https://developer.spotify.com/documentation/android/
Apache License 2.0
473 stars 120 forks source link

Get current track position in playlist #359

Open vitaliecroitor opened 8 months ago

vitaliecroitor commented 8 months ago

UseCase: We use Spotify Android SDK to stream music in our app. Every time user opens the music player, we want to continue playback with the next song in the playlist we selected. If the playlist has 5 songs, and the user closed the player at song 2, next time he opens the player we want to start the playlist at song 3 which is last position (2) + next (1).

Problem: There is no api to get the current position of the track in the current playlist. Ideally, the track position will be passed within the PlayerState object as is on the web api

Issue found on 20.03.2024

SDK Version:

0.8.0

OS Version:

Android 10, 11, 12, 13

Scope(s):

PlayerApi, PlayerState

Steps to reproduce:

  1. Connect to Spotify sdk
  2. Start the playlist playback by uri using PlayerApi.play(uri)
  3. Use the PlayerApi.subscribeToPlayerState() to listen to PlayerState changes

Expected behaviour:

The track position in the playlist is part of the PlayerState object

Actual behaviour:

There is no way to get the position of the currently playing track within the playlist.