use mpd's load() to load playlists
This commit is contained in:
parent
7eac9cfbc6
commit
fd371e8960
|
|
@ -160,16 +160,9 @@ impl Connection {
|
|||
}
|
||||
|
||||
/// Push all songs of a playlist into queue
|
||||
pub fn push_playlist(&mut self, playlist: &str) -> Result<()> {
|
||||
let songs: Vec<Song> = self.conn.playlist(playlist)?;
|
||||
|
||||
for song in songs {
|
||||
if self.songs_filenames.contains(&song.file) {
|
||||
let song = self.get_song_with_only_filename(&song.file);
|
||||
self.conn.push(&song)?;
|
||||
self.conn.play()?;
|
||||
}
|
||||
}
|
||||
pub fn load_playlist(&mut self, playlist: &str) -> Result<()> {
|
||||
self.conn.load(playlist, ..)?;
|
||||
self.conn.play()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
|
|||
|
||||
SelectedTab::Playlists => {
|
||||
app.conn
|
||||
.push_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?;
|
||||
.load_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?;
|
||||
}
|
||||
}
|
||||
app.conn.update_status();
|
||||
|
|
@ -330,22 +330,20 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
|
|||
KeyCode::Char('e') => if app.selected_tab == SelectedTab::Playlists {},
|
||||
|
||||
// go to top of list
|
||||
KeyCode::Char('g') => {
|
||||
match app.selected_tab {
|
||||
SelectedTab::Queue => app.queue_list.index = 0,
|
||||
SelectedTab::DirectoryBrowser => app.browser.selected = 0,
|
||||
SelectedTab::Playlists => app.pl_list.index = 0
|
||||
}
|
||||
}
|
||||
KeyCode::Char('g') => match app.selected_tab {
|
||||
SelectedTab::Queue => app.queue_list.index = 0,
|
||||
SelectedTab::DirectoryBrowser => app.browser.selected = 0,
|
||||
SelectedTab::Playlists => app.pl_list.index = 0,
|
||||
},
|
||||
|
||||
// go to bottom of list
|
||||
KeyCode::Char('G') => {
|
||||
match app.selected_tab {
|
||||
SelectedTab::Queue => app.queue_list.index = app.queue_list.list.len() - 1,
|
||||
SelectedTab::DirectoryBrowser => app.browser.selected = app.browser.filetree.len() - 1,
|
||||
SelectedTab::Playlists => app.pl_list.index = app.pl_list.list.len() - 1
|
||||
KeyCode::Char('G') => match app.selected_tab {
|
||||
SelectedTab::Queue => app.queue_list.index = app.queue_list.list.len() - 1,
|
||||
SelectedTab::DirectoryBrowser => {
|
||||
app.browser.selected = app.browser.filetree.len() - 1
|
||||
}
|
||||
}
|
||||
SelectedTab::Playlists => app.pl_list.index = app.pl_list.list.len() - 1,
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue