forked from enlightenment/efl
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
This commit is contained in:
parent
2f7eef14d8
commit
a63306a908
|
@ -94,4 +94,12 @@ interface Efl.Player
|
|||
}
|
||||
}
|
||||
}
|
||||
events {
|
||||
playing,changed: bool; [[Called when the playing state has changed. The event value reflects the current state. @since 1.24]]
|
||||
paused,changed: bool; [[Called when the paused state has changed. The event value reflects the current state. @since 1.24]]
|
||||
playback_progress,changed: double; [[Called when the playback_progress state has changed. The event value reflects the current state. @since 1.24]]
|
||||
playback_position,changed: double; [[Called when the playback_position state has changed. The event value reflects the current state. @since 1.24]]
|
||||
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]]
|
||||
playback,finished: void; [[Called when the player has completed playing its data stream. @since 1.24]]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,12 +64,16 @@ _size_hint_event_cb(void *data, const Efl_Event *event)
|
|||
static void
|
||||
_transit_go_facade(Eo* obj, Efl_Ui_Vg_Animation_Data *pd)
|
||||
{
|
||||
Eina_Bool playing = EINA_TRUE;
|
||||
pd->repeat_times = 0;
|
||||
if (pd->playing_reverse)
|
||||
pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS;
|
||||
else
|
||||
pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING;
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_START, NULL);
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_START, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYING_CHANGED, &playing);
|
||||
if (pd->transit) elm_transit_go(pd->transit);}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -106,25 +110,33 @@ _autoplay(Eo *obj, Efl_Ui_Vg_Animation_Data *pd, Eina_Bool vis)
|
|||
{
|
||||
if (pd->state == EFL_UI_VG_ANIMATION_STATE_PAUSED && pd->autoplay_pause)
|
||||
{
|
||||
Eina_Bool paused = EINA_FALSE;
|
||||
elm_transit_paused_set(pd->transit, EINA_FALSE);
|
||||
if (pd->playing_reverse)
|
||||
pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS;
|
||||
else
|
||||
pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING;
|
||||
pd->autoplay_pause = EINA_FALSE;
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL);
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
|
||||
}
|
||||
}
|
||||
//Pause Animation
|
||||
else
|
||||
{
|
||||
Eina_Bool paused = EINA_TRUE;
|
||||
if ((pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING) ||
|
||||
(pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS))
|
||||
{
|
||||
elm_transit_paused_set(pd->transit, EINA_TRUE);
|
||||
pd->state = EFL_UI_VG_ANIMATION_STATE_PAUSED;
|
||||
pd->autoplay_pause = EINA_TRUE;
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +150,12 @@ _transit_del_cb(Elm_Transit_Effect *effect, Elm_Transit *transit)
|
|||
|
||||
if ((pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING && pd->progress == 1) ||
|
||||
(pd->state == EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS && pd->progress == 0))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_DONE, NULL);
|
||||
{
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_DONE, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYBACK_FINISHED, NULL);
|
||||
}
|
||||
|
||||
if (pd->transit != transit) return;
|
||||
|
||||
|
@ -149,7 +166,11 @@ _transit_del_cb(Elm_Transit_Effect *effect, Elm_Transit *transit)
|
|||
|
||||
if (prev_state != EFL_UI_VG_ANIMATION_STATE_STOPPED)
|
||||
{
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_STOP, NULL);
|
||||
Eina_Bool playing = EINA_FALSE;
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_STOP, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYING_CHANGED, &playing);
|
||||
pd->progress = 0;
|
||||
}
|
||||
}
|
||||
|
@ -201,15 +222,25 @@ _transit_cb(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
|
|||
int repeat_times = elm_transit_current_repeat_times_get(pd->transit);
|
||||
if (pd->repeat_times != repeat_times)
|
||||
{
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_REPEAT, NULL);
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_REPEAT, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYBACK_REPEATED, &repeat_times);
|
||||
pd->repeat_times = repeat_times;
|
||||
}
|
||||
}
|
||||
|
||||
//transit_cb is always called with a progress value 0 ~ 1.
|
||||
//SIG_PLAY_UPDATE callback is called only when there is a real change.
|
||||
if (update_frame != current_frame)
|
||||
if (update_frame == current_frame) return;
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_UPDATE, NULL);
|
||||
else
|
||||
{
|
||||
double position = pd->frame_duration * pd->progress;
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYBACK_POSITION_CHANGED, &position);
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYBACK_PROGRESS_CHANGED, &pd->progress);
|
||||
}
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
@ -354,10 +385,14 @@ _efl_ui_vg_animation_efl_file_load(Eo *obj, Efl_Ui_Vg_Animation_Data *pd)
|
|||
|
||||
if (!_visible_check(obj))
|
||||
{
|
||||
Eina_Bool paused = EINA_TRUE;
|
||||
elm_transit_paused_set(pd->transit, EINA_TRUE);
|
||||
pd->state = EFL_UI_VG_ANIMATION_STATE_PAUSED;
|
||||
pd->autoplay_pause = EINA_TRUE;
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -492,6 +527,7 @@ Eina_Bool _efl_ui_vg_animation_playing_sector(Eo *obj, Efl_Ui_Vg_Animation_Data
|
|||
Eina_Bool
|
||||
_playing_stop(Eo* obj, Efl_Ui_Vg_Animation_Data *pd)
|
||||
{
|
||||
Eina_Bool playing = EINA_FALSE;
|
||||
if (!pd->transit) return EINA_FALSE;
|
||||
|
||||
if ((pd->state == EFL_UI_VG_ANIMATION_STATE_NOT_READY) ||
|
||||
|
@ -501,7 +537,11 @@ _playing_stop(Eo* obj, Efl_Ui_Vg_Animation_Data *pd)
|
|||
evas_object_vg_animated_frame_set(pd->vg, 0);
|
||||
pd->progress = 0;
|
||||
pd->state = EFL_UI_VG_ANIMATION_STATE_STOPPED;
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_STOP, NULL);
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_STOP, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PLAYING_CHANGED, &playing);
|
||||
|
||||
elm_transit_del(pd->transit);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -696,7 +736,7 @@ _efl_ui_vg_animation_efl_player_playing_get(const Eo *obj EINA_UNUSED, Efl_Ui_Vg
|
|||
EOLIAN static Eina_Bool
|
||||
_efl_ui_vg_animation_efl_player_paused_set(Eo *obj EINA_UNUSED, Efl_Ui_Vg_Animation_Data *pd, Eina_Bool paused)
|
||||
{
|
||||
|
||||
paused = !!paused;
|
||||
if (paused)
|
||||
{
|
||||
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
|
|||
elm_transit_paused_set(pd->transit, paused);
|
||||
pd->state = EFL_UI_VG_ANIMATION_STATE_PAUSED;
|
||||
pd->autoplay_pause = EINA_FALSE;
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -718,8 +761,10 @@ _efl_ui_vg_animation_efl_player_paused_set(Eo *obj EINA_UNUSED, Efl_Ui_Vg_Animat
|
|||
else
|
||||
pd->state = EFL_UI_VG_ANIMATION_STATE_PLAYING;
|
||||
pd->autoplay_pause = EINA_FALSE;
|
||||
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL);
|
||||
if (elm_widget_is_legacy(obj))
|
||||
evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL);
|
||||
else
|
||||
efl_event_callback_call(obj, EFL_PLAYER_EVENT_PAUSED_CHANGED, &paused);
|
||||
}
|
||||
}
|
||||
return EINA_TRUE;
|
||||
|
|
|
@ -204,13 +204,4 @@ class @beta Efl.Ui.Vg_Animation extends Efl.Ui.Widget implements Efl.Gfx.View, E
|
|||
Efl.Playable.playable { get; }
|
||||
Efl.Playable.seekable { get; }
|
||||
}
|
||||
events {
|
||||
play,start: void; [[Called when animation is just started]]
|
||||
play,repeat: void; [[Called when animation is just repeated]]
|
||||
play,done: void; [[Called when animation is just finished]]
|
||||
play,pause: void; [[Called when animation is just paused]]
|
||||
play,resume: void; [[Called when animation is just resumed]]
|
||||
play,stop: void; [[Called when animation is just stopped]]
|
||||
play,update: void; [[Called when animation is just updated]]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue