nowPlaying method

Future<SongInformation?> nowPlaying({
  1. int coverArtSize = 800,
})

Retrieve information about the current playing song on the queue.

Specify a coverArtSize to fetch the current song with the coverArtSize.

Implementation

Future<SongInformation?> nowPlaying({int coverArtSize = 800}) async {
  final result = await playerChannel
      .invokeMethod('nowPlaying', <String, dynamic>{'size': coverArtSize});
  if (result == null) {
    return null;
  }
  final resobj = Map<String, dynamic>.from(result);
  final artist = Artist(albums: [], name: resobj['artist']);
  Uint8List? coverArt;
  try {
    coverArt = resobj['image'];
  } catch (_) {}
  final album = Album(
      songs: [],
      title: resobj['albumTitle'],
      albumTrackCount: resobj['albumTrackCount'] ?? 0,
      coverArt: coverArt,
      discCount: resobj['discCount'] ?? 0,
      artistName: artist.name);
  final song = Song.fromJson(resobj);
  album.songs.add(song);
  artist.albums.add(album);
  album.artistName = artist.name;
  final info = SongInformation(album: album, artist: artist, song: song);
  return info;
}