Efl.Player: Add setter of playback_progress
authorJunsuChoi <jsuya.choi@samsung.com>
Tue, 31 Dec 2019 14:53:10 +0000 (09:53 -0500)
committerJunsuChoi <jsuya.choi@samsung.com>
Mon, 6 Jan 2020 00:34:29 +0000 (09:34 +0900)
Summary:
The setter of Efl.Player.playback_progress is implemented in each class below.
Efl.Ui.Animation_View
Efl.Ui.Image
Efl.Ui.Image_Zoomable
Efl.Canvas.Video

ref T8476
Depends on D10915

Test Plan: N/A

Reviewers: Hermet, bu5hm4n, kimcinoo, Jaehyun_Cho, segfaultxavi, zmike

Reviewed By: zmike

Subscribers: zmike, cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8476

Differential Revision: https://phab.enlightenment.org/D10931

12 files changed:
src/bin/elementary/test_efl_gfx_vg_value_provider.c
src/bin/elementary/test_efl_ui_animation_view.c
src/lib/efl/interfaces/efl_player.eo
src/lib/elementary/efl_ui_animation_view.c
src/lib/elementary/efl_ui_animation_view.eo
src/lib/elementary/efl_ui_animation_view_eo.legacy.c
src/lib/elementary/efl_ui_image.c
src/lib/elementary/efl_ui_image.eo
src/lib/elementary/efl_ui_image_zoomable.c
src/lib/elementary/efl_ui_image_zoomable.eo
src/lib/emotion/efl_canvas_video.eo
src/lib/emotion/emotion_smart.c

index e7a1520..22a55d5 100644 (file)
@@ -241,7 +241,7 @@ static void
 _slider_changed_cb(void *data, const Efl_Event *ev)
 {
    Evas_Object *anim_view = data;
-   efl_ui_animation_view_progress_set(anim_view, efl_ui_range_value_get(ev->object));
+   efl_player_playback_progress_set(anim_view, efl_ui_range_value_get(ev->object));
 }
 
 static void
index 912aa71..fe828a7 100644 (file)
@@ -133,7 +133,7 @@ static void
 _slider_changed_cb(void *data, const Efl_Event *ev)
 {
    Evas_Object *anim_view = data;
-   efl_ui_animation_view_progress_set(anim_view, efl_ui_range_value_get(ev->object));
+   efl_player_playback_progress_set(anim_view, efl_ui_range_value_get(ev->object));
 }
 
 static void
index afeb7c2..434482a 100644 (file)
@@ -67,9 +67,11 @@ interface Efl.Player
         @property playback_progress {
            [[How much of the file has been played.
 
-             This function gets the progress in playing the file, the
-             return value is in the [0, 1] range.
+             This function sets or gets the progress in playing the file, the
+             value is in the [0, 1] range.
            ]]
+           set {
+           }
            get {
            }
            values {
index b51ead6..bc9beb8 100644 (file)
@@ -509,30 +509,9 @@ _playing_stop(Eo* obj, Efl_Ui_Animation_View_Data *pd)
 }
 
 EOLIAN static void
-_efl_ui_animation_view_progress_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, double progress)
-{
-   if (progress < 0) progress = 0;
-   else if (progress > 1) progress = 1;
-   if (pd->progress == progress) return;
-
-   pd->progress = progress;
-
-   if (pd->frame_cnt > 0)
-     evas_object_vg_animated_frame_set(pd->vg, (int) ((pd->frame_cnt - 1) * progress));
-
-   if (pd->transit)
-     {
-        if (pd->playing_reverse)
-          elm_transit_progress_value_set(pd->transit, 1 - progress);
-        else
-          elm_transit_progress_value_set(pd->transit, progress);
-     }
-}
-
-EOLIAN static void
 _efl_ui_animation_view_frame_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, int frame_num)
 {
-   efl_ui_animation_view_progress_set(obj, (double) frame_num / (double) (evas_object_vg_animated_frame_count_get(pd->vg) - 1));
+   efl_player_playback_progress_set(obj, (double) frame_num / (double) (evas_object_vg_animated_frame_count_get(pd->vg) - 1));
 }
 
 EOLIAN static int
