From 6f4317dab6807ba643e7b1d4b2404dc0d28fbf5e Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Wed, 16 Dec 2015 16:45:31 +0900 Subject: viewer: pop the view if something went wrong while playing video Change-Id: I03f53c94f9f6ce9dc274b1d9ccbe20b44f3de156 Signed-off-by: Minkyu Kang --- src/view/viewer.c | 66 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/src/view/viewer.c b/src/view/viewer.c index 4968fc4..2605716 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -41,6 +41,7 @@ #define VIEWER_TIMEOUT 3.0 #define VIEWER_SEPARATOR "/ " #define SLIDE_SHOW_INTERVAL 3.0 +#define ERROR_MESSAGE "Something went wrong." #define BTN_LOC_NONE -1 #define BTN_LOC_PREV 0 @@ -813,6 +814,14 @@ static void _pop_view(struct _priv *priv) viewmgr_pop_view(); } +static void _error_exit(struct _priv *priv) +{ + _pop_view(priv); + + util_add_notify(priv->win, STYLE_TOAST, STYLE_TOAST, + ERROR_MESSAGE, VIEWER_TIMEOUT); +} + static int _player_get_position(void *data) { struct _priv *priv; @@ -828,6 +837,7 @@ static int _player_get_position(void *data) static void _player_set_position(struct _priv *priv, int position) { int ms; + bool r; ms = position; @@ -835,7 +845,9 @@ static void _player_set_position(struct _priv *priv, int position) if (position == -1) ms = playermgr_get_duration(priv->player) - 100; - playermgr_set_position(priv->player, ms, NULL, NULL); + r = playermgr_set_position(priv->player, ms, NULL, NULL); + if (!r) + _error_exit(priv); } static void _player_play_pause(struct _priv *priv) @@ -849,11 +861,19 @@ static void _player_play_pause(struct _priv *priv) switch (state) { case PLAYER_STATE_PAUSED: progressbar_resume(priv->progress); - playermgr_resume(priv->player); + r = playermgr_resume(priv->player); + if (!r) { + _error_exit(priv); + return; + } break; case PLAYER_STATE_PLAYING: progressbar_pause(priv->progress); - playermgr_pause(priv->player); + r = playermgr_pause(priv->player); + if (!r) { + _error_exit(priv); + return; + } break; case PLAYER_STATE_IDLE: case PLAYER_STATE_READY: @@ -868,15 +888,19 @@ static void _player_play_pause(struct _priv *priv) r = playermgr_play(priv->player, mi->file_path, mi->video->position); - if (r) { - progressbar_start(priv->progress); - _update_info(priv, mi); + if (!r) { + _error_exit(priv); + return; } + progressbar_start(priv->progress); + _update_info(priv, mi); + break; default: _ERR("player was not created"); - break; + _error_exit(priv); + return; } } @@ -892,7 +916,11 @@ static void _player_play(struct _priv *priv) switch (state) { case PLAYER_STATE_PAUSED: progressbar_resume(priv->progress); - playermgr_resume(priv->player); + r = playermgr_resume(priv->player); + if (!r) { + _error_exit(priv); + return; + } break; case PLAYER_STATE_PLAYING: break; @@ -909,15 +937,19 @@ static void _player_play(struct _priv *priv) r = playermgr_play(priv->player, mi->file_path, mi->video->position); - if (r) { - progressbar_start(priv->progress); - _update_info(priv, mi); + if (!r) { + _error_exit(priv); + return; } + progressbar_start(priv->progress); + _update_info(priv, mi); + break; default: _ERR("player was not created"); - break; + _error_exit(priv); + return; } ctl = priv->viewer.ctl[priv->viewer.cur]; @@ -929,13 +961,18 @@ static void _player_pause(struct _priv *priv) { player_state_e state; struct controller *ctl; + bool r; playermgr_get_state(priv->player, &state); switch (state) { case PLAYER_STATE_PLAYING: progressbar_pause(priv->progress); - playermgr_pause(priv->player); + r = playermgr_pause(priv->player); + if (!r) { + _error_exit(priv); + return; + } break; case PLAYER_STATE_PAUSED: case PLAYER_STATE_IDLE: @@ -943,7 +980,8 @@ static void _player_pause(struct _priv *priv) break; default: _ERR("player was not created"); - break; + _error_exit(priv); + return; } ctl = priv->viewer.ctl[priv->viewer.cur]; -- cgit v1.2.3