-
Notifications
You must be signed in to change notification settings - Fork 314
Play playlist 'CTRL+o' added #488 #695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
38ec4e9
9d26e9e
e8314db
a58077b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,6 +118,14 @@ fn handle_key_event( | |
| } | ||
| }; | ||
|
|
||
| // Example key binding: Alt+P to play the current playlist | ||
| if &key_sequence.keys[..] == [Key::Alt(crossterm::event::KeyCode::Char('p'))] { | ||
| client_pub.send(ClientRequest::Player(PlayerRequest::PlayCurrentPlaylist))?; | ||
| // Mark this event as handled and reset the key sequence | ||
| ui.input_key_sequence.keys.clear(); | ||
| return Ok(()); | ||
| } | ||
|
Comment on lines
+121
to
+127
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no this is not a correct pattern. You should define a command with keybindings and handle event based on the command |
||
|
|
||
| // if the key sequence is not handled, let the global handler handle it | ||
| let handled = if handled { | ||
| true | ||
|
|
@@ -253,6 +261,14 @@ pub fn handle_action_in_context( | |
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| Action::PlayContext => { | ||
| client_pub.send(ClientRequest::Player(PlayerRequest::StartPlayback( | ||
| Playback::URIs(vec![track.id.clone().into()], None), | ||
| None, | ||
| )))?; | ||
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| _ => Ok(false), | ||
| }, | ||
| ActionContext::Album(album) => match action { | ||
|
|
@@ -295,6 +311,15 @@ pub fn handle_action_in_context( | |
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| Action::PlayContext => { | ||
| let context_id = ContextId::Album(album.id.clone()); | ||
| client_pub.send(ClientRequest::Player(PlayerRequest::StartPlayback( | ||
| Playback::Context(context_id, None), | ||
| None, | ||
| )))?; | ||
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| _ => Ok(false), | ||
| }, | ||
| ActionContext::Artist(artist) => match action { | ||
|
|
@@ -324,6 +349,15 @@ pub fn handle_action_in_context( | |
| })?; | ||
| Ok(true) | ||
| } | ||
| Action::PlayContext => { | ||
| let context_id = ContextId::Artist(artist.id.clone()); | ||
| client_pub.send(ClientRequest::Player(PlayerRequest::StartPlayback( | ||
| Playback::Context(context_id, None), | ||
| None, | ||
| )))?; | ||
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| _ => Ok(false), | ||
| }, | ||
| ActionContext::Playlist(playlist) => match action { | ||
|
|
@@ -356,6 +390,15 @@ pub fn handle_action_in_context( | |
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| Action::PlayContext => { | ||
| let context_id = ContextId::Playlist(playlist.id.clone()); | ||
| client_pub.send(ClientRequest::Player(PlayerRequest::StartPlayback( | ||
| Playback::Context(context_id, None), | ||
| None, | ||
| )))?; | ||
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| _ => Ok(false), | ||
| }, | ||
| ActionContext::Show(show) => match action { | ||
|
|
@@ -375,6 +418,15 @@ pub fn handle_action_in_context( | |
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| Action::PlayContext => { | ||
| let context_id = ContextId::Show(show.id.clone()); | ||
| client_pub.send(ClientRequest::Player(PlayerRequest::StartPlayback( | ||
| Playback::Context(context_id, None), | ||
| None, | ||
| )))?; | ||
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| _ => Ok(false), | ||
| }, | ||
| ActionContext::Episode(episode) => match action { | ||
|
|
@@ -428,6 +480,25 @@ pub fn handle_action_in_context( | |
| } | ||
| Ok(false) | ||
| } | ||
| Action::PlayContext => { | ||
| if let Some(show) = &episode.show { | ||
| let context_id = ContextId::Show(show.id.clone()); | ||
| client_pub.send(ClientRequest::Player(PlayerRequest::StartPlayback( | ||
| Playback::Context( | ||
| context_id, | ||
| Some(rspotify::model::Offset::Uri(episode.id.uri())), | ||
| ), | ||
| None, | ||
| )))?; | ||
| } else { | ||
| client_pub.send(ClientRequest::Player(PlayerRequest::StartPlayback( | ||
| Playback::URIs(vec![episode.id.clone().into()], None), | ||
| None, | ||
| )))?; | ||
| } | ||
| ui.popup = None; | ||
| Ok(true) | ||
| } | ||
| _ => Ok(false), | ||
| }, | ||
| // TODO: support actions for playlist folders | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -298,6 +298,25 @@ fn handle_command_for_context_page( | |
| ui.new_search_popup(); | ||
| Ok(true) | ||
| } | ||
| Command::PlaySelectedPlaylist => { | ||
| if let PageState::Context { | ||
| context_page_type: ContextPageType::Browsing(context_id), | ||
| .. | ||
| } = ui.current_page() | ||
| { | ||
| if let ContextId::Playlist(_) = context_id { | ||
| client_pub.send(ClientRequest::Player(PlayerRequest::StartPlayback( | ||
| Playback::Context(context_id.clone(), None), | ||
| None, | ||
| )))?; | ||
| Ok(true) | ||
| } else { | ||
| Ok(false) | ||
| } | ||
| } else { | ||
| Ok(false) | ||
| } | ||
| } | ||
|
Comment on lines
+301
to
+319
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the logic doesn't seem right. You trigger this command in a playlist context page, so it's more like For |
||
| _ => window::handle_command_for_focused_context_window(command, client_pub, ui, state), | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for?