podcast support (#203)

* implement search for shows/podcasts

* create Playable supertype for queue to contain tracks and episodes

* wip: implement playback of episodes

* load spotify id from uri instead of raw id to fix podcast playback

* show duration for podcast episodes

* implement generic status bar for playables (tracks and episodes)

omit saved indicator for now as the library does not yet support podcasts

* instead of only the last 50 fetch all episodes of a show

* refactor: extract Playable code to separate file

* implement playback/queuing of shows + sharing url

* implement podcast library

* migrate mpris code to Playable supertype
This commit is contained in:
Henrik Friedrichsen
2020-07-14 10:38:22 +02:00
committed by GitHub
parent 8bf06147e2
commit 1b1d392ab8
19 changed files with 723 additions and 115 deletions

View File

@@ -12,6 +12,7 @@ use unicode_width::UnicodeWidthStr;
use crate::command::{Command, GotoMode, MoveAmount, MoveMode, TargetMode};
use crate::commands::CommandResult;
use crate::library::Library;
use crate::playable::Playable;
use crate::queue::Queue;
use crate::track::Track;
use crate::traits::{IntoBoxedViewExt, ListItem, ViewExt};
@@ -146,7 +147,10 @@ impl<I: ListItem> ListView<I> {
let content = self.content.read().unwrap();
let any = &(*content) as &dyn std::any::Any;
if let Some(tracks) = any.downcast_ref::<Vec<Track>>() {
let tracks: Vec<&Track> = tracks.iter().collect();
let tracks: Vec<Playable> = tracks
.iter()
.map(|track| Playable::Track(track.clone()))
.collect();
let index = self.queue.append_next(tracks);
self.queue.play(index + self.selected, true, false);
true
@@ -351,7 +355,10 @@ impl<I: ListItem + Clone> ViewExt for ListView<I> {
TargetMode::Selected => self.content.read().ok().and_then(|content| {
content.get(self.selected).and_then(ListItem::share_url)
}),
TargetMode::Current => self.queue.get_current().and_then(|t| t.share_url()),
TargetMode::Current => self
.queue
.get_current()
.and_then(|t| t.as_listitem().share_url()),
};
if let Some(url) = url {