summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2015-08-24 03:56:09 -0700
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2015-08-24 03:56:09 -0700
commitbb2b0a19118787567827e1f6ca9f71dac3b45cbf (patch)
treefe19d130a44c89a17ea1d7f1000a39f1eb854e23
parentf96da25b729ccd1d209ad3ac12bffeee2f0c419b (diff)
parent0512ebd1ba5eb907c133a9b1bd62e77556eafd43 (diff)
downloadair_mediahub-bb2b0a19118787567827e1f6ca9f71dac3b45cbf.tar.gz
air_mediahub-bb2b0a19118787567827e1f6ca9f71dac3b45cbf.tar.bz2
air_mediahub-bb2b0a19118787567827e1f6ca9f71dac3b45cbf.zip
Merge "viewer: adds support the remote controller" into tizen
-rw-r--r--src/view/viewer.c203
1 files changed, 157 insertions, 46 deletions
diff --git a/src/view/viewer.c b/src/view/viewer.c
index 276f9ee..e525765 100644
--- a/src/view/viewer.c
+++ b/src/view/viewer.c
@@ -650,60 +650,76 @@ static void _pop_view(struct _priv *priv)
ui_app_exit();
}
-static Eina_Bool _timeout_cb(void *data, int type, void *ei)
-{
- _hide_bar(data);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool _event_cb(void *data, int type, void *ei)
+static int _player_get_position(void *data)
{
struct _priv *priv;
if (!data)
- return ECORE_CALLBACK_PASS_ON;
+ return 0;
priv = data;
- if (type == ECORE_EVENT_KEY_DOWN) {
- Evas_Event_Key_Down *ev;
-
- if (!ei)
- return ECORE_CALLBACK_PASS_ON;
+ return playermgr_get_position(priv->player);
+}
- ev = ei;
+static void _player_set_position(struct _priv *priv, int position)
+{
+ int ms;
- if (!strcmp(ev->keyname, KEY_BACK) ||
- !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- if (priv->bar_show) {
- _pop_view(priv);
- return ECORE_CALLBACK_DONE;
- }
- }
- }
+ ms = position;
- _show_bar(data);
+ /* set to last position */
+ if (position == -1)
+ ms = playermgr_get_duration(priv->player) - 100;
- return ECORE_CALLBACK_PASS_ON;
+ playermgr_set_position(priv->player, ms, NULL, NULL);
}
-static int _player_get_position(void *data)
+static void _player_play_pause(struct _priv *priv)
{
- struct _priv *priv;
+ app_media_info *mi;
+ player_state_e state;
- if (!data)
- return 0;
+ playermgr_get_state(priv->player, &state);
- priv = data;
+ 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;
+ }
- return playermgr_get_position(priv->player);
+ _remove_thumbnail(priv);
+ _update_to_player(priv);
+
+ progressbar_start(priv->progress);
+ playermgr_play(priv->player, mi->file_path,
+ mi->video->position);
+
+ _add_to_recent(priv);
+
+ break;
+ default:
+ _ERR("player was not created");
+ break;
+ }
}
static void _player_play(struct _priv *priv)
{
app_media_info *mi;
player_state_e state;
+ struct controller *ctl;
playermgr_get_state(priv->player, &state);
@@ -713,8 +729,6 @@ static void _player_play(struct _priv *priv)
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:
@@ -738,6 +752,36 @@ static void _player_play(struct _priv *priv)
_ERR("player was not created");
break;
}
+
+ ctl = priv->viewer.ctl[priv->viewer.cur];
+ ctl->ops->signal(ctl->handle, PLAY_BTN_LOC, SIG_SET_PAUSE);
+ ctl->ops->focus(ctl->handle, PLAY_BTN_LOC, true);
+}
+
+static void _player_pause(struct _priv *priv)
+{
+ player_state_e state;
+ struct controller *ctl;
+
+ playermgr_get_state(priv->player, &state);
+
+ switch (state) {
+ case PLAYER_STATE_PLAYING:
+ progressbar_pause(priv->progress);
+ playermgr_pause(priv->player);
+ break;
+ case PLAYER_STATE_PAUSED:
+ case PLAYER_STATE_IDLE:
+ case PLAYER_STATE_READY:
+ break;
+ default:
+ _ERR("player was not created");
+ break;
+ }
+
+ ctl = priv->viewer.ctl[priv->viewer.cur];
+ ctl->ops->signal(ctl->handle, PLAY_BTN_LOC, SIG_SET_PLAY);
+ ctl->ops->focus(ctl->handle, PLAY_BTN_LOC, true);
}
static void _player_stop(struct _priv *priv)
@@ -767,11 +811,11 @@ static void _player_complete_cb(void *data)
priv = data;
_set_played_position(priv, 0);
- _player_stop(priv);
- if (priv->viewer.cur == VIEWER_MOVIE)
+ if (priv->viewer.cur == VIEWER_MOVIE) {
_pop_view(priv);
- else if (priv->viewer.cur == VIEWER_VIDEO) {
+ } else if (priv->viewer.cur == VIEWER_VIDEO) {
+ _player_stop(priv);
_viewer_show(priv);
_show_bar(data);
}
@@ -784,21 +828,18 @@ static struct progressbar_ops _progressbar_ops = {
static void _callback_movie(void *data, const char *ev)
{
struct _priv *priv;
- int ms;
if (!data || !ev)
return;
priv = data;
- if (!strcmp(ev, SRC_BTN_PREV)) {
- playermgr_set_position(priv->player, 0, NULL, NULL);
- } else if (!strcmp(ev, SRC_BTN_NEXT)) {
- ms = playermgr_get_duration(priv->player);
- playermgr_set_position(priv->player, ms - 500, NULL, NULL);
- } else if (!strcmp(ev, SRC_BTN_PLAY)) {
- _player_play(priv);
- }
+ if (!strcmp(ev, SRC_BTN_PREV))
+ _player_set_position(priv, 0);
+ else if (!strcmp(ev, SRC_BTN_NEXT))
+ _player_set_position(priv, -1);
+ else if (!strcmp(ev, SRC_BTN_PLAY))
+ _player_play_pause(priv);
}
static void _callback_photo(void *data, const char *ev)
@@ -832,8 +873,78 @@ static void _callback_video(void *data, const char *ev)
_player_stop(priv);
_viewer_next(priv);
} else if (!strcmp(ev, SRC_BTN_PLAY)) {
- _player_play(priv);
+ _player_play_pause(priv);
+ }
+}
+
+static Eina_Bool _timeout_cb(void *data, int type, void *ei)
+{
+ _hide_bar(data);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _event_cb(void *data, int type, void *ei)
+{
+ struct _priv *priv;
+
+ if (!data)
+ return ECORE_CALLBACK_PASS_ON;
+
+ priv = data;
+
+ if (type == ECORE_EVENT_KEY_DOWN) {
+ Evas_Event_Key_Down *ev;
+
+ if (!ei)
+ return ECORE_CALLBACK_PASS_ON;
+
+ ev = ei;
+
+ if (!strcmp(ev->keyname, KEY_BACK) ||
+ !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
+ if (priv->bar_show) {
+ _pop_view(priv);
+ return ECORE_CALLBACK_DONE;
+ }
+ } else if (!strcmp(ev->keyname, KEY_PLAY)) {
+ if (priv->viewer.cur != VIEWER_PHOTO)
+ _player_play(priv);
+ } else if (!strcmp(ev->keyname, KEY_PAUSE)) {
+ if (priv->viewer.cur != VIEWER_PHOTO)
+ _player_pause(priv);
+ } else if (!strcmp(ev->keyname, KEY_STOP)) {
+ if (priv->viewer.cur == VIEWER_MOVIE) {
+ _pop_view(priv);
+ return ECORE_CALLBACK_DONE;
+ } else if (priv->viewer.cur == VIEWER_VIDEO) {
+ _player_stop(priv);
+ _viewer_show(priv);
+ }
+ } else if (!strcmp(ev->keyname, KEY_NEXT)) {
+ if (priv->viewer.cur == VIEWER_MOVIE) {
+ _player_set_position(priv, -1);
+ } else if (priv->viewer.cur == VIEWER_PHOTO) {
+ _viewer_next(priv);
+ } else if (priv->viewer.cur == VIEWER_VIDEO) {
+ _player_stop(priv);
+ _viewer_next(priv);
+ }
+ } else if (!strcmp(ev->keyname, KEY_PREVIOUS)) {
+ if (priv->viewer.cur == VIEWER_MOVIE) {
+ _player_set_position(priv, 0);
+ } else if (priv->viewer.cur == VIEWER_PHOTO) {
+ _viewer_prev(priv);
+ } else if (priv->viewer.cur == VIEWER_VIDEO) {
+ _player_stop(priv);
+ _viewer_prev(priv);
+ }
+ }
}
+
+ _show_bar(data);
+
+ return ECORE_CALLBACK_PASS_ON;
}
static bool _ui_init(struct _priv *priv)