summaryrefslogtreecommitdiffstats
path: root/binding/afm-mediaplayer-binding.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-10-23 18:34:56 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-10-23 20:02:17 -0700
commit3e652b17cd0304633e04d71d2fe70492c3fbb00a (patch)
tree27c88ea4d7b7e1fcfae5cd527b9fc96b5375a211 /binding/afm-mediaplayer-binding.c
parent2c1535e6f96bbaeceeb45b145930b2a10419c190 (diff)
binding: mediaplayer: add looping of playlist
Allow playlist to be looped when it reachs the end of it. Bug-AGL: SPEC-931 Change-Id: I482c51d12234a5e70f76fbb981249a643b6b78fc Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/afm-mediaplayer-binding.c')
-rw-r--r--binding/afm-mediaplayer-binding.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index 6c3c3b3..9e77dc1 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -42,6 +42,7 @@ static GList *current_track = NULL;
typedef struct _CustomData {
GstElement *playbin;
gboolean playing;
+ gboolean loop;
guint volume;
gint64 position;
gint64 duration;
@@ -295,6 +296,7 @@ static int seek_track(int cmd)
*
* pick-track - select track via index number
* volume - set volume between 0 - 100%
+ * loop - set looping of playlist (true or false)
*/
static void controls(struct afb_req request)
@@ -379,6 +381,11 @@ static void controls(struct afb_req request)
break;
}
+ case LOOP_CMD: {
+ const char *state = afb_req_value(request, "state");
+ data.loop = !strcasecmp(state, "true") ? TRUE : FALSE;
+ break;
+ }
default:
afb_req_fail(request, "failed", "unknown command");
pthread_mutex_unlock(&mutex);
@@ -527,9 +534,12 @@ static gboolean handle_message(GstBus *bus, GstMessage *msg, CustomData *data)
data->duration = GST_CLOCK_TIME_NONE;
ret = seek_track(NEXT_CMD);
+
if (ret < 0) {
- data->playing = FALSE;
+ if (!data->loop)
+ data->playing = FALSE;
current_track = playlist;
+ set_media_uri(current_track->data);
} else if (data->playing) {
gst_element_set_state(data->playbin, GST_STATE_PLAYING);
}