@@ -768,7 +747,7 @@ _efl_ui_animation_view_efl_player_playback_position_set(Eo *obj, Efl_Ui_Animatio
    EINA_SAFETY_ON_TRUE_RETURN(sec < 0);
    EINA_SAFETY_ON_TRUE_RETURN(sec > pd->frame_duration);
 
-   efl_ui_animation_view_progress_set(obj, pd->frame_duration != 0 ? sec / pd->frame_duration : 0);
+   efl_player_playback_progress_set(obj, pd->frame_duration != 0 ? sec / pd->frame_duration : 0);
 }
 
 EOLIAN static double
@@ -784,6 +763,27 @@ _efl_ui_animation_view_efl_player_playback_progress_get(const Eo *obj EINA_UNUSE
 }
 
 EOLIAN static void
+_efl_ui_animation_view_efl_player_playback_progress_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, double progress)
+{
+   if (progress < 0) progress = 0;
+   else if (progress > 1) progress = 1;
+   if (pd->progress == progress) return;
+
+   pd->progress = progress;
+
+   if (pd->frame_cnt > 0)
+     evas_object_vg_animated_frame_set(pd->vg, (int) ((pd->frame_cnt - 1) * progress));
+
+   if (pd->transit)
+     {
+        if (pd->playing_reverse)
+          elm_transit_progress_value_set(pd->transit, 1 - progress);
+        else
+          elm_transit_progress_value_set(pd->transit, progress);
+     }
+}
+
+EOLIAN static void
 _efl_ui_animation_view_efl_player_playback_speed_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, double speed)
 {
    // pd->playback_direction_changed is used only during playback.
index 1d7d0c2..c14b927 100644 (file)
@@ -75,20 +75,6 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
             frame_duration: double; [[duration time in the seconds]]
          }
       }
