nowPlaying method
Retrieve information about the current playing song on the queue.
Implementation
Future<SongInfo> nowPlaying() async {
if (Platform.isIOS) {
var result = await playerChannel.invokeMethod('nowPlaying');
var resobj = new Map<String, dynamic>.from(result);
Artist artist = Artist(albums: [], name: resobj["artist"]);
print(resobj["albumTrackCount"]);
Album album = Album(
songs: [],
title: resobj["albumTitle"],
albumTrackCount: resobj["albumTrackCount"],
coverArt: Image.memory(resobj["image"]),
diskCount: resobj["diskCount"],
artistName: artist.name);
Song song = Song(
albumTitle: album.title,
duration: resobj["playbackDuration"],
title: resobj["songTitle"],
trackNumber: resobj["trackNumber"],
discNumber: resobj["discNumber"],
isExplicit: resobj["isExplicitItem"],
playCount: resobj["playCount"],
artistName: artist.name,
iOSSongID: resobj["songID"].toString());
album.songs.add(song);
artist.albums.add(album);
album.artistName = artist.name;
SongInfo info = SongInfo(album: album, artist: artist, song: song);
return info;
} else {
throw PlatformException(
code: "Device is not iOS!",
message:
"Currently only iOS is supported. Feel free to contribute to Playify to help support Android.");
}
}