aboutsummaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
Diffstat (limited to 'binding')
-rw-r--r--binding/afm-mediaplayer-binding.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index b0876fa..3aab371 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -228,31 +228,6 @@ static void audio_playlist(struct afb_req request)
pthread_mutex_unlock(&mutex);
}
-static int seek_track(int cmd)
-{
- GList *item = NULL;
- int ret;
-
- if (current_track == NULL)
- return -EINVAL;
-
- item = (cmd == NEXT_CMD) ? current_track->next : current_track->prev;
-
- if (item == NULL)
- return -EINVAL;
-
- ret = set_media_uri(item->data);
- if (ret < 0)
- return -EINVAL;
-
- if (data.playing)
- gst_element_set_state(data.playbin, GST_STATE_PLAYING);
-
- current_track = item;
-
- return 0;
-}
-
static int seek_stream(const char *value, int cmd)
{
gint64 position, current = 0;
@@ -278,6 +253,36 @@ static int seek_stream(const char *value, int cmd)
position * GST_MSECOND);
}
+static int seek_track(int cmd)
+{
+ GList *item = NULL;
+ int ret;
+
+ if (current_track == NULL)
+ return -EINVAL;
+
+ item = (cmd == NEXT_CMD) ? current_track->next : current_track->prev;
+
+ if (item == NULL) {
+ if (cmd == PREVIOUS_CMD) {
+ seek_stream("0", SEEK_CMD);
+ return 0;
+ }
+ return -EINVAL;
+ }
+
+ ret = set_media_uri(item->data);
+ if (ret < 0)
+ return -EINVAL;
+
+ if (data.playing)
+ gst_element_set_state(data.playbin, GST_STATE_PLAYING);
+
+ current_track = item;
+
+ return 0;
+}
+
/* @value can be one of the following values:
* play - go to playing transition
* pause - go to pause transition