updateNowPlaying method

Future<void> updateNowPlaying({
  1. required String track,
  2. required String artist,
  3. String? album,
  4. String? albumArtist,
  5. int? trackNumber,
  6. Duration? duration,
})

Used to notify Last.fm that a user has started listening to a track.

Please note: this method does NOT scrobble (add to history or charts). You must use scrobble to actually commit these. Follow the rules on that method.

The "Now Playing" service lets a client notify Last.fm that a user has started listening to a track. This does not affect a user's charts, but will feature the current track on their profile page, along with an indication of what music player they're using.

This API method call is optional for scrobbling clients, but recommended. Requests should be sent as soon as a user starts listening to a track.

Implementation

Future<void> updateNowPlaying({required String track, required String artist, String? album, String? albumArtist, int? trackNumber, Duration? duration}) {
  return write("track.updateNowPlaying", {
    "track": track,
    "artist": artist,
    if (album != null) "album": album,
    if (albumArtist != null) "albumArtist": albumArtist,
    if (trackNumber != null) "trackNumber": trackNumber.toString(),
    if (duration != null) "duration": duration.inSeconds.toString(),
  });
}