aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
}