Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From 751505501e0db31cf766ec0ae95a6968b4d1eb93 Mon Sep 17 00:00:00 2001 |
| 2 | From: Alban Browaeys <prahal@yahoo.com> |
| 3 | Date: Wed, 5 Sep 2012 02:58:26 +0000 |
| 4 | Subject: [PATCH] always use position as percent and define a 1 seconds |
| 5 | tolerance. |
| 6 | |
| 7 | Fix "reverb" effect: ie loop between setting the slider to match |
| 8 | the position and handling slider to position (seek). |
| 9 | --- |
| 10 | data/themes/default.edc | 8 +++----- |
| 11 | src/bin/win.c | 28 ++++++++++++++++++++++------ |
| 12 | 2 files changed, 25 insertions(+), 11 deletions(-) |
| 13 | |
| 14 | diff --git a/data/themes/default.edc b/data/themes/default.edc |
| 15 | index ebf8ba4..7a906b1 100644 |
| 16 | --- a/data/themes/default.edc |
| 17 | +++ b/data/themes/default.edc |
| 18 | @@ -186,7 +186,6 @@ collections { |
| 19 | group { |
| 20 | name: "nowplaying"; |
| 21 | script { |
| 22 | - public cur_length; |
| 23 | public mute; |
| 24 | |
| 25 | public get_time_str(Float:time, time_str[6]) |
| 26 | @@ -201,16 +200,15 @@ collections { |
| 27 | new Float:position = getfarg(2); |
| 28 | new Float:length = getfarg(3); |
| 29 | if (length > 0) |
| 30 | - external_param_set_float(PART:"progress.slider", "value", position / length * 100); |
| 31 | + external_param_set_float(PART:"progress.slider", "value", position * 100); |
| 32 | else |
| 33 | external_param_set_float(PART:"progress.slider", "value", 0); |
| 34 | |
| 35 | new time_str[6]; |
| 36 | - get_time_str(position, time_str); |
| 37 | + get_time_str(position * length, time_str); |
| 38 | set_text(PART:"ejy.text.current_time", time_str); |
| 39 | get_time_str(length, time_str); |
| 40 | set_text(PART:"ejy.text.total_time", time_str); |
| 41 | - set_float(cur_length, length); |
| 42 | } else if (type == MSG_INT && id == MSG_SHUFFLE) { |
| 43 | external_param_set_bool(PART:"buttons.shuffle", "state", getarg(2)); |
| 44 | } else if (type == MSG_INT && id == MSG_LOOP) { |
| 45 | @@ -689,7 +687,7 @@ collections { |
| 46 | source: "progress.slider"; |
| 47 | signal: "changed"; |
| 48 | script { |
| 49 | - send_message(MSG_FLOAT, MSG_POSITION, (external_param_get_float(PART:"progress.slider", "value") * get_float(cur_length) / 100)); |
| 50 | + send_message(MSG_FLOAT, MSG_POSITION, (external_param_get_float(PART:"progress.slider", "value") / 100)); |
| 51 | } |
| 52 | } |
| 53 | program { |
| 54 | diff --git a/src/bin/win.c b/src/bin/win.c |
| 55 | index 2f65953..428e268 100644 |
| 56 | --- a/src/bin/win.c |
| 57 | +++ b/src/bin/win.c |
| 58 | @@ -194,8 +194,8 @@ _win_play_eval(Win *w) |
| 59 | { |
| 60 | Edje_Message_Float_Set *mf; |
| 61 | |
| 62 | - w->play.position = emotion_object_position_get(w->emotion); |
| 63 | w->play.length = emotion_object_play_length_get(w->emotion); |
| 64 | + w->play.position = emotion_object_position_get(w->emotion) / w->play.length; |
| 65 | |
| 66 | if ((w->song) && (w->song->length != (int)w->play.length)) |
| 67 | db_song_length_set(w->db, w->song, w->play.length); |
| 68 | @@ -542,8 +542,14 @@ _win_edje_msg(void *data, Evas_Object *o __UNUSED__, Edje_Message_Type type, int |
| 69 | else |
| 70 | { |
| 71 | Edje_Message_Float *m = msg; |
| 72 | + |
| 73 | + if ((((m->val - w->play.position) * w->play.length) < 1.0) |
| 74 | + && (((w->play.position - m->val) * w->play.length) < 1.0)) |
| 75 | + return; |
| 76 | + |
| 77 | w->play.position = m->val; |
| 78 | - emotion_object_position_set(w->emotion, w->play.position); |
| 79 | + emotion_object_position_set(w->emotion, w->play.position |
| 80 | + * w->play.length); |
| 81 | ecore_event_add(ENJOY_EVENT_POSITION_CHANGE, NULL, NULL, NULL); |
| 82 | } |
| 83 | break; |
| 84 | @@ -617,16 +623,21 @@ enjoy_control_seek(uint64_t position) |
| 85 | { |
| 86 | Win *w = &_win; |
| 87 | double seek_to; |
| 88 | + double new_pos = w->play.length / ((double)position / 1e6); |
| 89 | |
| 90 | if (!w->db) return; |
| 91 | - seek_to = w->play.position + w->play.length / ((double)position / 1e6); |
| 92 | + |
| 93 | + if ((((new_pos - w->play.position) * w->play.length) < 1.0) |
| 94 | + && (((w->play.position - new_pos) * w->play.length) < 1.0)) return; |
| 95 | + |
| 96 | + seek_to = w->play.position + new_pos; |
| 97 | if (seek_to <= 0.0) |
| 98 | seek_to = 0.0; |
| 99 | else if (seek_to >= 1.0) |
| 100 | seek_to = 1.0; |
| 101 | |
| 102 | w->play.position = seek_to; |
| 103 | - emotion_object_position_set(w->emotion, w->play.position); |
| 104 | + emotion_object_position_set(w->emotion, w->play.position * w->play.length); |
| 105 | ecore_event_add(ENJOY_EVENT_POSITION_CHANGE, NULL, NULL, NULL); |
| 106 | } |
| 107 | |
| 108 | @@ -692,15 +703,20 @@ EAPI void |
| 109 | enjoy_position_set(int32_t position) |
| 110 | { |
| 111 | Win *w = &_win; |
| 112 | + double new_pos = w->play.length / ((double)position / 1e6); |
| 113 | |
| 114 | if (!w->db) return; |
| 115 | - w->play.position = w->play.length / ((double)position / 1e6); |
| 116 | + |
| 117 | + if ((((new_pos - w->play.position) * w->play.length) < 1.0) |
| 118 | + && (((w->play.position - new_pos) * w->play.length) < 1.0)) return; |
| 119 | + |
| 120 | + w->play.position = new_pos; |
| 121 | if (w->play.position < 0.0) |
| 122 | w->play.position = 0.0; |
| 123 | else if (w->play.position > 1.0) |
| 124 | w->play.position = 1.0; |
| 125 | |
| 126 | - emotion_object_position_set(w->emotion, w->play.position); |
| 127 | + emotion_object_position_set(w->emotion, w->play.position * w->play.length); |
| 128 | ecore_event_add(ENJOY_EVENT_POSITION_CHANGE, NULL, NULL, NULL); |
| 129 | } |
| 130 | |
| 131 | -- |
| 132 | 1.8.5.2 |
| 133 | |