Skip to content

Conversation

@ionescuaandrei
Copy link

This pull request introduces new playback functionalities and key bindings to the Spotify player, enhancing the user experience by allowing more control over playback actions. The most important changes include adding new commands and actions for playing selected playlists and contexts, as well as updating key bindings and UI elements to support these new features.

New Playback Functionalities:

  • Added PlayCurrentPlaylist to PlayerRequest enum in spotify_player/src/client/request.rs to handle playing the current playlist.
  • Implemented handling for PlayCurrentPlaylist in Client in spotify_player/src/client/mod.rs.

New Commands and Actions:

  • Added PlaySelectedPlaylist to Command enum and PlayContext to Action enum in spotify_player/src/command.rs. [1] [2]
  • Updated action constructors to include PlayContext for various entities like albums, artists, playlists, and shows in spotify_player/src/command.rs. [1] [2] [3] [4]

Key Bindings and Event Handling:

  • Added a key binding for Alt+P to play the current playlist in spotify_player/src/event/mod.rs.
  • Implemented handling for PlayContext action in different contexts (album, artist, playlist, show, episode) in spotify_player/src/event/mod.rs. [1] [2] [3] [4] [5] [6]

UI Updates:

  • Updated render_context_page function to include a "Play Context" button in the UI in spotify_player/src/ui/page.rs.
  • Added a default key binding for PlaySelectedPlaylist in KeymapConfig in spotify_player/src/config/keymap.rs.
    [Copilot is generating a summary...]

@aome510
Copy link
Owner

aome510 commented Mar 25, 2025

@ionescuaandrei can you fix the CI fail?

@ionescuaandrei
Copy link
Author

Sure I will, check and have a look

Copy link
Owner

@aome510 aome510 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating but it seems CIs still fail

Comment on lines +121 to +127
// 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(());
}
Copy link
Owner

Choose a reason for hiding this comment

The 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

PlayerRequest::TransferPlayback(..) => {
anyhow::bail!("`TransferPlayback` should be handled earlier")
}
PlayerRequest::PlayCurrentPlaylist => todo!(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Comment on lines +301 to +319
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)
}
}
Copy link
Owner

@aome510 aome510 Mar 27, 2025

Choose a reason for hiding this comment

The 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 PlayCurrentPlaylist. I think this command's functionality is covered by PlayRandom command which supports all context not just playlist context.

For PlaySelectedPlaylist command, I expect that you can trigger it on a selected item in a playlist list. You did implement Action::PlayContext already for selected playlist so probably don't need to define a separate command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants