efl/player: rename 'play' property to 'pause'

this is a bit of an overhaul wherein the existing 'play' mechanics are
all inverted. 'pause' is a state which stops playback but does not affect
the playback_position property.

this patch also includes implementations of Efl.Player::playing for
a couple classes which (now) only implement pause, as this is a requirement
for the objects to actually activate their animations

test cases:
* unit tests
* all elm_test animation cases
* elm_test video
* rage

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10114
This commit is contained in:
Mike Blumenkrantz 2019-09-24 11:18:57 -04:00 committed by Cedric Bail
parent 89bee7a11a
commit 3d3cdc5955
24 changed files with 279 additions and 188 deletions

View File

@ -82,13 +82,13 @@ _pause_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
if (ad->is_anim_paused)
{
//Pause animation
efl_player_play_set(ad->anim_obj, EINA_FALSE);
efl_player_paused_set(ad->anim_obj, EINA_TRUE);
elm_object_text_set(obj, "Resume Animation");
}
else
{
//Resume animation
efl_player_play_set(ad->anim_obj, EINA_TRUE);
efl_player_paused_set(ad->anim_obj, EINA_FALSE);
elm_object_text_set(obj, "Pause Animation");
}
}

View File

@ -122,8 +122,7 @@ test_efl_anim_repeat(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
App_Data *ad = calloc(1, sizeof(App_Data));
if (!ad) return;
Evas_Object *win = elm_win_add(NULL, "Efl Animation Repeat", ELM_WIN_BASIC);
elm_win_title_set(win, "Efl Animation Repeat");
Evas_Object *win = elm_win_util_standard_add(NULL, "Efl Animation Repeat");
elm_win_autodel_set(win, EINA_TRUE);
evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);

View File

@ -47,7 +47,11 @@ _anim_toggle(void *data, const Efl_Event *ev EINA_UNUSED)
EINA_ITERATOR_FOREACH(it, o)
{
if (efl_isa(o, EFL_PLAYER_INTERFACE) && efl_playable_get(o))
efl_player_play_set(o, !efl_player_play_get(o));
{
if (!efl_player_playing_get(o))
efl_player_playing_set(o, EINA_TRUE);
efl_player_paused_set(o, !efl_player_paused_get(o));
}
}
eina_iterator_free(it);
}

View File

@ -408,7 +408,7 @@ test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
efl_name_set(efl_added, images[k].src_name),
elm_object_tooltip_text_set(efl_added, images[k].src_name));
if (efl_playable_get(o))
efl_player_play_set(o, 1);
efl_player_playing_set(o, 1);
efl_event_callback_add(o, EFL_INPUT_EVENT_CLICKED, _img_click, win);
efl_pack(box2, o);
}

View File

