aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-10-19 21:14:33 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-10-19 21:14:40 -0700
commit9d5f34e17c41332cddab11b71e15f28393f593c1 (patch)
treede077fed4b29949a58d05ccdfbf4ca2867cf3646
parented2d5d3363d3ee1b689871ab09cc5a68785419b9 (diff)
binding: mediaplayer: previous command on first track rewinds to beginning
If on first track on playlist and get previous track commands just rewind to beginning of that track. Bug-AGL: SPEC-931 Change-Id: Ie3decb70bd0826ad5199bdc9641befcc52cfd40a Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-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