diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-04-24 13:56:53 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-04-24 13:56:53 +0530 |
| commit | 044101b29091eab34f5bb11ad8929db266826705 (patch) | |
| tree | b6d2c05daa0ccd182a9d139773f6901af3cba662 /src/handler.rs | |
| parent | 3f6b2bfefd54a53e675e0cffc98b704d3b8ad244 (diff) | |
handle seek forwards/backwords
Diffstat (limited to 'src/handler.rs')
| -rwxr-xr-x | src/handler.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/handler.rs b/src/handler.rs index efb8d7f..6024322 100755 --- a/src/handler.rs +++ b/src/handler.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use crate::app::{App, AppResult}; use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; @@ -69,17 +71,17 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { } KeyCode::Char('f') => { - // let place = app.conn.conn.status().unwrap().duration; + let place = app.conn.conn.status().unwrap().song.unwrap().pos; let (pos, _) = app.conn.conn.status().unwrap().time.unwrap(); - let pos: i64 = (pos.as_secs() + 2).try_into().unwrap(); - app.conn.conn.seek(2, pos)?; + let pos = Duration::from_secs(pos.as_secs().wrapping_add(2)); + app.conn.conn.seek(place, pos)?; } KeyCode::Char('b') => { - // let place = app.conn.conn.status().unwrap().duration; + let place = app.conn.conn.status().unwrap().song.unwrap().pos; let (pos, _) = app.conn.conn.status().unwrap().time.unwrap(); - let pos: i64 = (pos.as_secs() - 2).try_into().unwrap(); - app.conn.conn.seek(2, pos)?; + let pos = Duration::from_secs(pos.as_secs().wrapping_add(2)); + app.conn.conn.seek(place, pos)?; } _ => {} } |
