I've been playing around with Spotify API in Python (Spotipy) and I don't know how to get the duration of the track I'm currently playing on Spotify. I'm assuming it would look something like this:
global spotifyObject
trackInfo = spotifyObject.current_user_playing_track()
// would probably look something like this?
trackInfo['duration']
I suppose it would be a dictionary because trackInfo['currently_playing_type'] == 'ad'
worked successfully. After taking some time searching through the Spotipy documentation and guessing a few keywords, I still did not hit the bullseye.
In Android Java Spotify API, it was actually pretty straight forward:
mSpotifyAppRemote.getPlayerApi()
.subscribeToPlayerState()
.setEventCallback(playerState -> {
final Track track = playerState.track;
String trackName = track.name;
// here!
Long trackDuration = track.duration;
});
Any help is appreciated :)
Thank you!