currentTrack method
Returns the current track status from Spotify
Implementation
Future<NowPlayingTrack> currentTrack([_]) async {
final api = await this.api();
if (api is SpotifyApi) {
try {
final playbackState = await api.player.currentlyPlaying();
if (playbackState.item is Track) {
this.track = SpotifyTrack.from(playbackState);
} else {
this.track = SpotifyTrack.notPlaying;
}
} catch (e) {
print('ERROR: $e');
if (e is! ApiRateException) this.track = SpotifyTrack.notPlaying;
}
}
return this.track;
}