Fix: Play multiples of Track and Playable

With the migration to rspotify 0.11.x playlists were changed to be a list of `Playable`
instead of `Track` items, so that playlists can contain podcast episodes.
This needs to be considered when collecting all tracks for playback in `ListView`.

Should help with #667
This commit is contained in:
Henrik Friedrichsen
2021-12-08 21:32:36 +01:00
parent dc977d758e
commit 240a0a7c41

View File

@@ -113,12 +113,14 @@ impl<I: ListItem> ListView<I> {
fn attempt_play_all_tracks(&self) -> bool { fn attempt_play_all_tracks(&self) -> bool {
let content = self.content.read().unwrap(); let content = self.content.read().unwrap();
let any = &(*content) as &dyn std::any::Any; let any = &(*content) as &dyn std::any::Any;
if let Some(tracks) = any.downcast_ref::<Vec<Track>>() { let playables = any.downcast_ref::<Vec<Playable>>();
let tracks: Vec<Playable> = tracks let tracks = any.downcast_ref::<Vec<Track>>().map(|t| {
.iter() t.iter()
.map(|track| Playable::Track(track.clone())) .map(|t| Playable::Track(t.clone()))
.collect(); .collect::<Vec<Playable>>()
let index = self.queue.append_next(&tracks); });
if let Some(tracks) = playables.or_else(|| tracks.as_ref()) {
let index = self.queue.append_next(tracks);
self.queue.play(index + self.selected, true, false); self.queue.play(index + self.selected, true, false);
true true
} else { } else {