Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ List of supported commands:
| `Shuffle` | toggle the shuffle mode | `C-s` |
| `VolumeChange` | change playback volume by an offset (default shortcuts use 5%) | `+`, `-` |
| `Mute` | toggle playback volume between 0% and previous level | `_` |
| `SeekForward` | seek forward by 5s | `>` |
| `SeekBackward` | seek backward by 5s | `<` |
| `SeekForward` | seek forward by a duration in seconds (default is 5s) | `>` |
| `SeekBackward` | seek backward by a duration in seconds (default is 5s) | `<` |
Comment thread
aome510 marked this conversation as resolved.
Outdated
| `Quit` | quit the application | `C-c`, `q` |
| `ClosePopup` | close a popup | `esc` |
| `SelectNextOrScrollDown` | select the next item in a list/table or scroll down (supports vim-style count: 5j) | `j`, `C-n`, `down` |
Expand Down
6 changes: 6 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ key_sequence = "q"
[[keymaps]]
command = { VolumeChange = { offset = 1 } }
key_sequence = "-"
[[keymaps]]
command = { SeekForward = { duration = 10 } }
key_sequence = "E"
[[keymaps]]
command = { SeekBackward = { } }
key_sequence = "Q"
```

## Actions
Expand Down
12 changes: 8 additions & 4 deletions spotify_player/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ pub enum Command {
offset: i32,
},
Mute,
SeekForward,
SeekBackward,
SeekForward {
duration: Option<u16>,
},
SeekBackward {
duration: Option<u16>,
},

Quit,
OpenCommandHelp,
Expand Down Expand Up @@ -303,8 +307,8 @@ impl Command {
Self::ToggleFakeTrackRepeatMode => "toggle fake track repeat mode",
Self::Shuffle => "toggle the shuffle mode",
Self::Mute => "toggle playback volume between 0% and previous level",
Self::SeekForward => "seek forward by 5s",
Self::SeekBackward => "seek backward by 5s",
Self::SeekForward { duration } => { return format!("seek forward by {}s", duration.unwrap_or(5)) },
Self::SeekBackward { duration } => { return format!("seek backward by {}s", duration.unwrap_or(5)) },
Self::Quit => "quit the application",
Self::ClosePopup => "close a popup",
#[cfg(feature = "streaming")]
Expand Down
4 changes: 2 additions & 2 deletions spotify_player/src/config/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ impl Default for KeymapConfig {
},
Keymap {
key_sequence: ">".into(),
command: Command::SeekForward,
command: Command::SeekForward { duration: None },
},
Keymap {
key_sequence: "<".into(),
command: Command::SeekBackward,
command: Command::SeekBackward { duration: None },
},
Keymap {
key_sequence: "enter".into(),
Expand Down
10 changes: 6 additions & 4 deletions spotify_player/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,17 +582,19 @@ fn handle_global_command(
Command::Mute => {
client_pub.send(ClientRequest::Player(PlayerRequest::ToggleMute))?;
}
Command::SeekForward => {
Command::SeekForward { duration } => {
if let Some(progress) = state.player.read().playback_progress() {
let duration = config::get_config().app_config.seek_duration_secs;
let duration =
duration.unwrap_or(config::get_config().app_config.seek_duration_secs);
client_pub.send(ClientRequest::Player(PlayerRequest::SeekTrack(
progress + chrono::Duration::try_seconds(i64::from(duration)).unwrap(),
)))?;
}
}
Command::SeekBackward => {
Command::SeekBackward { duration } => {
if let Some(progress) = state.player.read().playback_progress() {
let duration = config::get_config().app_config.seek_duration_secs;
let duration =
duration.unwrap_or(config::get_config().app_config.seek_duration_secs);
client_pub.send(ClientRequest::Player(PlayerRequest::SeekTrack(
std::cmp::max(
chrono::Duration::zero(),
Expand Down