getSong method
Get song from the server.
Throws DaapImproperlyConfiguredException in case of calling without
supplied sessionId
before connect call.
Implementation
Future<Uint8List> getSong(int databaseId, int songId, String songFormat,
{int? sessionId}) async {
var url = _baseUrl;
if (sessionId != null) {
url = url.replace(
path: Interpolator(songUrlPath)({
"databaseId": databaseId.toString(),
"songId": songId.toString(),
"songFormat": songFormat
}),
queryParameters: {"session-id": sessionId.toString()});
} else {
if (sessionInfo != null) {
return await getSong(databaseId, songId, songFormat,
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);
}