From 4ce89b162cecc149ad2864c8a839befdbf83487e Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Mon, 23 Oct 2017 21:24:01 -0700 Subject: binding: mediaplayer: ending of playlist needs to send an event When ending a playlist an event needs to be sent to notify the UI Bug-AGL: SPEC-931 Change-Id: Ib96ee49775a90d9ca969031443cb9e9e2ec4610e Signed-off-by: Matt Ranostay --- binding/afm-mediaplayer-binding.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c index 9e77dc1..805a6bb 100644 --- a/binding/afm-mediaplayer-binding.c +++ b/binding/afm-mediaplayer-binding.c @@ -43,6 +43,7 @@ typedef struct _CustomData { GstElement *playbin; gboolean playing; gboolean loop; + gboolean one_time; guint volume; gint64 position; gint64 duration; @@ -536,8 +537,10 @@ static gboolean handle_message(GstBus *bus, GstMessage *msg, CustomData *data) ret = seek_track(NEXT_CMD); if (ret < 0) { - if (!data->loop) + if (!data->loop) { data->playing = FALSE; + data->one_time = TRUE; + } current_track = playlist; set_media_uri(current_track->data); } else if (data->playing) { @@ -564,6 +567,18 @@ static gboolean position_event(CustomData *data) pthread_mutex_lock(&mutex); + if (data->one_time) { + data->one_time = FALSE; + + json_object *jresp = json_object_new_object(); + json_object_object_add(jresp, "status", + json_object_new_string("stopped")); + pthread_mutex_unlock(&mutex); + + afb_event_push(metadata_event, jresp); + return; + } + if (!data->playing || current_track == NULL) { pthread_mutex_unlock(&mutex); return TRUE; @@ -583,6 +598,8 @@ static gboolean position_event(CustomData *data) json_object_new_int64(data->duration / GST_MSECOND)); json_object_object_add(jresp, "position", json_object_new_int64(data->position / GST_MSECOND)); + json_object_object_add(jresp, "status", + json_object_new_string("playing")); pthread_mutex_unlock(&mutex); -- cgit 1.2.3-korg