@ -153,7 +153,7 @@ my_bt_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
if (file && eina_str_has_extension(file, ".gif")
&& efl_playable_get(ph))
efl_player_play_set(ph, EINA_TRUE);
efl_player_playing_set(ph, EINA_TRUE);
}
static void
@ -754,11 +754,11 @@ test_photocam_icon(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
static void
_zoomable_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev)
{
Eina_Bool play;
Eina_Bool paused;
play = !efl_player_play_get(ev->object);
printf("image clicked! play = %d\n", play);
efl_player_play_set(ev->object, play);
paused = efl_player_paused_get(ev->object);
printf("image clicked! paused = %d\n", paused);
efl_player_paused_set(ev->object, !paused);
}
static void
@ -832,7 +832,7 @@ test_image_zoomable_animated(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
if (efl_playable_get(zoomable))
{
printf("animation is available for this image.\n");
efl_player_play_set(zoomable, EINA_TRUE);
efl_player_playing_set(zoomable, EINA_TRUE);
}
rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,

View File

@ -1202,13 +1202,13 @@ edje_object_calc_force(Edje_Object *obj)
EAPI void
edje_object_play_set(Evas_Object *obj, Eina_Bool play)
{
efl_player_play_set(obj, play);
efl_player_paused_set(obj, !play);
}
EAPI Eina_Bool
edje_object_play_get(const Evas_Object *obj)
{
return efl_player_play_get(obj);
return !efl_player_paused_get(obj);
}
EAPI void

View File

@ -543,28 +543,26 @@ _efl_canvas_layout_efl_playable_playable_get(const Eo *obj EINA_UNUSED, Edje *pd
return EINA_TRUE;
}
EOLIAN void
_efl_canvas_layout_efl_player_play_set(Eo *obj EINA_UNUSED, Edje *ed, Eina_Bool play)
EOLIAN Eina_Bool
_efl_canvas_layout_efl_player_paused_set(Eo *obj EINA_UNUSED, Edje *ed, Eina_Bool paused)
{
double t;
Eina_List *l;
Edje_Running_Program *runp;
unsigned short i;
if (!ed) return;
if (ed->delete_me) return;
if (play)
if (!ed) return EINA_FALSE;
if (ed->delete_me) return EINA_FALSE;
paused = !!paused;
if (ed->paused == paused) return EINA_TRUE;
if (!paused)
{
if (!ed->paused) return;
ed->paused = EINA_FALSE;
t = ecore_time_get() - ed->paused_at;
EINA_LIST_FOREACH(ed->actions, l, runp)
runp->start_time += t;
}
else
{
if (ed->paused) return;
ed->paused = EINA_TRUE;
ed->paused_at = ecore_time_get();
}
@ -576,18 +574,17 @@ _efl_canvas_layout_efl_player_play_set(Eo *obj EINA_UNUSED, Edje *ed, Eina_Bool
((rp->type == EDJE_RP_TYPE_SWALLOW) &&
(rp->typedata.swallow)) &&
(rp->typedata.swallow->swallowed_object))
edje_object_play_set(rp->typedata.swallow->swallowed_object, play);
efl_player_paused_set(rp->typedata.swallow->swallowed_object, paused);
}
return EINA_TRUE;
}
EOLIAN Eina_Bool
_efl_canvas_layout_efl_player_play_get(const Eo *obj EINA_UNUSED, Edje *ed)
_efl_canvas_layout_efl_player_paused_get(const Eo *obj EINA_UNUSED, Edje *ed)
{
if (!ed) return EINA_FALSE;
if (ed->delete_me) return EINA_FALSE;
if (ed->paused) return EINA_FALSE;
return EINA_TRUE;
return ed->paused;
}
EOLIAN void

View File

@ -127,7 +127,7 @@ class @beta Efl.Canvas.Layout extends Efl.Canvas.Group implements Efl.File, Efl.
Efl.Part.part_get; [[Returns @Efl.Canvas.Layout_Part]]
Efl.Observer.update;
Efl.Playable.playable { get; }
Efl.Player.play { get; set; }
Efl.Player.paused { get; set; }
Efl.Player.play_speed { get; set; }
}
}

View File

