summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2015-07-22 12:44:14 (GMT)
committerMinkyu Kang <mk7.kang@samsung.com>2015-07-22 12:44:14 (GMT)
commit1bc0c17a8ac78f2d9fc0a19f70e16449d3e55736 (patch)
tree15abb5fdf307dc524bb1cfde9ef24fce23f8d96f
parent449d32ceb112eac1b8d9cbc1343b5e61a5b40eee (diff)
downloadair_mediahub-resf/for/tizen.zip
air_mediahub-resf/for/tizen.tar.gz
air_mediahub-resf/for/tizen.tar.bz2
musicplayer: implement the complete callback at progressbar (workaround)resf/for/tizen
Since the complete callback of player have bug, we implemented it on progressbar Change-Id: I69f1afd6751b49a3523daf6fe80e5301a2049523 Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
-rw-r--r--include/util/progressbar.h1
-rw-r--r--src/util/progressbar.c27
-rw-r--r--src/view/mplayer.c20
3 files changed, 36 insertions, 12 deletions
diff --git a/include/util/progressbar.h b/include/util/progressbar.h
index 884761e..b788a3c 100644
--- a/include/util/progressbar.h
+++ b/include/util/progressbar.h
@@ -22,6 +22,7 @@ struct progressbar;
struct progressbar_ops {
int (*get_value)(void *data);
int (*set_value)(void *data);
+ void (*complete_cb)(void *data);
};
enum progressbar_time_format {
diff --git a/src/util/progressbar.c b/src/util/progressbar.c
index ed0a28f..3623016 100644
--- a/src/util/progressbar.c
+++ b/src/util/progressbar.c
@@ -26,6 +26,8 @@
#define SLIDER_STEP 0.03
#define PROGRESSBAR_INTERVAL 0.1
+#define COMPLETE_INTERVAL 1.0
+#define COMPLETE_BUFFER 500
struct progressbar {
Evas_Object *base;
@@ -41,6 +43,7 @@ struct progressbar {
char *str_separator;
enum progressbar_time_format fmt;
+ int duration;
};
static void _update_progress_info(struct progressbar *m, int position)
@@ -64,6 +67,21 @@ static void _update_time_info(struct progressbar *m, int position, int duration)
_update_progress_info(m, position);
}
+static Eina_Bool _complete_cb(void *data)
+{
+ struct progressbar *m;
+
+ if (!data)
+ return ECORE_CALLBACK_CANCEL;
+
+ m = data;
+
+ if (m->ops->complete_cb)
+ m->ops->complete_cb(m->ops_data);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
static Eina_Bool _timer_cb(void *data)
{
struct progressbar *m;
@@ -79,6 +97,13 @@ static Eina_Bool _timer_cb(void *data)
elm_slider_value_set(m->slider, position);
_update_progress_info(m, position);
+ if (position + COMPLETE_BUFFER > m->duration) {
+ ecore_timer_add(COMPLETE_INTERVAL, _complete_cb, m);
+ m->timer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+
return ECORE_CALLBACK_RENEW;
}
@@ -167,6 +192,8 @@ void progressbar_reset(struct progressbar *m, int position, int duration)
return;
}
+ m->duration = duration;
+
elm_slider_min_max_set(m->slider, 0, duration);
elm_slider_step_set(m->slider, SLIDER_STEP);
elm_slider_value_set(m->slider, position);
diff --git a/src/view/mplayer.c b/src/view/mplayer.c
index a438cf1..c5c77f8 100644
--- a/src/view/mplayer.c
+++ b/src/view/mplayer.c
@@ -124,7 +124,6 @@ static void _draw_music_info(struct _priv *priv, app_media_info *mi)
static void _draw_progressbar(struct _priv *priv, app_media_info *mi)
{
- progressbar_reset(priv->progress, 0, mi->audio->duration);
progressbar_show(priv->progress);
}
@@ -152,6 +151,9 @@ static void _update_info(struct _priv *priv, app_media_info *mi)
{
struct view_update_data vdata;
+ /* update progressbar */
+ progressbar_reset(priv->progress, 0, mi->audio->duration);
+
/* update history */
app_contents_recent_add(CONTENTS_MEDIA, mi->media_id);
@@ -250,10 +252,6 @@ static int _player_get_position(void *data)
return playermgr_get_position(priv->player);
}
-static struct progressbar_ops _progressbar_ops = {
- .get_value = _player_get_position,
-};
-
static void _player_play_pause(struct _priv *priv)
{
app_media_info *mi;
@@ -388,6 +386,11 @@ static void _player_complete_cb(void *data)
_player_next(priv);
}
+static struct progressbar_ops _progressbar_ops = {
+ .get_value = _player_get_position,
+ .complete_cb = _player_complete_cb,
+};
+
static void _callback_music(void *data, const char *ev)
{
struct _priv *priv;
@@ -713,13 +716,6 @@ static Evas_Object *_create(Evas_Object *win, void *data)
return NULL;
}
- r = playermgr_set_completed_cb(player, _player_complete_cb, priv);
- if (!r) {
- _ERR("failed to set callback");
- playermgr_destroy(player);
- return NULL;
- }
-
priv->player = player;
r = _ui_init(priv);