From: Minkyu Kang Date: Wed, 15 Jul 2015 11:34:44 +0000 (+0900) Subject: music player: support play/prev/next X-Git-Tag: accepted/tizen/tv/20150728.070555~61 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f61176309266a47a30b136b50f1134337ad0a011;p=profile%2Ftv%2Fapps%2Fnative%2Fair_mediahub.git music player: support play/prev/next Change-Id: If18fa8fb9d5d87af51ef39f3292355e4f4e856e2 Signed-off-by: Minkyu Kang --- diff --git a/src/view/mplayer.c b/src/view/mplayer.c index 6a16e4b..90a89cb 100644 --- a/src/view/mplayer.c +++ b/src/view/mplayer.c @@ -73,6 +73,10 @@ static struct _btn_info btn_player[] = { }, }; +static void _player_play(struct _priv *priv); +static void _player_stop(struct _priv *priv); +static void _player_next(struct _priv *priv); + /* FIXME: test function */ static bool _media(media_info_h media_h, void *dt) { @@ -240,9 +244,91 @@ static struct progressbar_ops _progressbar_ops = { .get_value = _player_get_position, }; +static void _player_play(struct _priv *priv) +{ + app_media_info *mi; + player_state_e state; + + playermgr_get_state(priv->player, &state); + + switch (state) { + case PLAYER_STATE_PAUSED: + progressbar_resume(priv->progress); + playermgr_resume(priv->player); + break; + case PLAYER_STATE_PLAYING: + progressbar_pause(priv->progress); + playermgr_pause(priv->player); + break; + case PLAYER_STATE_IDLE: + case PLAYER_STATE_READY: + mi = _get_current_media_info(priv); + if (!mi) { + _ERR("failed to getting media info"); + return; + } + + progressbar_start(priv->progress); + playermgr_play(priv->player, mi->file_path, 0); + + break; + default: + _ERR("player was not created"); + break; + } +} + +static void _player_next(struct _priv *priv) +{ + app_media_info *mi; + player_state_e state; + + playermgr_get_state(priv->player, &state); + + switch (state) { + case PLAYER_STATE_PAUSED: + case PLAYER_STATE_IDLE: + case PLAYER_STATE_READY: + progressbar_stop(priv->progress); + playermgr_stop(priv->player); + break; + case PLAYER_STATE_PLAYING: + mi = _get_current_media_info(priv); + if (!mi) { + _ERR("failed to getting media info"); + return; + } + + playermgr_play(priv->player, mi->file_path, 0); + break; + default: + _ERR("player was not created"); + break; + } +} + +static void _player_stop(struct _priv *priv) +{ + struct controller *ctl; + + progressbar_stop(priv->progress); + playermgr_stop(priv->player); + + ctl = priv->ctl; + ctl->ops->signal(ctl->handle, PLAY_BTN_LOC, SIG_SET_PLAY); +} + static void _player_complete_cb(void *data) { - /* TODO */ + struct _priv *priv; + + if (!data) + return; + + priv = data; + + _mplayer_next(priv); + _player_next(priv); } static void _callback_music(void *data, const char *ev) @@ -256,10 +342,12 @@ static void _callback_music(void *data, const char *ev) if (!strcmp(ev, SRC_BTN_MUSIC_PREV)) { _mplayer_prev(priv); + _player_next(priv); } else if (!strcmp(ev, SRC_BTN_MUSIC_NEXT)) { _mplayer_next(priv); + _player_next(priv); } else if (!strcmp(ev, SRC_BTN_MUSIC_PLAY)) { - /* TODO */ + _player_play(priv); } }