diff --git a/src/bin/elementary/test_efl_anim_alpha.c b/src/bin/elementary/test_efl_anim_alpha.c index 0a42b920eb..d75733f8c8 100644 --- a/src/bin/elementary/test_efl_anim_alpha.c +++ b/src/bin/elementary/test_efl_anim_alpha.c @@ -53,7 +53,7 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) } //Let Animation Object start animation - efl_player_start(ad->anim_obj); + efl_player_playing_set(ad->anim_obj, EINA_TRUE); } static void diff --git a/src/bin/elementary/test_efl_anim_group_parallel.c b/src/bin/elementary/test_efl_anim_group_parallel.c index b7128883d0..6283e2262f 100644 --- a/src/bin/elementary/test_efl_anim_group_parallel.c +++ b/src/bin/elementary/test_efl_anim_group_parallel.c @@ -54,7 +54,7 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) } //Let Animation Object start animation - efl_player_start(ad->anim_obj); + efl_player_playing_set(ad->anim_obj, EINA_TRUE); } static void diff --git a/src/bin/elementary/test_efl_anim_group_sequential.c b/src/bin/elementary/test_efl_anim_group_sequential.c index 655c37c571..3488149af0 100644 --- a/src/bin/elementary/test_efl_anim_group_sequential.c +++ b/src/bin/elementary/test_efl_anim_group_sequential.c @@ -53,7 +53,7 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) } //Let Animation Object start animation - efl_player_start(ad->anim_obj); + efl_player_playing_set(ad->anim_obj, EINA_TRUE); } static void diff --git a/src/bin/elementary/test_efl_anim_interpolator.c b/src/bin/elementary/test_efl_anim_interpolator.c index ca2e2446f9..be177d7ed4 100644 --- a/src/bin/elementary/test_efl_anim_interpolator.c +++ b/src/bin/elementary/test_efl_anim_interpolator.c @@ -113,7 +113,7 @@ _anim_start(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) int index = (uintptr_t)evas_object_data_get(obj, "index"); //Let Animation Object start animation - efl_player_start(ad->anim_obj[index]); + efl_player_playing_set(ad->anim_obj[index], EINA_TRUE); elm_object_disabled_set(obj, EINA_TRUE); elm_object_disabled_set(ad->start_all_btn, EINA_TRUE); @@ -128,7 +128,7 @@ _anim_start_all(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) for (i = 0; i < INTERP_NUM; i++) { //Let Animation Object start animation - efl_player_start(ad->anim_obj[i]); + efl_player_playing_set(ad->anim_obj[i], EINA_TRUE); elm_object_disabled_set(ad->btn[i], EINA_TRUE); } diff --git a/src/bin/elementary/test_efl_anim_pause.c b/src/bin/elementary/test_efl_anim_pause.c index c73b7bcf6c..748599bbfa 100644 --- a/src/bin/elementary/test_efl_anim_pause.c +++ b/src/bin/elementary/test_efl_anim_pause.c @@ -69,7 +69,7 @@ _start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED efl_text_set(obj, "Start Alpha Animation from 0.0 to 1.0"); } //Let Animation Object start animation - efl_player_start(ad->anim_obj); + efl_player_playing_set(ad->anim_obj, EINA_TRUE); } static void diff --git a/src/bin/elementary/test_efl_anim_repeat.c b/src/bin/elementary/test_efl_anim_repeat.c index 50df2035c8..d853f9c32b 100644 --- a/src/bin/elementary/test_efl_anim_repeat.c +++ b/src/bin/elementary/test_efl_anim_repeat.c @@ -106,7 +106,7 @@ _start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED } //Let Animation Object start animation - efl_player_start(ad->anim_obj); + efl_player_playing_set(ad->anim_obj, EINA_TRUE); } static void diff --git a/src/bin/elementary/test_efl_anim_rotate.c b/src/bin/elementary/test_efl_anim_rotate.c index 454ca0f262..10df8caf89 100644 --- a/src/bin/elementary/test_efl_anim_rotate.c +++ b/src/bin/elementary/test_efl_anim_rotate.c @@ -53,7 +53,7 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) } //Let Animation Object start animation - efl_player_start(ad->anim_obj); + efl_player_playing_set(ad->anim_obj, EINA_TRUE); } static void diff --git a/src/bin/elementary/test_efl_anim_scale.c b/src/bin/elementary/test_efl_anim_scale.c index bd380bd145..5e5f9abc58 100644 --- a/src/bin/elementary/test_efl_anim_scale.c +++ b/src/bin/elementary/test_efl_anim_scale.c @@ -53,7 +53,7 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) } //Let Animation Object start animation - efl_player_start(ad->anim_obj); + efl_player_playing_set(ad->anim_obj, EINA_TRUE); } static void diff --git a/src/bin/elementary/test_efl_anim_start_delay.c b/src/bin/elementary/test_efl_anim_start_delay.c index c94b515b62..e3c7b255b5 100644 --- a/src/bin/elementary/test_efl_anim_start_delay.c +++ b/src/bin/elementary/test_efl_anim_start_delay.c @@ -68,7 +68,7 @@ _start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED } //Let Animation Object start animation - efl_player_start(ad->anim_obj); + efl_player_playing_set(ad->anim_obj, EINA_TRUE); } static void diff --git a/src/bin/elementary/test_efl_anim_translate.c b/src/bin/elementary/test_efl_anim_translate.c index a562d17d65..9f30cc3b63 100644 --- a/src/bin/elementary/test_efl_anim_translate.c +++ b/src/bin/elementary/test_efl_anim_translate.c @@ -53,7 +53,7 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) } //Let Animation Object start animation - efl_player_start(ad->anim_obj); + efl_player_playing_set(ad->anim_obj, EINA_TRUE); } static void diff --git a/src/examples/evas/evas-vg-json.c b/src/examples/evas/evas-vg-json.c index 7447373711..248dcb1054 100644 --- a/src/examples/evas/evas-vg-json.c +++ b/src/examples/evas/evas-vg-json.c @@ -124,7 +124,7 @@ main(void) Eo *player = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, evas); efl_animation_player_animation_set(player, anim); efl_event_callback_add(player, EFL_ANIMATION_PLAYER_EVENT_RUNNING, running_cb, NULL); - efl_player_start(player); + efl_player_playing_set(player, EINA_TRUE); ecore_main_loop_begin(); ecore_evas_shutdown(); diff --git a/src/lib/efl/interfaces/efl_player.eo b/src/lib/efl/interfaces/efl_player.eo index 2581bb5494..619fcd5ea8 100644 --- a/src/lib/efl/interfaces/efl_player.eo +++ b/src/lib/efl/interfaces/efl_player.eo @@ -3,11 +3,25 @@ interface @beta Efl.Player [[Efl media player interface]] c_prefix: efl_player; methods { - start { - [[Start a playing playable object.]] - } - stop { - [[Stop playable object.]] + @property playing { + [[Playback state of the media file. + + This property sets the playback state of the object. Re-setting the current + playback state has no effect. + + If set to $false, the object's @.progress property is reset to $0.0. Applying + the $false playing state also has the same effect as the player object reaching + the end of its playback, which may invoke additional behavior based on a class's + implementation. + ]] + set { + return: bool(false); [[If $true, the property change has succeeded.]] + } + get { + } + values { + playing: bool; [[$true if playing, $false otherwise.]] + } } @property play { [[Playback state of the media file. diff --git a/src/lib/elementary/efl_ui_spotlight_manager_stack.c b/src/lib/elementary/efl_ui_spotlight_manager_stack.c index 501df211b3..9d920346f9 100644 --- a/src/lib/elementary/efl_ui_spotlight_manager_stack.c +++ b/src/lib/elementary/efl_ui_spotlight_manager_stack.c @@ -176,9 +176,9 @@ _efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_content_del(Eo *obj EIN static void _setup_anim(Efl_Animation_Player *player, Efl_Gfx_Entity *entity) { - efl_player_stop(player); + efl_player_playing_set(player, EINA_FALSE); efl_animation_player_target_set(player, entity); - efl_player_start(player); + efl_player_playing_set(player, EINA_TRUE); } static Eina_Bool @@ -256,7 +256,7 @@ _reset_player(Efl_Animation_Player *player, Eina_Bool vis) Efl_Gfx_Entity *obj; obj = efl_animation_player_target_get(player); - efl_player_stop(player); + efl_player_playing_set(player, EINA_FALSE); efl_animation_player_target_set(player, NULL); efl_gfx_entity_visible_set(obj, vis); } diff --git a/src/lib/elementary/efl_ui_video.c b/src/lib/elementary/efl_ui_video.c index 1e26bba4ce..e5bf59b4f0 100644 --- a/src/lib/elementary/efl_ui_video.c +++ b/src/lib/elementary/efl_ui_video.c @@ -327,13 +327,6 @@ _efl_ui_video_emotion_get(const Eo *obj EINA_UNUSED, Efl_Ui_Video_Data *sd) return sd->emotion; } -EOLIAN static void -_efl_ui_video_efl_player_start(Eo *obj, Efl_Ui_Video_Data *sd EINA_UNUSED) -{ - efl_player_playback_position_set(obj, 0.0); - efl_player_play_set(obj, EINA_TRUE); -} - EOLIAN static void _efl_ui_video_efl_player_play_set(Eo *obj, Efl_Ui_Video_Data *sd, Eina_Bool play) { @@ -367,14 +360,25 @@ _efl_ui_video_efl_player_play_set(Eo *obj, Efl_Ui_Video_Data *sd, Eina_Bool play /* FIXME: stop should go into hibernate state directly. */ -EOLIAN static void -_efl_ui_video_efl_player_stop(Eo *obj, Efl_Ui_Video_Data *sd) +EOLIAN static Eina_Bool +_efl_ui_video_efl_player_playing_set(Eo *obj, Efl_Ui_Video_Data *sd, Eina_Bool playing) { - if (!emotion_object_play_get(sd->emotion) && sd->stop) return; - + playing = !!playing; + if (playing && emotion_object_play_get(sd->emotion)) return EINA_TRUE; + if ((!playing) && sd->stop) return EINA_TRUE; ELM_SAFE_FREE(sd->timer, ecore_timer_del); + sd->stop = !playing; + if (playing) + { + emotion_object_play_set(sd->emotion, EINA_TRUE); - sd->stop = EINA_TRUE; + if(elm_widget_is_legacy(obj)) + elm_layout_signal_emit(obj, "elm,video,play", "elm"); + else + elm_layout_signal_emit(obj, "efl,video,play", "efl"); + return EINA_TRUE; + } + efl_player_playback_position_set(obj, 0.0); emotion_object_play_set(sd->emotion, EINA_FALSE); if(elm_widget_is_legacy(obj)) @@ -383,6 +387,13 @@ _efl_ui_video_efl_player_stop(Eo *obj, Efl_Ui_Video_Data *sd) elm_layout_signal_emit(obj, "efl,video,stop", "efl"); emotion_object_suspend_set(sd->emotion, EMOTION_HIBERNATE); + return EINA_TRUE; +} + +EOLIAN static Eina_Bool +_efl_ui_video_efl_player_playing_get(const Eo *obj EINA_UNUSED, Efl_Ui_Video_Data *sd) +{ + return emotion_object_play_get(sd->emotion); } EOLIAN static Eina_Bool @@ -534,7 +545,7 @@ elm_video_play(Evas_Object *obj) EAPI void elm_video_stop(Evas_Object *obj) { - efl_player_stop(obj); + efl_player_playing_set(obj, EINA_FALSE); } EAPI void diff --git a/src/lib/elementary/efl_ui_video.eo b/src/lib/elementary/efl_ui_video.eo index 5fc841a3b3..77a550c68f 100644 --- a/src/lib/elementary/efl_ui_video.eo +++ b/src/lib/elementary/efl_ui_video.eo @@ -43,8 +43,7 @@ class @beta Efl.Ui.Video extends Efl.Ui.Layout_Base Efl.Canvas.Group.group_calculate; Efl.Ui.Widget.widget_input_event_handler; Efl.Access.Widget.Action.elm_actions { get; } - Efl.Player.start; - Efl.Player.stop; + Efl.Player.playing { get; set; } Efl.Player.play { get; set; } } } diff --git a/src/lib/evas/canvas/efl_canvas_animation_player.c b/src/lib/evas/canvas/efl_canvas_animation_player.c index ea4929789c..981ece8b80 100644 --- a/src/lib/evas/canvas/efl_canvas_animation_player.c +++ b/src/lib/evas/canvas/efl_canvas_animation_player.c @@ -61,7 +61,7 @@ _efl_canvas_animation_player_animation_set(Eo *eo_obj, if (pd->animation) { - efl_player_stop(eo_obj); + efl_player_playing_set(eo_obj, EINA_FALSE); efl_unref(pd->animation); } pd->animation = anim; @@ -147,7 +147,7 @@ _animator_cb(void *data) return ECORE_CALLBACK_RENEW; } - efl_player_stop(eo_obj); + efl_player_playing_set(eo_obj, EINA_FALSE); return ECORE_CALLBACK_CANCEL; } @@ -188,30 +188,6 @@ _start_delay_timer_cb(void *data) return ECORE_CALLBACK_CANCEL; } -EOLIAN static void -_efl_canvas_animation_player_efl_player_start(Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd) -{ - double start_delay; - EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim); - - if (!efl_playable_get(eo_obj)) return; - pd->is_play = EINA_TRUE; - //TODO: check this case is correct - if (pd->start_delay_timer) return; - - pd->progress = 0.0; - start_delay = efl_animation_start_delay_get(anim); - if (start_delay > 0.0) - { - pd->start_delay_timer = ecore_timer_add(start_delay, - _start_delay_timer_cb, eo_obj); - return; - } - - _start(eo_obj, pd); -} - static Eina_Bool _is_final_state(Efl_Canvas_Animation *anim, double progress) { @@ -240,12 +216,9 @@ _is_final_state(Efl_Canvas_Animation *anim, double progress) return EINA_FALSE; } -EOLIAN static void -_efl_canvas_animation_player_efl_player_stop(Eo *eo_obj, - Efl_Canvas_Animation_Player_Data *pd) +static void +_player_stop(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, Efl_Canvas_Animation *anim) { - EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim); - //Reset the state of the target to the initial state efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj)); @@ -281,6 +254,42 @@ _efl_canvas_animation_player_efl_player_stop(Eo *eo_obj, if (pd->auto_del) efl_del(eo_obj); } +EOLIAN static Eina_Bool +_efl_canvas_animation_player_efl_player_playing_set(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, Eina_Bool playing) +{ + double start_delay; + EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim); + + if (!efl_playable_get(eo_obj)) return EINA_FALSE; + if ((!playing) && (!pd->is_play)) return EINA_TRUE; + if ((playing) && (pd->is_play)) return EINA_TRUE; + pd->is_play = !!playing; + if (!playing) + { + _player_stop(eo_obj, pd, anim); + return EINA_TRUE; + } + //TODO: check this case is correct + if (pd->start_delay_timer) return EINA_TRUE; + + pd->progress = 0.0; + start_delay = efl_animation_start_delay_get(anim); + if (start_delay > 0.0) + { + pd->start_delay_timer = ecore_timer_add(start_delay, + _start_delay_timer_cb, eo_obj); + } + else + _start(eo_obj, pd); + return EINA_TRUE; +} + +EOLIAN static Eina_Bool +_efl_canvas_animation_player_efl_player_playing_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Player_Data *pd) +{ + return pd->is_play; +} + EOLIAN static void _efl_canvas_animation_player_efl_player_play_set(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, @@ -425,7 +434,7 @@ _efl_canvas_animation_player_efl_object_destructor(Eo *eo_obj, pd->animator = NULL; //Reset the state of the target to the initial state - efl_player_stop(eo_obj); + efl_player_playing_set(eo_obj, EINA_FALSE); efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL); } diff --git a/src/lib/evas/canvas/efl_canvas_animation_player.eo b/src/lib/evas/canvas/efl_canvas_animation_player.eo index 6e739b5c58..57e13f1035 100644 --- a/src/lib/evas/canvas/efl_canvas_animation_player.eo +++ b/src/lib/evas/canvas/efl_canvas_animation_player.eo @@ -35,8 +35,7 @@ class @beta Efl.Canvas.Animation_Player extends Efl.Object implements Efl.Player implements { Efl.Object.constructor; Efl.Object.destructor; - Efl.Player.start; - Efl.Player.stop; + Efl.Player.playing { get; set; } Efl.Player.play { get; set; } Efl.Playable.playable { get; } Efl.Player.playback_position { get; set; } diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index 95ee8a21d5..abd8a2d5e2 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -1870,7 +1870,7 @@ static void _show(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj) { if (obj->anim_player) - efl_player_stop(obj->anim_player); + efl_player_playing_set(obj->anim_player, EINA_FALSE); if (obj->is_smart && obj->smart.smart && obj->smart.smart->smart_class->show) { obj->smart.smart->smart_class->show(eo_obj); @@ -2583,7 +2583,7 @@ _efl_canvas_object_event_animation_cancel(Eo *eo_obj) Evas_Object_Protected_Data *obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj); if (obj) - efl_player_stop(obj->anim_player); + efl_player_playing_set(obj->anim_player, EINA_FALSE); } /* legacy */