aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--binding/afm-common.c1
-rw-r--r--binding/afm-common.h1
-rw-r--r--binding/afm-mediaplayer-binding.c12
3 files changed, 13 insertions, 1 deletions
diff --git a/binding/afm-common.c b/binding/afm-common.c
index 3f0f38e..0f27d57 100644
--- a/binding/afm-common.c
+++ b/binding/afm-common.c
@@ -29,6 +29,7 @@ const char *control_commands[] = {
"rewind",
"pick-track",
"volume",
+ "loop",
};
int get_command_index(const char *name)
diff --git a/binding/afm-common.h b/binding/afm-common.h
index 8a418a1..5b36404 100644
--- a/binding/afm-common.h
+++ b/binding/afm-common.h
@@ -47,6 +47,7 @@ enum {
REWIND_CMD,
PICKTRACK_CMD,
VOLUME_CMD,
+ LOOP_CMD,
NUM_CMDS
};
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);
}