summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2020-01-15 09:24:07 -0500
committerMike Blumenkrantz <zmike@samsung.com>2020-01-15 09:24:07 -0500
commita63306a9087893bb894329306fe4149394db832f (patch)
tree6f2f2bec1d40755d3228e5839e57b496e2825a03
parent2f7eef14d8bd58a93577c1a0bf8d467c2f0aaca4 (diff)
efl/player: merge in and rework events from vg_animation
Summary: this adds comprehensive events for the player interface which can be used to provide details about the state of the playback ref T8476 Depends on D11098 Reviewers: jsuya, bu5hm4n Reviewed By: jsuya Subscribers: jsuya, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8476 Differential Revision: https://phab.enlightenment.org/D11080
-rw-r--r--src/lib/efl/interfaces/efl_player.eo8
-rw-r--r--src/lib/elementary/efl_ui_vg_animation.c71
-rw-r--r--src/lib/elementary/efl_ui_vg_animation.eo9
3 files changed, 66 insertions, 22 deletions
diff --git a/src/lib/efl/interfaces/efl_player.eo b/src/lib/efl/interfaces/efl_player.eo
index 434482ab63..90717ff7a3 100644
--- a/src/lib/efl/interfaces/efl_player.eo
+++ b/src/lib/efl/interfaces/efl_player.eo
@@ -94,4 +94,12 @@ interface Efl.Player
94 } 94 }
95 } 95 }
96 } 96 }
97 events {
98 playing,changed: bool; [[Called when the playing state has changed. The event value reflects the current state. @since 1.24]]
99 paused,changed: bool; [[Called when the paused state has changed. The event value reflects the current state. @since 1.24]]
100 playback_progress,changed: double; [[Called when the playback_progress state has changed. The event value reflects the current state. @since 1.24]]
101 playback_position,changed: double; [[Called when the playback_position state has changed. The event value reflects the current state. @since 1.24]]
102 playback,repeated: int; [[Called when the player has begun to repeat its data stream. The event value is the current number of repeats. @since 1.24]]
103 playback,finished: void; [[Called when the player has completed playing its data stream. @since 1.24]]
104 }
97} 105}
diff --git a/src/lib/elementary/efl_ui_vg_animation.c b/src/lib/elementary/efl_ui_vg_animation.c
index 210c5ec29c..503ea856e6 100644
--- a/src/lib/elementary/efl_ui_vg_animation.c
+++ b/src/lib/elementary/efl_ui_vg_animation.c
@@ -64,12 +64,16 @@ _size_hint_event_cb(void *data, const Efl_Event *event)
64static void 64static void
65_transit_go_facade(Eo* obj, Efl_Ui_Vg_Animation_Data *pd) 65_transit_go_facade(Eo* obj, Efl_Ui_Vg_Animation_Data *pd)
66{ 66{
67 Eina_Bool playing = EINA_TRUE;
67 pd->repeat_times = 0; 68 pd->repeat_times = 0;
68 if (pd->playing_reverse) 69 if (pd->playing_reverse)
69 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS; 70 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS;
70 else 71 else
71 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING; 72 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING;
72 evas_object_smart_callback_call(obj, SIG_PLAY_START, NULL); 73 if (elm_widget_is_legacy(obj))
74 evas_object_smart_callback_call(obj, SIG_PLAY_START, NULL);
75 else
76 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYING_CHANGED, &playing);
73 if (pd->transit) elm_transit_go(pd->transit);} 77 if (pd->transit) elm_transit_go(pd->transit);}
74 78
75static Eina_Bool 79static Eina_Bool
@@ -106,25 +110,33 @@ _autoplay(Eo *obj, Efl_Ui_Vg_Animation_Data *pd, Eina_Bool vis)
106 { 110 {
107 if (pd->state == EFL_UI_VG_ANIMATION_STATE_PAUSED && pd->autoplay_pause) 111 if (pd->state == EFL_UI_VG_ANIMATION_STATE_PAUSED && pd->autoplay_pause)
108 { 112 {
113 Eina_Bool paused = EINA_FALSE;
109 elm_transit_paused_set(pd->transit, EINA_FALSE); 114 elm_transit_paused_set(pd->transit, EINA_FALSE);
110 if (pd->playing_reverse) 115 if (pd->playing_reverse)
111 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS; 116 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS;
112 else 117 else
113 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING; 118 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING;
114 pd->autoplay_pause = EINA_FALSE; 119 pd->autoplay_pause = EINA_FALSE;
115 evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL); 120 if (elm_widget_is_legacy(obj))
121 evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL);
122 else
123 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
116 } 124 }
117 } 125 }
118 //Pause Animation 126 //Pause Animation
119 else 127 else
120 { 128 {
129 Eina_Bool paused = EINA_TRUE;
121 if ((pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING) || 130 if ((pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING) ||
122 (pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS)) 131 (pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS))
123 { 132 {
124 elm_transit_paused_set(pd->transit, EINA_TRUE); 133 elm_transit_paused_set(pd->transit, EINA_TRUE);
125 pd->state = EFL_UI_VG_ANIMATION_STATE_PAUSED; 134 pd->state = EFL_UI_VG_ANIMATION_STATE_PAUSED;
126 pd->autoplay_pause = EINA_TRUE; 135 pd->autoplay_pause = EINA_TRUE;
127 evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL); 136 if (elm_widget_is_legacy(obj))
137 evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
138 else
139 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
128 } 140 }
129 } 141 }
130} 142}
@@ -138,7 +150,12 @@ _transit_del_cb(Elm_Transit_Effect *effect, Elm_Transit *transit)
138 150
139 if ((pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING && pd->progress == 1) || 151 if ((pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING && pd->progress == 1) ||
140 (pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS && pd->progress == 0)) 152 (pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS && pd->progress == 0))
141 evas_object_smart_callback_call(obj, SIG_PLAY_DONE, NULL); 153 {
154 if (elm_widget_is_legacy(obj))
155 evas_object_smart_callback_call(obj, SIG_PLAY_DONE, NULL);
156 else
157 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYBACK_FINISHED, NULL);
158 }
142 159
143 if (pd->transit != transit) return; 160 if (pd->transit != transit) return;
144 161
@@ -149,7 +166,11 @@ _transit_del_cb(Elm_Transit_Effect *effect, Elm_Transit *transit)
149 166
150 if (prev_state != EFL_UI_VG_ANIMATION_STATE_STOPPED) 167 if (prev_state != EFL_UI_VG_ANIMATION_STATE_STOPPED)
151 { 168 {
152 evas_object_smart_callback_call(obj, SIG_PLAY_STOP, NULL); 169 Eina_Bool playing = EINA_FALSE;
170 if (elm_widget_is_legacy(obj))
171 evas_object_smart_callback_call(obj, SIG_PLAY_STOP, NULL);
172 else
173 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYING_CHANGED, &playing);
153 pd->progress = 0; 174 pd->progress = 0;
154 } 175 }
155} 176}
@@ -201,15 +222,25 @@ _transit_cb(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
201 int repeat_times = elm_transit_current_repeat_times_get(pd->transit); 222 int repeat_times = elm_transit_current_repeat_times_get(pd->transit);
202 if (pd->repeat_times != repeat_times) 223 if (pd->repeat_times != repeat_times)
203 { 224 {
204 evas_object_smart_callback_call(obj, SIG_PLAY_REPEAT, NULL); 225 if (elm_widget_is_legacy(obj))
226 evas_object_smart_callback_call(obj, SIG_PLAY_REPEAT, NULL);
227 else
228 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYBACK_REPEATED, &repeat_times);
205 pd->repeat_times = repeat_times; 229 pd->repeat_times = repeat_times;
206 } 230 }
207 } 231 }
208 232
209 //transit_cb is always called with a progress value 0 ~ 1. 233 //transit_cb is always called with a progress value 0 ~ 1.
210 //SIG_PLAY_UPDATE callback is called only when there is a real change. 234 //SIG_PLAY_UPDATE callback is called only when there is a real change.
211 if (update_frame != current_frame) 235 if (update_frame == current_frame) return;
236 if (elm_widget_is_legacy(obj))
212 evas_object_smart_callback_call(obj, SIG_PLAY_UPDATE, NULL); 237 evas_object_smart_callback_call(obj, SIG_PLAY_UPDATE, NULL);
238 else
239 {
240 double position = pd->frame_duration * pd->progress;
241 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYBACK_POSITION_CHANGED, &position);
242 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYBACK_PROGRESS_CHANGED, &pd->progress);
243 }
213} 244}
214 245
215EOLIAN static void 246EOLIAN static void
@@ -354,10 +385,14 @@ _efl_ui_vg_animation_efl_file_load(Eo *obj, Efl_Ui_Vg_Animation_Data *pd)
354 385
355 if (!_visible_check(obj)) 386 if (!_visible_check(obj))
356 { 387 {
388 Eina_Bool paused = EINA_TRUE;
357 elm_transit_paused_set(pd->transit, EINA_TRUE); 389 elm_transit_paused_set(pd->transit, EINA_TRUE);
358 pd->state = EFL_UI_VG_ANIMATION_STATE_PAUSED; 390 pd->state = EFL_UI_VG_ANIMATION_STATE_PAUSED;
359 pd->autoplay_pause = EINA_TRUE; 391 pd->autoplay_pause = EINA_TRUE;
360 evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL); 392 if (elm_widget_is_legacy(obj))
393 evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
394 else
395 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
361 } 396 }
362 } 397 }
363 return 0; 398 return 0;
@@ -492,6 +527,7 @@ Eina_Bool _efl_ui_vg_animation_playing_sector(Eo *obj, Efl_Ui_Vg_Animation_Data
492Eina_Bool 527Eina_Bool
493_playing_stop(Eo* obj, Efl_Ui_Vg_Animation_Data *pd) 528_playing_stop(Eo* obj, Efl_Ui_Vg_Animation_Data *pd)
494{ 529{
530 Eina_Bool playing = EINA_FALSE;
495 if (!pd->transit) return EINA_FALSE; 531 if (!pd->transit) return EINA_FALSE;
496 532
497 if ((pd->state == EFL_UI_VG_ANIMATION_STATE_NOT_READY) || 533 if ((pd->state == EFL_UI_VG_ANIMATION_STATE_NOT_READY) ||
@@ -501,7 +537,11 @@ _playing_stop(Eo* obj, Efl_Ui_Vg_Animation_Data *pd)
501 evas_object_vg_animated_frame_set(pd->vg, 0); 537 evas_object_vg_animated_frame_set(pd->vg, 0);
502 pd->progress = 0; 538 pd->progress = 0;
503 pd->state = EFL_UI_VG_ANIMATION_STATE_STOPPED; 539 pd->state = EFL_UI_VG_ANIMATION_STATE_STOPPED;
504 evas_object_smart_callback_call(obj, SIG_PLAY_STOP, NULL); 540 if (elm_widget_is_legacy(obj))
541 evas_object_smart_callback_call(obj, SIG_PLAY_STOP, NULL);
542 else
543 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYING_CHANGED, &playing);
544
505 elm_transit_del(pd->transit); 545 elm_transit_del(pd->transit);
506 return EINA_TRUE; 546 return EINA_TRUE;
507} 547}
@@ -696,7 +736,7 @@ _efl_ui_vg_animation_efl_player_playing_get(const Eo *obj EINA_UNUSED, Efl_Ui_Vg
696EOLIAN static Eina_Bool 736EOLIAN static Eina_Bool
697_efl_ui_vg_animation_efl_player_paused_set(Eo *obj EINA_UNUSED, Efl_Ui_Vg_Animation_Data *pd, Eina_Bool paused) 737_efl_ui_vg_animation_efl_player_paused_set(Eo *obj EINA_UNUSED, Efl_Ui_Vg_Animation_Data *pd, Eina_Bool paused)
698{ 738{
699 739 paused = !!paused;
700 if (paused) 740 if (paused)
701 { 741 {
702 if ((pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING) || 742 if ((pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING) ||
@@ -705,7 +745,10 @@ _efl_ui_vg_animation_efl_player_paused_set(Eo *obj EINA_UNUSED, Efl_Ui_Vg_Animat
705 elm_transit_paused_set(pd->transit, paused); 745 elm_transit_paused_set(pd->transit, paused);
706 pd->state = EFL_UI_VG_ANIMATION_STATE_PAUSED; 746 pd->state = EFL_UI_VG_ANIMATION_STATE_PAUSED;
707 pd->autoplay_pause = EINA_FALSE; 747 pd->autoplay_pause = EINA_FALSE;
708 evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL); 748 if (elm_widget_is_legacy(obj))
749 evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
750 else
751 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
709 } 752 }
710 } 753 }
711 else 754 else
@@ -718,8 +761,10 @@ _efl_ui_vg_animation_efl_player_paused_set(Eo *obj EINA_UNUSED, Efl_Ui_Vg_Animat
718 else 761 else
719 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING; 762 pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING;
720 pd->autoplay_pause = EINA_FALSE; 763 pd->autoplay_pause = EINA_FALSE;
721 764 if (elm_widget_is_legacy(obj))
722 evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL); 765 evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL);
766 else
767 efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
723 } 768 }
724 } 769 }
725 return EINA_TRUE; 770 return EINA_TRUE;
diff --git a/src/lib/elementary/efl_ui_vg_animation.eo b/src/lib/elementary/efl_ui_vg_animation.eo
index 69971f95c2..12dcfe96c6 100644
--- a/src/lib/elementary/efl_ui_vg_animation.eo
+++ b/src/lib/elementary/efl_ui_vg_animation.eo
@@ -204,13 +204,4 @@ class @beta Efl.Ui.Vg_Animation extends Efl.Ui.Widget implements Efl.Gfx.View, E
204 Efl.Playable.playable { get; } 204 Efl.Playable.playable { get; }
205 Efl.Playable.seekable { get; } 205 Efl.Playable.seekable { get; }
206 } 206 }
207 events {
208 play,start: void; [[Called when animation is just started]]
209 play,repeat: void; [[Called when animation is just repeated]]
210 play,done: void; [[Called when animation is just finished]]
211 play,pause: void; [[Called when animation is just paused]]
212 play,resume: void; [[Called when animation is just resumed]]
213 play,stop: void; [[Called when animation is just stopped]]
214 play,update: void; [[Called when animation is just updated]]
215 }
216} 207}