efl/player: merge start+stop methods into 'playing' property
authorMike Blumenkrantz <zmike@samsung.com>
Tue, 24 Sep 2019 14:11:26 +0000 (10:11 -0400)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 25 Sep 2019 21:11:54 +0000 (06:11 +0900)
this has some overlap with the existing 'play' property which will
soon be renamed. the intent here is that there is a property for
controlling the 'playing' state and then another property for managing
'pausing' the play state

ref T7877

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10113

18 files changed:
src/bin/elementary/test_efl_anim_alpha.c
src/bin/elementary/test_efl_anim_group_parallel.c
src/bin/elementary/test_efl_anim_group_sequential.c
src/bin/elementary/test_efl_anim_interpolator.c
src/bin/elementary/test_efl_anim_pause.c
src/bin/elementary/test_efl_anim_repeat.c
src/bin/elementary/test_efl_anim_rotate.c
src/bin/elementary/test_efl_anim_scale.c
src/bin/elementary/test_efl_anim_start_delay.c
src/bin/elementary/test_efl_anim_translate.c
src/examples/evas/evas-vg-json.c
src/lib/efl/interfaces/efl_player.eo
src/lib/elementary/efl_ui_spotlight_manager_stack.c
src/lib/elementary/efl_ui_video.c
src/lib/elementary/efl_ui_video.eo
src/lib/evas/canvas/efl_canvas_animation_player.c
src/lib/evas/canvas/efl_canvas_animation_player.eo
src/lib/evas/canvas/evas_object_main.c

index 0a42b92..d75733f 100644 (file)
@@ -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
index b712888..6283e22 100644 (file)
@@ -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
index 655c37c..3488149 100644 (file)
@@ -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
index ca2e244..be177d7 100644 (file)
@@ -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);
      }
 
index c73b7bc..748599b 100644 (file)
@@ -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
index 50df203..d853f9c 100644 (file)
@@ -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
index 454ca0f..10df8ca 100644 (file)
@@ -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
index bd380bd..5e5f9ab 100644 (file)
@@ -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
index c94b515..e3c7b25 100644 (file)
@@ -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
index a562d17..9f30cc3 100644 (file)
@@ -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
index 7447373..248dcb1 100644 (file)
@@ -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();
index 2581bb5..619fcd5 100644 (file)
@@ -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.
index 501df21..9d92034 100644 (file)
@@ -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);
 }
index 1e26bba..e5bf59b 100644 (file)
@@ -328,13 +328,6 @@ _efl_ui_video_emotion_get(const Eo *obj EINA_UNUSED, Efl_Ui_Video_Data *sd)
 }
 
 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)
 {
    if (emotion_object_play_get(sd->emotion) == !!play) return;
@@ -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
index 5fc841a..77a550c 100644 (file)
@@ -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; }
    }
 }
index ea49297..981ece8 100644 (file)
@@ -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);
      }
index 6e739b5..57e13f1 100644 (file)
@@ -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; }
index 95ee8a2..abd8a2d 100644 (file)
@@ -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 */