updateNowPlaying method
Used to notify Last.fm that a user has started listening to a track. Parameter names are case sensitive.
Implementation
Future<NowPlayedTrack> updateNowPlaying({
required String track,
String? album,
required String artist,
String? albumArtist,
int? trackNumber,
Duration? duration,
DateTime? timestamp,
String? context,
String? streamId,
bool chosenByUser = false,
String? mbid,
}) async {
if (!_api.isAuth) {
return Future.error(
ScrobblenautException(
description: "You can't use this method unless you Authenticate.",
),
);
}
final parameters = {
'track': track,
'album': album,
'artist': artist,
'albumArtist': albumArtist,
'trackNumber': trackNumber,
'duration': duration?.inSeconds,
'timestamp': LastFMValueNormalizer.timestampToSecondsSinceEpoch(
timestamp,
),
'context': context,
'streamId': streamId,
'chosenByUser': (chosenByUser ? 1 : 0),
'mbid': mbid,
};
final request = Request(
api: _api,
method: 'track.updateNowPlaying',
parameters: parameters,
)..signRequest();
final response = (await request.send(mode: RequestMode.POST));
return NowPlayedTrack.parse(response);
}