-      @property progress {
-         [[Set current progress position of animation view object.
-
-           When you required to jump on a certain frame instantly,
-           you can change current position by using this API.
-
-           Warning: The range of progress is 0 ~ 1.
-         ]]
-         set {
-         }
-         values {
-            progress: double; [[Progress position. Value must be 0 ~ 1.]]
-         }
-      }
       @property frame {
          [[Number of current frame.
 
@@ -224,7 +210,7 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
       Efl.Player.playing { set; get; }
       Efl.Player.paused { set; get; }
       Efl.Player.playback_position { set; get; }
-      Efl.Player.playback_progress { get; }
+      Efl.Player.playback_progress { get; set; }
       Efl.Player.playback_speed { set; get; }
    }
    events {
index e213ebb..b109e0e 100644 (file)
@@ -46,7 +46,7 @@ elm_animation_view_duration_time_get(const Efl_Ui_Animation_View *obj)
 EAPI void
 elm_animation_view_progress_set(Efl_Ui_Animation_View *obj, double progress)
 {
-   efl_ui_animation_view_progress_set(obj, progress);
+   efl_player_playback_progress_set(obj, progress);
 }
 
 EAPI double
index 5ea021e..18a2833 100644 (file)
@@ -1769,7 +1769,7 @@ _efl_ui_image_animated_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool an
    if (anim)
      {
         sd->frame_count = evas_object_image_animated_frame_count_get(sd->img);
-        sd->cur_frame = 1;
+        sd->cur_frame = 0;
         sd->frame_duration =
           evas_object_image_animated_frame_duration_get
             (sd->img, sd->cur_frame, 0);
@@ -1875,11 +1875,23 @@ _efl_ui_image_efl_player_playback_progress_get(const Eo *obj EINA_UNUSED, Efl_Ui
 {
    if (sd->edje)
      efl_player_playback_progress_get(sd->img);
-   else if ((sd->frame_count > 0) && (sd->frame_duration > 0.0))
-     return (sd->cur_frame * sd->frame_duration) / sd->frame_count;
+   else if (sd->frame_count > 1)
+     return sd->cur_frame / (sd->frame_count - 1);
    return 0.0;
 }
 
+EOLIAN static void
+_efl_ui_image_efl_player_playback_progress_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, double progress)
+{
+   EINA_SAFETY_ON_TRUE_RETURN(progress > 1 || progress < 0);
+   if (sd->edje)
+     efl_player_playback_progress_set(sd->img, progress);
+   else if (sd->frame_count > 1)
+     sd->cur_frame = lround(progress * (sd->frame_count - 1));
+   else
+     sd->cur_frame = 0;
+}
+
 static Eina_Bool
 _efl_ui_image_animated_paused_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool paused)
 {
index 207a264..0cabaa0 100644 (file)
@@ -103,7 +103,7 @@ class Efl.Ui.Image extends Efl.Ui.Widget implements Efl.Input.Clickable, Efl.Ui.
       Efl.Player.playing { get; set; }
       Efl.Player.paused { get; set; }
       Efl.Player.playback_position { get; set; }
-      Efl.Player.playback_progress { get; }
+      Efl.Player.playback_progress { get; set; }
       Efl.Player.playback_speed { get; set; }
       Efl.Layout.Signal.signal_emit;
       Efl.Layout.Signal.message_send;
index 3484929..06a1791 100644 (file)
@@ -3071,7 +3071,7 @@ _efl_ui_image_zoomable_animated_set_internal(Eo *obj EINA_UNUSED, Efl_Ui_Image_Z
    if (anim)
      {
         sd->frame_count = evas_object_image_animated_frame_count_get(sd->img);
-        sd->cur_frame = 1;
+        sd->cur_frame = 0;
         sd->frame_duration =
           evas_object_image_animated_frame_duration_get
             (sd->img, sd->cur_frame, 0);
@@ -3191,12 +3191,27 @@ _efl_ui_image_zoomable_efl_player_playback_progress_get(const Eo *obj EINA_UNUSE
 {
    if (sd->edje)
      efl_player_playback_progress_get(sd->edje);
-   else if ((sd->frame_count > 0) && (sd->frame_duration > 0.0))
-     return (sd->cur_frame * sd->frame_duration) / sd->frame_count;
+   else if (sd->frame_count > 1)
+     return sd->cur_frame / (sd->frame_count - 1);
    return 0.0;
 }
 
 EOLIAN static void
+_efl_ui_image_zoomable_efl_player_playback_progress_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd, double progress)
+{
+   EINA_SAFETY_ON_TRUE_RETURN(progress > 1 || progress < 0);
+   if (sd->edje)
+     {
+        efl_player_playback_progress_set(sd->img, progress);
+     }
+   else if (sd->frame_count > 1)
+     sd->cur_frame = lround(progress * (sd->frame_count - 1));
+   else
+     sd->cur_frame = 0;
+}
+
+
+EOLIAN static void
 _efl_ui_image_zoomable_class_constructor(Efl_Class *klass EINA_UNUSED)
 {
    PHOTO_FILE_LOAD_ERROR_GENERIC = eina_error_msg_static_register("Generic load error");
index 5b097e1..4887128 100644 (file)
@@ -50,7 +50,7 @@ class Efl.Ui.Image_Zoomable extends Efl.Ui.Image implements Efl.Ui.Zoom
       Efl.Player.playing { get; set; }
       Efl.Player.paused { get; set; }
       Efl.Player.playback_position { get; set; }
-      Efl.Player.playback_progress { get; }
+      Efl.Player.playback_progress { get; set; }
       Efl.Player.playback_speed { get; set; }
       Efl.Ui.Zoom.zoom_animation { set; get; }
       Efl.Ui.Zoom.zoom_level { set; get; }
index 162e0fc..0f2ffa7 100644 (file)
@@ -60,7 +60,7 @@ class @beta Efl.Canvas.Video extends Efl.Canvas.Group
         Efl.Player.playing { get; set; }
         Efl.Player.paused { get; set; }
         Efl.Player.playback_position { get; set; }
-        Efl.Player.playback_progress { get; }
+        Efl.Player.playback_progress { get; set; }
         Efl.Audio_Control.volume { get; set; }
         Efl.Audio_Control.mute { get; set; }
         Efl.Playable.length { get; }
index a642386..9f723e5 100644 (file)
@@ -1217,6 +1217,13 @@ _efl_canvas_video_efl_player_playback_progress_get(const Eo *obj EINA_UNUSED, Ef
    return sd->progress.stat;
 }
 
+EOLIAN static void
+_efl_canvas_video_efl_player_playback_progress_set(Eo *obj, Efl_Canvas_Video_Data *sd EINA_UNUSED, double progress)
+{
+   const char *info = emotion_object_progress_info_get((const Evas_Object*)obj);
+   _emotion_progress_set(obj, (char*)info, progress);
+}
+
 EOLIAN static double
 _efl_canvas_video_efl_playable_length_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
 {