Allow `open` with an empty Playlist
Problem
Right now you can't open/initialize the player with a playlist with zero audio resources (empty playlist). The code responsible for this behavior can be seen here:
if (playable is Playlist && playable.audios.isNotEmpty) {
playlist = playable;
} else if (playable is Audio) {
playlist = Playlist(audios: [playable]);
}
if (playlist != null) {
await _openPlaylist(...)
Basically this means this code won't trigger _openPlaylist():
AssetsAudioPlayer
.newPlayer()
.open(Playlist(audios: []);
This is pretty inconvenient. Imagine having a music app that loads a list of songs from a server and allows the user to tap and queue them one by one. This basic interaction wouldn't be possible without having to check and open the player first:
void addToQueue(Audio song) {
// since there's no guarantee that the player is already open with a playlist…
if (_player.playlist == null) {
_player.open(Playlist(audios: [song]));
} else {
_player.playlist!.add(song);
}
}
Essentially, every interaction with the playlist/player now would need to check and open the player first. I hope you would agree that it would be cumbersome, if not annoying.
Suggestion
To allow open'ing a player with an empty Playlist.
am facing the issues already when using cached , it cant play the audio even after downloads are completed, you need to rebuild the page to work