aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-12-14 16:46:39 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-12-16 19:58:15 -0800
commitac1d71ad7e6610739ad74815ae90fafc6cbbcb2c (patch)
tree7ec645e45189647d5992f72a06d0d681b87cca0f
parent62c16eaa5a9e97145dc2ee2f03f9f900ada27147 (diff)
binding: mediaplayer: fix reporting to mediaplayer UI
1) local media wasn't stopping playback when a2dp transport was connected 2) when disconnecting a2dp the local media metadata wasn't being displayed 3) pausing wasn't sending an event to the UI subscriber Bug-AGL: SPEC-1630 Change-Id: I67eee3af44169c8138d03aff591200884f1dd6ae Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/afm-mediaplayer-binding.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index 37cd85e..7358f95 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -40,6 +40,8 @@ static GList *playlist = NULL;
static GList *metadata_track = NULL;
static GList *current_track = NULL;
+static json_object *populate_json_metadata(void);
+
typedef struct _CustomData {
GstElement *playbin, *fake_sink, *alsa_sink;
gboolean playing;
@@ -406,10 +408,18 @@ static void gstreamer_controls(afb_req_t request)
break;
}
case PAUSE_CMD:
- jresp = json_object_new_object();
gst_element_set_state(data.playbin, GST_STATE_PAUSED);
AFB_DEBUG("GSTREAMER playbin.state = GST_STATE_PAUSED");
data.playing = FALSE;
+
+ /* metadata event */
+ jresp = populate_json_metadata();
+ json_object_object_add(jresp, "status",
+ json_object_new_string("stopped"));
+ afb_event_push(metadata_event, jresp);
+
+ /* status returned */
+ jresp = json_object_new_object();
json_object_object_add(jresp, "playing", json_object_new_boolean(FALSE));
break;
case PREVIOUS_CMD:
@@ -923,8 +933,15 @@ static void onevent(afb_api_t api, const char *event, struct json_object *object
gboolean state = json_object_get_boolean(val);
data.avrcp_connected = state;
- if (state)
+ if (state) {
+ data.playing = FALSE;
gst_element_set_state(data.playbin, GST_STATE_PAUSED);
+ } else {
+ json_object *jresp = populate_json_metadata();
+ json_object_object_add(jresp, "status",
+ json_object_new_string("stopped"));
+ afb_event_push(metadata_event, jresp);
+ }
}
pthread_mutex_unlock(&mutex);