aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-10-23 21:24:01 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-10-23 21:29:40 -0700
commit4ce89b162cecc149ad2864c8a839befdbf83487e (patch)
tree564b92d7f483704983c4c0803ede3d327ddb4a9b
parent3e652b17cd0304633e04d71d2fe70492c3fbb00a (diff)
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 <matt.ranostay@konsulko.com>
-rw-r--r--binding/afm-mediaplayer-binding.c19
1 files changed, 18 insertions, 1 deletions
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);