summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2015-08-20 16:28:10 +0900
committerMinkyu Kang <mk7.kang@samsung.com>2015-08-21 10:05:47 +0900
commit0c802141d6f83606e0581ee33ae2ef0128ff0270 (patch)
tree0c10be92bb539b20462762e6b193baab47ceabe3
parent6c754eac11174331a8a01d8409e45e94a35d5177 (diff)
downloadair_mediahub-0c802141d6f83606e0581ee33ae2ef0128ff0270.tar.gz
air_mediahub-0c802141d6f83606e0581ee33ae2ef0128ff0270.tar.bz2
air_mediahub-0c802141d6f83606e0581ee33ae2ef0128ff0270.zip
mplayer: adds support three state of repeat mode (all/one/none)
Change-Id: I5eee61ce78a29ae2b20db3e4b324579c4e113300 Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
-rw-r--r--src/view/mplayer.c110
1 files changed, 96 insertions, 14 deletions
diff --git a/src/view/mplayer.c b/src/view/mplayer.c
index 8c3b881..c1cafd0 100644
--- a/src/view/mplayer.c
+++ b/src/view/mplayer.c
@@ -38,6 +38,12 @@
#define PART_MUSIC_BTN "control_btn"
#define PLAY_BTN_LOC 2
+enum _repeat_state {
+ REPEAT_ALL,
+ REPEAT_ONE,
+ REPEAT_NONE
+};
+
struct _list_data {
app_media *am;
Elm_Object_Item *item;
@@ -48,6 +54,7 @@ struct _playlist {
Eina_List *list_org;
int cur;
bool shuffle;
+ enum _repeat_state repeat;
};
struct _priv {
@@ -227,6 +234,33 @@ static void _playlist_set_list(struct _priv *priv, bool shuffle, int index)
p->shuffle = shuffle;
}
+static void _playlist_set_repeat_mode(struct _priv *priv)
+{
+ struct _playlist *p;
+
+ p = &priv->playlist;
+ if (!p) {
+ _ERR("playlist is NULL");
+ return;
+ }
+
+ switch (p->repeat) {
+ case REPEAT_ALL:
+ p->repeat = REPEAT_ONE;
+ break;
+ case REPEAT_ONE:
+ p->repeat = REPEAT_NONE;
+ break;
+ case REPEAT_NONE:
+ p->repeat = REPEAT_ALL;
+ break;
+ default:
+ _ERR("Unknown repeat state");
+ p->repeat = REPEAT_ALL;
+ break;
+ }
+}
+
static void _update_info(struct _priv *priv, app_media_info *mi)
{
struct view_update_data vdata;
@@ -278,32 +312,69 @@ static void _mplayer_hide(struct _priv *priv)
ctl->ops->hide(ctl->handle);
}
-static void _mplayer_prev(struct _priv *priv)
+static bool _mplayer_prev(struct _priv *priv)
{
int total;
total = eina_list_count(priv->playlist.list);
- if (priv->playlist.cur == 0)
- priv->playlist.cur = total - 1;
- else
- priv->playlist.cur--;
+ switch (priv->playlist.repeat) {
+ case REPEAT_ALL:
+ if (priv->playlist.cur != 0)
+ priv->playlist.cur--;
+ else
+ priv->playlist.cur = total - 1;
+ break;
+ case REPEAT_NONE:
+ if (priv->playlist.cur != 0)
+ priv->playlist.cur--;
+ break;
+ case REPEAT_ONE:
+ break;
+ default:
+ _ERR("Unknown repeat state");
+ break;
+ }
_mplayer_show(priv);
+
+ return true;
}
-static void _mplayer_next(struct _priv *priv)
+static bool _mplayer_next(struct _priv *priv)
{
int total;
+ bool r;
total = eina_list_count(priv->playlist.list);
- if (priv->playlist.cur == total - 1)
- priv->playlist.cur = 0;
- else
- priv->playlist.cur++;
+ r = true;
+
+ switch (priv->playlist.repeat) {
+ case REPEAT_ALL:
+ if (priv->playlist.cur != total - 1)
+ priv->playlist.cur++;
+ else
+ priv->playlist.cur = 0;
+ break;
+ case REPEAT_NONE:
+ if (priv->playlist.cur != total - 1)
+ priv->playlist.cur++;
+ else {
+ priv->playlist.cur = 0;
+ r = false;
+ }
+ break;
+ case REPEAT_ONE:
+ break;
+ default:
+ _ERR("Unknown repeat state");
+ break;
+ }
_mplayer_show(priv);
+
+ return r;
}
static void _mplayer_set_current(struct _priv *priv, int index)
@@ -459,14 +530,18 @@ static void _player_stop(struct _priv *priv)
static void _player_complete_cb(void *data)
{
struct _priv *priv;
+ bool r;
if (!data)
return;
priv = data;
- _mplayer_next(priv);
- _player_next(priv);
+ r = _mplayer_next(priv);
+ if (r)
+ _player_next(priv);
+ else
+ _player_stop(priv);
}
static struct progressbar_ops _progressbar_ops = {
@@ -723,6 +798,7 @@ static void _add_playlist_item(struct _priv *priv)
static void _callback_music(void *data, const char *ev)
{
struct _priv *priv;
+ bool r;
if (!data || !ev)
return;
@@ -733,8 +809,11 @@ static void _callback_music(void *data, const char *ev)
_mplayer_prev(priv);
_player_next(priv);
} else if (!strcmp(ev, SRC_BTN_MUSIC_NEXT)) {
- _mplayer_next(priv);
- _player_next(priv);
+ r = _mplayer_next(priv);
+ if (r)
+ _player_next(priv);
+ else
+ _player_stop(priv);
} else if (!strcmp(ev, SRC_BTN_MUSIC_PLAY)) {
_player_play_pause(priv);
} else if (!strcmp(ev, SRC_BTN_MUSIC_SHUFFLE)) {
@@ -744,6 +823,8 @@ static void _callback_music(void *data, const char *ev)
_mplayer_set_current(priv, priv->playlist.cur);
_player_play(priv);
+ } else if (!strcmp(ev, SRC_BTN_MUSIC_REPEAT)) {
+ _playlist_set_repeat_mode(priv);
}
}
@@ -847,6 +928,7 @@ static Evas_Object *_create(Evas_Object *win, void *data)
priv->playlist.list_org = NULL;
priv->playlist.cur = 0;
priv->playlist.shuffle = false;
+ priv->playlist.repeat = REPEAT_ALL;
player = playermgr_create(NULL);
if (!player) {