summaryrefslogtreecommitdiff
path: root/plugins/hotkeys
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-11-18 21:29:27 +0100
committerGravatar waker <wakeroid@gmail.com>2012-11-18 21:29:27 +0100
commit467b422e1b015a7b8bd94a03d61aa2a6843464a9 (patch)
tree2a3d57b7b300a6dda5edbd1e6cef114fbc151c01 /plugins/hotkeys
parent2a3845d0b8a9a8d0d08cc1c17699ee8cf7a702ee (diff)
hotkeys for seeking
Diffstat (limited to 'plugins/hotkeys')
-rw-r--r--plugins/hotkeys/hotkeys.c96
1 files changed, 82 insertions, 14 deletions
diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c
index c516385e..451f1d4c 100644
--- a/plugins/hotkeys/hotkeys.c
+++ b/plugins/hotkeys/hotkeys.c
@@ -606,14 +606,66 @@ action_play_random_cb (struct DB_plugin_action_s *action, int ctx) {
}
int
-action_seek_forward_cb (struct DB_plugin_action_s *action, int ctx) {
- deadbeef->playback_set_pos (deadbeef->playback_get_pos () + 5);
+action_seek_5p_forward_cb (struct DB_plugin_action_s *action, int ctx) {
+ deadbeef->pl_lock ();
+ DB_playItem_t *it = deadbeef->streamer_get_playing_track ();
+ if (it) {
+ float dur = deadbeef->pl_get_item_duration (it);
+ if (dur > 0) {
+ float pos = deadbeef->streamer_get_playpos ();
+ deadbeef->sendmessage (DB_EV_SEEK, 0, (pos + dur * 0.05f) * 1000, 0);
+ }
+ deadbeef->pl_item_unref (it);
+ }
+ deadbeef->pl_unlock ();
+ return 0;
+}
+
+int
+action_seek_5p_backward_cb (struct DB_plugin_action_s *action, int ctx) {
+ deadbeef->pl_lock ();
+ DB_playItem_t *it = deadbeef->streamer_get_playing_track ();
+ if (it) {
+ float dur = deadbeef->pl_get_item_duration (it);
+ if (dur > 0) {
+ float pos = deadbeef->streamer_get_playpos ();
+ deadbeef->sendmessage (DB_EV_SEEK, 0, (pos - dur * 0.05f) * 1000, 0);
+ }
+ deadbeef->pl_item_unref (it);
+ }
+ deadbeef->pl_unlock ();
+ return 0;
+}
+
+int
+action_seek_1p_forward_cb (struct DB_plugin_action_s *action, int ctx) {
+ deadbeef->pl_lock ();
+ DB_playItem_t *it = deadbeef->streamer_get_playing_track ();
+ if (it) {
+ float dur = deadbeef->pl_get_item_duration (it);
+ if (dur > 0) {
+ float pos = deadbeef->streamer_get_playpos ();
+ deadbeef->sendmessage (DB_EV_SEEK, 0, (pos + dur * 0.01f) * 1000, 0);
+ }
+ deadbeef->pl_item_unref (it);
+ }
+ deadbeef->pl_unlock ();
return 0;
}
int
-action_seek_backward_cb (struct DB_plugin_action_s *action, int ctx) {
- deadbeef->playback_set_pos (deadbeef->playback_get_pos () - 5);
+action_seek_1p_backward_cb (struct DB_plugin_action_s *action, int ctx) {
+ deadbeef->pl_lock ();
+ DB_playItem_t *it = deadbeef->streamer_get_playing_track ();
+ if (it) {
+ float dur = deadbeef->pl_get_item_duration (it);
+ if (dur > 0) {
+ float pos = deadbeef->streamer_get_playpos ();
+ deadbeef->sendmessage (DB_EV_SEEK, 0, (pos - dur * 0.01f) * 1000, 0);
+ }
+ deadbeef->pl_item_unref (it);
+ }
+ deadbeef->pl_unlock ();
return 0;
}
@@ -879,20 +931,36 @@ static DB_plugin_action_t action_play_random = {
.next = &action_play_pause
};
-static DB_plugin_action_t action_seek_forward = {
- .title = "Playback/Seek Forward",
- .name = "seek_fwd",
+static DB_plugin_action_t action_seek_1p_forward = {
+ .title = "Playback/Seek 1% forward",
+ .name = "seek_1p_fwd",
.flags = DB_ACTION_COMMON,
- .callback = action_seek_forward_cb,
+ .callback = action_seek_1p_forward_cb,
.next = &action_play_random
};
-static DB_plugin_action_t action_seek_backward = {
- .title = "Playback/Seek Backward",
- .name = "seek_back",
+static DB_plugin_action_t action_seek_1p_backward = {
+ .title = "Playback/Seek 1% backward",
+ .name = "seek_1p_back",
+ .flags = DB_ACTION_COMMON,
+ .callback = action_seek_1p_backward_cb,
+ .next = &action_seek_1p_forward
+};
+
+static DB_plugin_action_t action_seek_5p_forward = {
+ .title = "Playback/Seek 5% forward",
+ .name = "seek_5p_fwd",
+ .flags = DB_ACTION_COMMON,
+ .callback = action_seek_5p_forward_cb,
+ .next = &action_seek_1p_backward
+};
+
+static DB_plugin_action_t action_seek_5p_backward = {
+ .title = "Playback/Seek 5% backward",
+ .name = "seek_5p_back",
.flags = DB_ACTION_COMMON,
- .callback = action_seek_backward_cb,
- .next = &action_seek_forward
+ .callback = action_seek_5p_backward_cb,
+ .next = &action_seek_5p_forward
};
static DB_plugin_action_t action_volume_up = {
@@ -900,7 +968,7 @@ static DB_plugin_action_t action_volume_up = {
.name = "volume_up",
.flags = DB_ACTION_COMMON,
.callback = action_volume_up_cb,
- .next = &action_seek_backward
+ .next = &action_seek_5p_backward
};
static DB_plugin_action_t action_volume_down = {