getSongArtwork method

Future<Uint8List> getSongArtwork(
  1. int databaseId,
  2. int songId, {
  3. int? sessionId,
})

Get song artwork from the server.

Throws DaapImproperlyConfiguredException in case of calling without supplied sessionId before connect call.

Implementation

Future<Uint8List> getSongArtwork(int databaseId, int songId,
    {int? sessionId}) async {
  var url = _baseUrl;
  if (sessionId != null) {
    url = url.replace(
        path: Interpolator(songArtworkUrlPath)({
          "databaseId": databaseId.toString(),
          "songId": songId.toString(),
        }),
        queryParameters: {"session-id": sessionId.toString()});
  } else {
    if (sessionInfo != null) {
      return await getSongArtwork(databaseId, songId,
          sessionId: sessionInfo!.getAtom(dmapCodeDmapSessionId));
    } else {
      throw DaapImproperlyConfiguredException(
          // ignore: lines_longer_than_80_chars
          "Can't get 'sessionId' from 'sessionInfo'. First, try to connect to the server.");
    }
  }
  return await request(url);
}