@ -23,19 +23,22 @@ interface @beta Efl.Player
playing: bool; [[$true if playing, $false otherwise.]]
}
}
@property play {
[[Playback state of the media file.
@property paused {
[[Pause state of the media file.
This property sets the currently playback state of the
video. Using this function to play or pause the video
doesn't alter it's current position.
This property sets the pause state of the media. Re-setting the current
pause state has no effect.
If @.playing is set to $true, this property can be used to pause and resume
playback of the media without changing its @.progress property.
]]
set {
return: bool(false); [[If $true, the property change has succeeded.]]
}
get {
}
values {
play: bool; [[$true if playing, $false otherwise.]]
paused: bool; [[$true if paused, $false otherwise.]]
}
}
@property playback_position {

View File

@ -871,6 +871,8 @@ _efl_ui_image_efl_object_constructor(Eo *obj, Efl_Ui_Image_Data *pd)
pd->scale_type = EFL_GFX_IMAGE_SCALE_METHOD_FIT;
pd->self = obj;
/* legacy elm_image starts paused */
pd->paused = elm_widget_is_legacy(obj);
return obj;
}
@ -930,8 +932,11 @@ _efl_ui_image_efl_file_load(Eo *obj, Efl_Ui_Image_Data *sd)
if (sd->anim)
{
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
sd->play = EINA_FALSE;
sd->paused = elm_widget_is_legacy(obj);
sd->anim = EINA_FALSE;
sd->frame_count = -1;
sd->cur_frame = -1;
sd->frame_duration = -1;
}
if (file && _efl_ui_image_is_remote(file))
@ -967,8 +972,11 @@ _efl_ui_image_efl_file_unload(Eo *obj, Efl_Ui_Image_Data *sd)
if (sd->anim)
{
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
sd->play = EINA_FALSE;
sd->paused = elm_widget_is_legacy(obj);
sd->anim = EINA_FALSE;
sd->frame_count = -1;
sd->cur_frame = -1;
sd->frame_duration = -1;
}
if (sd->prev_img)
@ -1727,21 +1735,21 @@ _efl_ui_image_efl_playable_playable_get(const Eo *obj, Efl_Ui_Image_Data *sd)
return evas_object_image_animated_get(elm_image_object_get(obj));
}
static void
static Eina_Bool
_efl_ui_image_animated_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool anim)
{
anim = !!anim;
if (sd->anim == anim) return;
sd->anim = anim;
if (sd->anim == anim) return EINA_TRUE;
if (sd->edje)
{
edje_object_animation_set(sd->img, anim);
return;
sd->anim = anim;
return EINA_TRUE;
}
sd->img = elm_image_object_get(obj);
if (!evas_object_image_animated_get(sd->img)) return;
if (!evas_object_image_animated_get(sd->img)) return EINA_FALSE;
sd->anim = anim;
if (anim)
{
@ -1751,13 +1759,18 @@ _efl_ui_image_animated_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool an
evas_object_image_animated_frame_duration_get
(sd->img, sd->cur_frame, 0);
evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
if (!sd->paused)//legacy
sd->anim_timer = ecore_timer_add
(sd->frame_duration, _efl_ui_image_animate_cb, obj);
}
else
{
sd->frame_count = -1;
sd->cur_frame = -1;
sd->frame_duration = -1;
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
}
return EINA_TRUE;
}
static Eina_Bool
@ -1784,18 +1797,31 @@ elm_image_animated_get(const Evas_Object *obj)
return _efl_ui_image_animated_get_internal(obj, sd);
}
static void
_efl_ui_image_animated_play_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool play)
EOLIAN static Eina_Bool
_efl_ui_image_efl_player_playing_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool playing)
{
if (!sd->anim) return;
if (sd->play == play) return;
sd->play = play;
return _efl_ui_image_animated_set_internal(obj, sd, playing);
}
EOLIAN static Eina_Bool
_efl_ui_image_efl_player_playing_get(const Eo *obj, Efl_Ui_Image_Data *sd)
{
return _efl_ui_image_animated_get_internal(obj, sd);
}
static Eina_Bool
_efl_ui_image_animated_paused_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool paused)
{
paused = !!paused;
if (!sd->anim) return EINA_FALSE;
if (sd->paused == paused) return EINA_TRUE;
sd->paused = paused;
if (sd->edje)
{
edje_object_play_set(sd->img, play);
return;
edje_object_play_set(sd->img, !paused);
return EINA_TRUE;
}
if (play)
if (!paused)
{
sd->anim_timer = ecore_timer_add
(sd->frame_duration, _efl_ui_image_animate_cb, obj);
@ -1804,14 +1830,15 @@ _efl_ui_image_animated_play_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bo
{
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
}
return EINA_TRUE;
}
static Eina_Bool
_efl_ui_image_animated_play_get_internal(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
_efl_ui_image_animated_paused_get_internal(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
{
if (sd->edje)
return edje_object_play_get(sd->img);
return sd->play;
return !edje_object_play_get(sd->img);
return sd->paused;
}
EAPI void
@ -1819,7 +1846,7 @@ elm_image_animated_play_set(Elm_Image *obj, Eina_Bool play)
{
Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
if (!sd) return;
_efl_ui_image_animated_play_set_internal(obj, sd, play);
_efl_ui_image_animated_paused_set_internal(obj, sd, !play);
}
EAPI Eina_Bool
@ -1827,21 +1854,19 @@ elm_image_animated_play_get(const Elm_Image *obj)
{
Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
if (!sd) return EINA_FALSE;
return _efl_ui_image_animated_play_get_internal(obj, sd);
}
EOLIAN static void
_efl_ui_image_efl_player_play_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool play)
{
if (play && !_efl_ui_image_animated_get_internal(obj, sd))
_efl_ui_image_animated_set_internal(obj, sd, play);
_efl_ui_image_animated_play_set_internal(obj, sd, play);
return _efl_ui_image_animated_paused_get_internal(obj, sd);
}
EOLIAN static Eina_Bool
_efl_ui_image_efl_player_play_get(const Eo *obj, Efl_Ui_Image_Data *sd)
_efl_ui_image_efl_player_paused_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool paused)
{
return _efl_ui_image_animated_play_get_internal(obj, sd);
return _efl_ui_image_animated_paused_set_internal(obj, sd, paused);
}
EOLIAN static Eina_Bool
_efl_ui_image_efl_player_paused_get(const Eo *obj, Efl_Ui_Image_Data *sd)
{
return _efl_ui_image_animated_paused_get_internal(obj, sd);
}
EOLIAN static void

View File

@ -98,7 +98,8 @@ class Efl.Ui.Image extends Efl.Ui.Widget implements Efl.Input.Clickable, Efl.Ui.
Efl.Gfx.Image.content_hint { get; set; }
Efl.Gfx.Image.image_load_error { get; }
Efl.Playable.playable { get; }
Efl.Player.play { get; set; }
Efl.Player.playing { get; set; }
Efl.Player.paused { get; set; }
Efl.Layout.Signal.signal_emit;
Efl.Layout.Signal.message_send;
Efl.Layout.Signal.signal_callback_add;

View File

@ -3017,39 +3017,6 @@ _efl_ui_image_zoomable_animated_get_internal(const Eo *obj EINA_UNUSED, Efl_Ui_I
return sd->anim;
}
static void
_efl_ui_image_zoomable_animated_set_internal(Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool anim)
{
anim = !!anim;
if (sd->anim == anim) return;
sd->anim = anim;
if (sd->edje)
{
edje_object_animation_set(sd->edje, anim);
return;
}
if (!evas_object_image_animated_get(sd->img)) return;
if (anim)
{
sd->frame_count = evas_object_image_animated_frame_count_get(sd->img);
sd->cur_frame = 1;
sd->frame_duration =
evas_object_image_animated_frame_duration_get
(sd->img, sd->cur_frame, 0);
evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
}
else
{
sd->frame_count = -1;
sd->cur_frame = -1;
sd->frame_duration = -1;
}
}
static Eina_Bool
_efl_ui_image_zoomable_animate_cb(void *data)
{
@ -3072,18 +3039,56 @@ _efl_ui_image_zoomable_animate_cb(void *data)
return ECORE_CALLBACK_RENEW;
}
static void
_efl_ui_image_zoomable_animated_play_set_internal(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool play)
static Eina_Bool
_efl_ui_image_zoomable_animated_set_internal(Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool anim)
{
if (!sd->anim) return;
if (sd->play == play) return;
sd->play = play;
anim = !!anim;
if (sd->anim == anim) return EINA_TRUE;
if (sd->edje)
{
edje_object_play_set(sd->edje, play);
return;
sd->anim = anim;
edje_object_animation_set(sd->edje, anim);
return EINA_TRUE;
}
if (play)
if (!evas_object_image_animated_get(sd->img)) return EINA_FALSE;
sd->anim = anim;
if (anim)
{
sd->frame_count = evas_object_image_animated_frame_count_get(sd->img);
sd->cur_frame = 1;
sd->frame_duration =
evas_object_image_animated_frame_duration_get
(sd->img, sd->cur_frame, 0);
evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
if (!sd->paused)//legacy
sd->anim_timer = ecore_timer_add
(sd->frame_duration, _efl_ui_image_zoomable_animate_cb, obj);
}
else
{
sd->frame_count = -1;
sd->cur_frame = -1;
sd->frame_duration = -1;
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
}
return EINA_TRUE;
}
static Eina_Bool
_efl_ui_image_zoomable_animated_paused_set_internal(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool paused)
{
paused = !!paused;
if (!sd->anim) return EINA_FALSE;
if (sd->paused == paused) return EINA_TRUE;
sd->paused = paused;
if (sd->edje)
{
edje_object_play_set(sd->edje, !paused);
return EINA_TRUE;
}
if (!paused)
{
sd->anim_timer = ecore_timer_add
(sd->frame_duration, _efl_ui_image_zoomable_animate_cb, obj);
@ -3092,30 +3097,33 @@ _efl_ui_image_zoomable_animated_play_set_internal(Eo *obj, Efl_Ui_Image_Zoomable
{
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
}
}
EOLIAN static void
_efl_ui_image_zoomable_efl_player_play_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool play)
{
evas_object_image_preload(sd->img, EINA_FALSE);
if (play && !_efl_ui_image_zoomable_animated_get_internal(obj, sd))
_efl_ui_image_zoomable_animated_set_internal(obj, sd, play);
_efl_ui_image_zoomable_animated_play_set_internal(obj, sd, play);
}
static Eina_Bool
_efl_ui_image_zoomable_animated_play_get_internal(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
{
if (sd->edje)
return edje_object_play_get(sd->edje);
return sd->play;
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_ui_image_zoomable_efl_player_play_get(const Eo *obj, Efl_Ui_Image_Zoomable_Data *sd)
_efl_ui_image_zoomable_efl_player_playing_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool playing)
{
return _efl_ui_image_zoomable_animated_play_get_internal(obj, sd);
return _efl_ui_image_zoomable_animated_set_internal(obj, sd, playing);
}
EOLIAN static Eina_Bool
_efl_ui_image_zoomable_efl_player_paused_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool paused)
{
return _efl_ui_image_zoomable_animated_paused_set_internal(obj, sd, paused);
}
EOLIAN static Eina_Bool
_efl_ui_image_zoomable_efl_player_playing_get(const Eo *obj, Efl_Ui_Image_Zoomable_Data *sd)
{
return _efl_ui_image_zoomable_animated_get_internal(obj, sd);
}
EOLIAN static Eina_Bool
_efl_ui_image_zoomable_efl_player_paused_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
{
if (sd->edje)
return !edje_object_play_get(sd->edje);
return sd->paused;
}
EOLIAN static void

View File

@ -44,7 +44,8 @@ class @beta Efl.Ui.Image_Zoomable extends Efl.Ui.Image implements Efl.Ui.Zoom
Efl.Gfx.Image.image_size { get; }
Efl.Ui.Image.icon { set; get; }
Efl.Playable.playable { get; }
Efl.Player.play { get; set; }
Efl.Player.playing { get; set; }
Efl.Player.paused { get; set; }
Efl.Ui.Zoom.zoom_animation { set; get; }
Efl.Ui.Zoom.zoom_level { set; get; }
Efl.Ui.Zoom.zoom_mode { set; get; }

View File

@ -140,7 +140,6 @@ struct _Efl_Ui_Image_Zoomable_Data
Eina_Bool on_hold : 1;
Eina_Bool paused : 1;
Eina_Bool orientation_changed : 1;
Eina_Bool play : 1;
Eina_Bool anim : 1;
Eina_Bool freeze_want : 1;
Eina_Bool show_item: 1;

View File

@ -23,7 +23,7 @@ _geom_sync(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Stack_Data *pd)
{
Eina_Array *array = eina_array_new(2);
Eina_Rect group_pos = efl_gfx_entity_geometry_get(pd->group);
if (efl_player_play_get(pd->hide))
if (efl_player_playing_get(pd->hide))
{
//we are currently in animation, sync the geometry of the targets
eina_array_push(array, efl_animation_player_target_get(pd->hide));
@ -132,7 +132,7 @@ _efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_bind(Eo *obj, Efl_Ui_Sp
pd->show = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, obj);
efl_animation_player_animation_set(pd->show, show_anim);
efl_player_play_set(pd->show, EINA_FALSE);
efl_player_playing_set(pd->show, EINA_FALSE);
efl_event_callback_array_add(pd->show, _anim_show_event_cb(), obj);
//Default Hide Animation
@ -143,7 +143,7 @@ _efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_bind(Eo *obj, Efl_Ui_Sp
pd->hide = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, obj);
efl_animation_player_animation_set(pd->hide, hide_anim);
efl_player_play_set(pd->hide, EINA_FALSE);
efl_player_playing_set(pd->hide, EINA_FALSE);
efl_event_callback_array_add(pd->hide, _anim_hide_event_cb(), obj);
for (int i = 0; i < efl_content_count(spotlight) ; ++i) {

View File

@ -95,7 +95,7 @@ _key_action_move(Evas_Object *obj, const char *params)
static Eina_Bool
_key_action_play(Evas_Object *obj, const char *params EINA_UNUSED)
{
if (efl_player_play_get(obj))
if (!efl_player_paused_get(obj))
elm_video_pause(obj);
else
elm_video_play(obj);
@ -327,15 +327,17 @@ _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_play_set(Eo *obj, Efl_Ui_Video_Data *sd, Eina_Bool play)
EOLIAN static Eina_Bool
_efl_ui_video_efl_player_paused_set(Eo *obj, Efl_Ui_Video_Data *sd, Eina_Bool paused)
{
if (emotion_object_play_get(sd->emotion) == !!play) return;
paused = !!paused;
/* can't pause if we're stopped */
if (sd->stop) return EINA_FALSE;
if (emotion_object_play_get(sd->emotion) == !paused) return EINA_TRUE;
if (play)
if (!paused)
{
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
sd->stop = EINA_FALSE;
emotion_object_play_set(sd->emotion, EINA_TRUE);
if(elm_widget_is_legacy(obj))
@ -356,6 +358,7 @@ _efl_ui_video_efl_player_play_set(Eo *obj, Efl_Ui_Video_Data *sd, Eina_Bool play
else
elm_layout_signal_emit(obj, "efl,video,pause", "efl");
}
return EINA_TRUE;
}
/* FIXME: stop should go into hibernate state directly.
@ -397,9 +400,10 @@ _efl_ui_video_efl_player_playing_get(const Eo *obj EINA_UNUSED, Efl_Ui_Video_Dat
}
EOLIAN static Eina_Bool
_efl_ui_video_efl_player_play_get(const Eo *obj EINA_UNUSED, Efl_Ui_Video_Data *sd)
_efl_ui_video_efl_player_paused_get(const Eo *obj EINA_UNUSED, Efl_Ui_Video_Data *sd)
{
return emotion_object_play_get(sd->emotion);
/* pause is when !playing and !stopped */
return !emotion_object_play_get(sd->emotion) && !sd->stop;
}
EOLIAN static const char*
@ -533,13 +537,16 @@ elm_video_play_position_get(const Evas_Object *obj)
EAPI Eina_Bool
elm_video_is_playing_get(Evas_Object *obj)
{
return efl_player_play_get(obj);
return efl_player_playing_get(obj) && !efl_player_paused_get(obj);
}
EAPI void
elm_video_play(Evas_Object *obj)
{
efl_player_play_set(obj, EINA_TRUE);
if (efl_player_playing_get(obj))
efl_player_paused_set(obj, EINA_FALSE);
else
efl_player_playing_set(obj, EINA_TRUE);
}
EAPI void
@ -551,7 +558,7 @@ elm_video_stop(Evas_Object *obj)
EAPI void
elm_video_pause(Evas_Object *obj)
{
efl_player_play_set(obj, EINA_FALSE);
efl_player_paused_set(obj, EINA_TRUE);
}
#include "efl_ui_video_legacy_eo.c"

View File

@ -44,6 +44,6 @@ class @beta Efl.Ui.Video extends Efl.Ui.Layout_Base
Efl.Ui.Widget.widget_input_event_handler;
Efl.Access.Widget.Action.elm_actions { get; }
Efl.Player.playing { get; set; }
Efl.Player.play { get; set; }
Efl.Player.paused { get; set; }
}
}

View File

@ -96,7 +96,7 @@ struct _Efl_Ui_Image_Data
Eina_Bool edit : 1;
Eina_Bool edje : 1;
Eina_Bool anim : 1;
Eina_Bool play : 1;
Eina_Bool paused : 1;
Eina_Bool async_enable : 1;
Eina_Bool scale_up : 1;
Eina_Bool scale_down : 1;

View File

@ -57,7 +57,8 @@ class @beta Efl.Canvas.Video extends Efl.Canvas.Group
Efl.File.unload;
Efl.File.file { set; }
Efl.File.loaded { get; }
Efl.Player.play { get; set; }
Efl.Player.playing { get; set; }
Efl.Player.paused { get; set; }
Efl.Player.playback_position { get; set; }
Efl.Player.progress { get; }
Efl.Audio_Control.volume { get; set; }

View File

@ -116,6 +116,7 @@ struct _Efl_Canvas_Video_Data
Eina_Bool open : 1;
Eina_Bool play : 1;
Eina_Bool pause : 1;
Eina_Bool remember_play : 1;
Eina_Bool seek : 1;
Eina_Bool seeking : 1;
@ -645,40 +646,85 @@ emotion_object_keep_aspect_get(const Evas_Object *obj)
EAPI void
emotion_object_play_set(Evas_Object *obj, Eina_Bool play)
{
efl_player_play_set(obj, play);
/* avoid calling playback_position_set(0) for legacy */
if (play)
efl_player_playing_set(obj, EINA_TRUE);
efl_player_paused_set(obj, !play);
}
EOLIAN static void
_efl_canvas_video_efl_player_play_set(Eo *obj, Efl_Canvas_Video_Data *sd, Eina_Bool play)
EOLIAN static Eina_Bool
_efl_canvas_video_efl_player_playing_set(Eo *obj, Efl_Canvas_Video_Data *sd, Eina_Bool play)
{
play = !!play;
DBG("play=" FMT_UCHAR ", was=" FMT_UCHAR, play, sd->play);
if (!sd->engine_instance) return;
if (!sd->engine_instance) return EINA_FALSE;
/* always unset pause if playing is false */
if (!play) sd->pause = EINA_FALSE;
if (!sd->open)
{
sd->remember_play = play;
return;
return EINA_TRUE;
}
if (play == sd->play) return;
if (play == sd->play) return EINA_TRUE;
sd->play = play;
sd->remember_play = play;
if (sd->state != EMOTION_WAKEUP) emotion_object_suspend_set(obj, EMOTION_WAKEUP);
if (sd->play) emotion_engine_instance_play(sd->engine_instance, sd->pos);
else emotion_engine_instance_stop(sd->engine_instance);
if (sd->play) emotion_engine_instance_play(sd->engine_instance, 0.0);
else
{
emotion_engine_instance_stop(sd->engine_instance);
efl_player_playback_position_set(obj, 0.0);
}
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_canvas_video_efl_player_paused_set(Eo *obj, Efl_Canvas_Video_Data *sd, Eina_Bool paused)
{
paused = !!paused;
DBG("paused=" FMT_UCHAR ", was=" FMT_UCHAR, paused, sd->pause);
if (!sd->engine_instance) return EINA_FALSE;
if (!sd->open)
{
/* queue pause */
if (sd->remember_play)
sd->pause = paused;
return sd->remember_play;
}
if (!sd->play) return EINA_FALSE;
if (paused == sd->pause) return EINA_TRUE;
sd->pause = paused;
if (sd->pause)
emotion_engine_instance_stop(sd->engine_instance);
else
{
if (sd->state != EMOTION_WAKEUP) emotion_object_suspend_set(obj, EMOTION_WAKEUP);
emotion_engine_instance_play(sd->engine_instance, sd->pos);
}
return EINA_TRUE;
}
EAPI Eina_Bool
emotion_object_play_get(const Evas_Object *obj)
{
return efl_player_play_get(obj);
return efl_player_playing_get(obj) && !efl_player_paused_get(obj);
}
EOLIAN static Eina_Bool
_efl_canvas_video_efl_player_play_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
_efl_canvas_video_efl_player_playing_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
{
if (!sd->engine_instance) return EINA_FALSE;
return sd->play;
}
EOLIAN static Eina_Bool
_efl_canvas_video_efl_player_paused_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
{
if (!sd->engine_instance) return EINA_FALSE;
if (!sd->play) return EINA_FALSE;
return sd->pause;
}
EAPI void
emotion_object_position_set(Evas_Object *obj, double sec)
{
@ -1632,7 +1678,12 @@ _emotion_open_done(Evas_Object *obj)
if (!EINA_DBL_EQ(sd->remember_jump, 0.0))
emotion_object_position_set(obj, sd->remember_jump);
if (sd->remember_play != sd->play)
emotion_object_play_set(obj, sd->remember_play);
{
if (sd->pause)
sd->play = sd->remember_play;
else
emotion_object_play_set(obj, sd->remember_play);
}
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_OPEN_DONE, NULL);
evas_object_smart_callback_call(obj, "open_done", NULL);
}

View File

@ -222,35 +222,25 @@ _player_stop(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, Efl_Canvas_Animat
//Reset the state of the target to the initial state
efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj));
Eina_Bool play = efl_player_play_get(eo_obj);
if (play)
if (efl_animation_final_state_keep_get(anim))
{
efl_player_play_set(eo_obj, EINA_FALSE);
if (efl_animation_final_state_keep_get(anim))
if (_is_final_state(anim, pd->progress))
{
if (_is_final_state(anim, pd->progress))
{
/* Keep the final state only if efl_player_stop is called at
* the end of _animator_cb. */
efl_animation_apply(anim, pd->progress,
efl_animation_player_target_get(eo_obj));
}
else
{
pd->progress = 0.0;
}
/* Keep the final state only if efl_player_playing_set(EINA_FALSE) is called at
* the end of _animator_cb. */
efl_animation_apply(anim, pd->progress,
efl_animation_player_target_get(eo_obj));
}
else
{
pd->progress = 0.0;
}
efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL);
}
else
{
pd->progress = 0.0;
}
efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL);
if (pd->auto_del) efl_del(eo_obj);
}
@ -266,6 +256,8 @@ _efl_canvas_animation_player_efl_player_playing_set(Eo *eo_obj, Efl_Canvas_Anima
pd->is_play = !!playing;
if (!playing)
{
if (!pd->is_play) return EINA_TRUE;
pd->is_paused = EINA_FALSE;
_player_stop(eo_obj, pd, anim);
return EINA_TRUE;
}
@ -290,19 +282,20 @@ _efl_canvas_animation_player_efl_player_playing_get(const Eo *eo_obj EINA_UNUSED
return pd->is_play;
}
EOLIAN static void
_efl_canvas_animation_player_efl_player_play_set(Eo *eo_obj,
EOLIAN static Eina_Bool
_efl_canvas_animation_player_efl_player_paused_set(Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd,
Eina_Bool play)
Eina_Bool paused)
{
if (efl_player_play_get(eo_obj) == !!play)
return;
pd->is_play = play;
if (play)
paused = !!paused;
/* can't pause if not playing */
if (!pd->is_play) return EINA_FALSE;
if (pd->is_paused == paused) return EINA_TRUE;
pd->is_paused = paused;
if (!paused)
{
//TODO: check this case is correct.
if (pd->start_delay_timer) return;
if (pd->start_delay_timer) return EINA_FALSE;
pd->time.prev = ecore_loop_time_get();
pd->animator = ecore_evas_animator_add(pd->target, _animator_cb, eo_obj);
@ -316,13 +309,14 @@ _efl_canvas_animation_player_efl_player_play_set(Eo *eo_obj,
ecore_animator_del(pd->animator);
pd->animator = NULL;
}
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_canvas_animation_player_efl_player_play_get(const Eo *eo_obj EINA_UNUSED,
_efl_canvas_animation_player_efl_player_paused_get(const Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd)
{
return pd->is_play;
return pd->is_paused;
}
EOLIAN static Eina_Bool

View File

@ -36,7 +36,7 @@ class @beta Efl.Canvas.Animation_Player extends Efl.Object implements Efl.Player
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Player.playing { get; set; }
Efl.Player.play { get; set; }
Efl.Player.paused { get; set; }
Efl.Playable.playable { get; }
Efl.Player.playback_position { get; set; }
Efl.Player.progress { get;}

View File

@ -41,6 +41,7 @@ typedef struct _Efl_Canvas_Animation_Player_Data
Eina_Bool auto_del : 1;
Eina_Bool is_play : 1;
Eina_Bool is_paused : 1;
Eina_Bool keep_final_state : 1;
Eina_Bool is_direction_forward : 1;
} Efl_Canvas_Animation_Player_Data;

View File

@ -107,7 +107,7 @@ _evas_object_intercept_call_internal(Evas_Object *eo_obj,
/* If show is called during hide animation is running, then the
* current hide animation is cancelled and show operation is
* proceeded. */
if ((!obj->anim_player) || (!efl_player_play_get(obj->anim_player)))
if ((!obj->anim_player) || (!efl_player_playing_get(obj->anim_player)))
return 1;
}
if (!obj->interceptors) return 0;