blob: 91b5f86637b59336cdde4878d6bde90f53d72143 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
use crate::app::{App, AppResult};
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
match key_event.code {
KeyCode::Char('q') | KeyCode::Esc => app.quit(),
KeyCode::Char('c') | KeyCode::Char('C') => {
if key_event.modifiers == KeyModifiers::CONTROL {
app.quit();
}
}
KeyCode::Char('j') => {
app.song_list.next();
}
KeyCode::Char('k') => {
app.song_list.prev();
}
KeyCode::Enter | KeyCode::Char('l') => {
let song = app.conn.get_song_with_only_filename(app.conn.songs_filenames.get(app.song_list.index).unwrap());
app.conn.push(&song)?;
// app.update_queue();
}
// Playback controls
// Toggle Pause
KeyCode::Char('p') => {
app.conn.toggle_pause();
}
// Pause
KeyCode::Char('s') => {
app.conn.pause();
}
// Clearn Queue
KeyCode::Char('x') => {
app.conn.conn.clear()?;
// app.update_queue();
}
KeyCode::Char('d') => {
app.conn.play_dmenu()?;
}
KeyCode::Down=> {
app.pl_list.next();
}
KeyCode::Up=> {
app.pl_list.prev();
}
KeyCode::Right => {
app.conn.push_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?;
}
KeyCode::Char('f')=> {
// let place = app.conn.conn.status().unwrap().duration;
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 )?;
}
KeyCode::Char('b')=> {
// let place = app.conn.conn.status().unwrap().duration;
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 )?;
}
_ => {}
}
Ok(())
}
|