initial tizen_2.0_beta
[apps/core/preloaded/music-player.git] / src / view / mp-play-view.c
1 /*
2  * Copyright 2012         Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *  http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <glib.h>
18 #include "music.h"
19 #include "mp-play-view.h"
20 #include "mp-player-control.h"
21 #include "mp-play.h"
22 #include "mp-item.h"
23 #include "mp-player-drm.h"
24 #include "mp-smart-event-box.h"
25 #include "mp-file-tag-info.h"
26 #include "mp-player-mgr.h"
27 #include "mp-player-debug.h"
28 #include "mp-play-list.h"
29 #include "mp-util.h"
30 #include "mp-app.h"
31 #include "mp-menu.h"
32 #include "mp-widget.h"
33 #include "mp-popup.h"
34 #include "mp-ug-launch.h"
35 #include "mp-streaming-mgr.h"
36
37 #include "mp-minicontroller.h"
38 #include "mp-setting-ctrl.h"
39
40 #ifdef MP_SOUND_PLAYER
41 #include "sp-view-manager.h"
42 #else
43 #include "mp-common.h"
44 #include "mp-library.h"
45 #endif
46
47 #ifndef ABS
48 #define ABS(x) ((x) < 0 ? -(x) : (x))
49 #endif
50
51 #define MAIN_W                  480
52 #define MAIN_H                  800
53
54 #define HD_SCREEN_WIDTH 720.0
55 #define HD_INFO_RIGHT_WIDTH 550.0
56 #define HD_ALBUM_IMAGE_H_SCALE 720/1280
57
58 #define PROGRESS_BAR_POSITION 20        /*80 */
59 #define LS_PROGRESS_BAR_POSITION 340    /*400 */
60
61 #define CTR_EDJ_SIG_SRC "ctrl_edj"
62 #define CTR_PROG_SIG_SRC "ctrl_prog"
63 #define PLAYVIEW_TRANSIT_TIME (0.35)
64 #define FAVOUR_LONG_PRESS_TIME (1.5)
65
66 #define ALBUMART_IMAGE_COLOR 160
67 #define ALBUMART_IMAGE_SHADOW_RGBA 60, 60, 60, 123
68 #define ALBUMART_IMAGE_SHADOW_RGBA1 100, 100, 100, 123
69 #define ALBUMART_IMAGE_SHADOW_RGBA2 0, 0, 0, 123
70 #define EVAS_OBJ_SHOW(obj) if(obj){evas_object_show(obj);}
71 #define EVAS_OBJ_HIDE(obj) if(obj){evas_object_hide(obj);}
72 #define EVAS_OBJ_MOVE(obj, x, y) if(obj){evas_object_move(obj, x, y);}
73 static void _mp_play_view_set_album_art(void *data, char *file_path);
74 static void _mp_play_view_album_art_update(void *data);
75 Evas_Object *_mp_play_view_create_bg_map(void *data, Evas_Object * parents, music_list_item * current_item);
76
77 static void _mp_play_progress_val_set(void *data, double position);
78 static bool _mp_play_view_init_progress_bar(void *data);
79 static bool _mp_play_view_transit_by_item(void *data, struct music_list_item *it, bool move_left);
80 static void _mp_play_view_destory_cb(void *data, Evas * e, Evas_Object * obj, void *event_info);
81 static Evas_Object *_mp_play_view_create_ctrl_layout(void *data, Evas_Object * parents, Evas_Object ** progress,
82                                                      bool remove_signal);
83 #ifndef MP_SOUND_PLAYER
84 static void _mp_play_view_start_request(void *data, Evas_Object * obj, void *event_info);
85 #endif
86 static void _mp_play_view_glist_free_cb(gpointer data);
87
88
89 static void
90 _mp_play_view_init(void *data)
91 {
92         startfunc;
93
94         struct appdata *ad = (struct appdata *)data;
95         MP_CHECK(ad);
96
97         mp_playing_view *playing_view = ad->playing_view;
98         MP_CHECK(playing_view);
99
100         ad->show_optional_menu = FALSE;
101
102         playing_view->layout = NULL;
103         playing_view->play_view = NULL;
104         playing_view->play_control = NULL;
105         playing_view->play_menu = NULL; //information, srs, shuffle, repeat
106         playing_view->play_progressbar = NULL;
107         playing_view->play_info = NULL;
108         playing_view->albumart_img = NULL;
109
110         playing_view->albumart_bg = NULL;
111         playing_view->albumart_image_reflection = NULL;
112         playing_view->pre_albumart_image_reflection = NULL;
113         playing_view->flick_direction = 0;
114         ad->volume_long_pressed = false;
115
116         playing_view->play_view_next = NULL;
117         playing_view->x = 0;
118         playing_view->y = 0;
119         playing_view->favour_longpress = 0;
120         playing_view->favourite_timer = NULL;
121         playing_view->progressbar_timer = NULL;
122
123         playing_view->play_view_screen_mode = MP_SCREEN_MODE_PORTRAIT;
124
125         playing_view->transition_state = false;
126         playing_view->b_play_all = false;
127
128         endfunc;
129
130         return;
131 }
132
133 void
134 mp_play_view_back_clicked_cb(void *data, Evas_Object * obj, void *event_info)
135 {
136         struct appdata *ad = (struct appdata *)data;
137         MP_CHECK(ad);
138         mp_retm_if(ad->navi_effect_in_progress, "navi effect in progress");
139
140         DEBUG_TRACE("ad->loadtype: %d", ad->loadtype);
141
142         //reset mute flag
143         ad->mute_flag = false;
144         if (ad->playing_view)
145                 mp_evas_object_del(ad->playing_view->play_icon);
146
147         {
148 #ifdef MP_SOUND_PLAYER
149                 mp_play_view_unswallow_info_ug_layout(ad);
150                 sp_view_mgr_pop_view_content(ad->view_mgr, FALSE);
151 #else
152                 view_data_t *view_data = evas_object_data_get(ad->naviframe, "view_data");
153                 MP_CHECK(view_data);
154                 mp_view_manager_pop_view_content(view_data, FALSE, FALSE);
155
156                 if (ad->music_setting_change_flag)
157                 {
158                         mp_util_set_library_controlbar_items(ad);
159                         ad->music_setting_change_flag = false;
160                 }
161 #endif
162         }
163         if (ad->buffering_popup)
164                 mp_streaming_mgr_buffering_popup_control(ad, false);
165         evas_object_smart_callback_del(obj, "clicked", mp_play_view_back_clicked_cb);
166
167         return;
168 }
169
170 static void
171 _mp_play_view_clear_animator(struct appdata *ad)
172 {
173         MP_CHECK(ad);
174         if(ad->minfo_ani)
175         {
176                 ecore_animator_del(ad->minfo_ani);
177                 ad->minfo_ani = NULL;
178         }
179
180         if(ad->minfo_list)
181         {
182                 g_list_free_full(ad->minfo_list, _mp_play_view_glist_free_cb);
183                 ad->minfo_list = NULL;
184         }
185 }
186
187 void
188 mp_play_view_info_back_cb(void *data, Evas_Object * obj, void *event_info)
189 {
190         startfunc;
191         struct appdata *ad = (struct appdata *)data;
192         MP_CHECK(ad);
193         mp_retm_if(ad->navi_effect_in_progress, "navi effect in progress");
194         ad->info_click_flag = FALSE;
195         mp_playing_view *playing_view = ad->playing_view;
196         //show albumart_image_reflection
197         if (playing_view && playing_view->albumart_image_reflection)
198         {
199                 evas_object_show(playing_view->albumart_image_reflection);
200                 evas_object_show(playing_view->albumart_image);
201         }
202         if(ad->info_ug)
203         {
204                 int first_view = (int)evas_object_data_get(ad->info_ug_layout, "first_view");
205                 if(first_view)
206                 {
207                         ad->info_back_play_view_flag = TRUE;
208 #ifdef MP_SOUND_PLAYER
209                         mp_play_view_unswallow_info_ug_layout(ad);
210                         sp_view_mgr_pop_view_content(ad->view_mgr, FALSE);
211 #else
212                         view_data_t *view_data = evas_object_data_get(ad->naviframe, "view_data");
213                         mp_view_manager_pop_view_content(view_data, FALSE, FALSE);
214 #endif
215                         if (playing_view)
216                                 playing_view->play_info = NULL;
217                 }
218                 else
219                 {
220                         ad->info_back_play_view_flag = FALSE;
221                         mp_ug_send_message(ad, MP_UG_MESSAGE_BACK);
222                 }
223         }
224         else
225         {
226                 _mp_play_view_clear_animator(ad);
227                 ad->info_back_play_view_flag = TRUE;
228 #ifdef MP_SOUND_PLAYER
229                 mp_play_view_unswallow_info_ug_layout(ad);
230                 sp_view_mgr_pop_view_content(ad->view_mgr, FALSE);
231 #else
232                 view_data_t *view_data = evas_object_data_get(ad->naviframe, "view_data");
233                 mp_view_manager_pop_view_content(view_data, FALSE, FALSE);
234 #endif
235                 if (playing_view)
236                         playing_view->play_info = NULL;
237         }
238         endfunc;
239         return;
240 }
241
242 /* callback function when click "album" image*/
243 static void
244 _mp_play_view_sb_click_info_albumart(void *data, Evas * e, Evas_Object * obj, void *event_info)
245 {
246         startfunc;
247         struct appdata *ad = (struct appdata *)data;
248         MP_CHECK(ad);
249         mp_play_view_info_back_cb(ad, NULL, NULL);
250         endfunc;
251 }
252
253 typedef struct
254 {
255         char *header;
256         char *detail;
257 }mp_media_info_t;
258
259 static char *
260 _mp_play_view_info_gl_label_get(void *data, Evas_Object * obj, const char *part)
261 {
262         mp_media_info_t *info = (mp_media_info_t *)data;
263         char *text;
264
265         if (!g_strcmp0(part, "elm.text.1"))
266         {
267                 MP_CHECK_NULL(info);
268                 DEBUG_TRACE("%s", info->header);
269                 if(info->header && strstr(info->header, "IDS_COM"))
270                         text = GET_SYS_STR(info->header);
271                 else
272                         text = GET_STR(info->header);
273                 return g_strdup(text);
274         }
275         else if (!g_strcmp0(part, "elm.text.2"))
276         {
277                 MP_CHECK_NULL(info);
278                 if(info->detail && strstr(info->detail, "IDS_COM"))
279                         text = GET_SYS_STR(info->detail);
280                 else
281                         text = GET_STR(info->detail);
282                 return g_strdup(text);
283         }
284
285         return NULL;
286 }
287
288 static void
289 _mp_play_view_info_gl_item_del(void *data, Evas_Object * obj)
290 {
291         mp_media_info_t *info = data;
292         MP_CHECK(info);
293         IF_FREE(info->header);
294         IF_FREE(info->detail);
295         free(info);
296 }
297
298 static Elm_Genlist_Item_Class info_view_info_item_class = {
299         .version = ELM_GENGRID_ITEM_CLASS_VERSION,
300         .refcount = 0,
301         .delete_me = EINA_FALSE,
302         .item_style = "multiline/music_player/info",
303         .func.text_get = _mp_play_view_info_gl_label_get,
304         .func.del = _mp_play_view_info_gl_item_del,
305         .func.content_get = NULL,
306 };
307
308 static Eina_Bool
309 _ecore_animator_cb(void *data)
310 {
311         struct appdata *ad = NULL;
312         Elm_Object_Item *item;
313
314         ad = data;
315         MP_CHECK_FALSE(ad);
316
317         if(ad->minfo_list)
318         {
319                 ad->minfo_list = g_list_first(ad->minfo_list);
320
321                 item = elm_genlist_item_append(ad->minfo_genlist, &info_view_info_item_class,
322                                                        ad->minfo_list->data,
323                                                        NULL,
324                                                        ELM_GENLIST_ITEM_NONE,
325                                                        NULL, NULL);
326                 if(item)
327                         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
328
329                 mp_language_mgr_register_genlist_item(item);
330
331                 ad->minfo_list = g_list_delete_link(ad->minfo_list, ad->minfo_list);
332                 return EINA_TRUE;
333         }
334
335         ad->minfo_ani = NULL;
336         return EINA_FALSE;
337
338 }
339
340 static void
341 _mp_play_view_create_info_item(Evas_Object * genlist, char *header, char *detail)
342 {
343         MP_CHECK(genlist);
344
345         struct appdata *ad =  evas_object_data_get(genlist, "ad");
346         MP_CHECK(ad);
347
348         mp_media_info_t *info = calloc(1, sizeof(mp_media_info_t));
349         MP_CHECK(info);
350         info->header = g_strdup(header);
351         info->detail= g_strdup(detail);
352
353         if(!ad->minfo_ani)
354         {
355                 DEBUG_TRACE("create animator");
356                 ad->minfo_ani = ecore_animator_add(_ecore_animator_cb, ad);
357                 ad->minfo_genlist = genlist;
358         }
359
360         ad->minfo_list = g_list_append(ad->minfo_list, info);
361
362 }
363
364 static void
365 _mp_play_view_glist_free_cb(gpointer data)
366 {
367         startfunc;
368         _mp_play_view_info_gl_item_del(data, NULL);
369 }
370
371 static void
372 _mp_play_view_append_drm_info(Evas_Object *genlist, const char *path)
373 {
374         startfunc;
375         MP_CHECK(genlist);
376         MP_CHECK(path);
377
378         GList *rs_list = mp_drm_get_right_status(path);
379         if (rs_list) {
380                 mp_debug("show right_status");
381                 GList *current = rs_list;
382                 while (current) {
383                         mp_drm_right_status_t *rs = current->data;
384                         if (rs)
385                                 _mp_play_view_create_info_item(genlist,
386                                                               rs->type,
387                                                               rs->validity);
388
389                         current = current->next;
390                 }
391
392                 mp_drm_free_right_status(rs_list);
393                 rs_list = NULL;
394         }
395 }
396
397 static Evas_Object *
398 _mp_play_view_create_info_detail(Evas_Object * parent, void *data)
399 {
400         struct appdata *ad = (struct appdata *)data;
401         MP_CHECK_NULL(ad);
402         music_list_item *cur_item = mp_play_list_get_current_item(ad->playing_list);
403         MP_CHECK_NULL(cur_item);
404
405         int ret = 0;
406         Evas_Object *genlist;
407
408         mp_media_info_h svc_audio_item;
409         char *pathname = NULL, *title = NULL, *album = NULL, *artist = NULL, *thumbname = NULL, *genre = NULL;
410         char *author = NULL, *copyright = NULL, *format = NULL, *track_num = NULL;
411         int duration = 0;
412
413         {
414                 ret = mp_media_info_create(&svc_audio_item, cur_item->key_id);
415
416                 mp_media_info_get_file_path(svc_audio_item, &pathname);
417                 mp_media_info_get_title(svc_audio_item, &title);
418                 mp_media_info_get_album(svc_audio_item, &album);
419                 mp_media_info_get_artist(svc_audio_item, &artist);
420                 mp_media_info_get_thumbnail_path(svc_audio_item, &thumbname);
421                 mp_media_info_get_genre(svc_audio_item, &genre);
422                 mp_media_info_get_copyright(svc_audio_item, &copyright);
423                 mp_media_info_get_composer(svc_audio_item, &author);
424                 mp_media_info_get_duration(svc_audio_item, &duration);
425                 mp_media_info_get_track_num(svc_audio_item, &track_num);
426                 mp_media_info_get_format(svc_audio_item, &format);
427         }
428
429         _mp_play_view_clear_animator(ad);
430
431         genlist = elm_genlist_add(parent);
432         MP_CHECK_NULL(genlist);
433         evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
434         evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
435         elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
436         evas_object_data_set(genlist, "ad", ad);
437
438         if (ret == 0)
439         {
440
441                 if (artist && strlen(artist))
442                         _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_ARTIST"), artist);
443
444                 _mp_play_view_create_info_item(genlist, ("IDS_COM_BODY_DETAILS_TITLE"), title);
445
446                 if (album && strlen(album))
447                          _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_ALBUM"), album);
448
449                 char duration_format[10] = { 0, };
450                 int dur_sec = duration / 1000;
451                 int sec = dur_sec % 60;
452                 int min = dur_sec / 60;
453                 snprintf(duration_format, sizeof(duration_format), "%02u:%02u", min, sec);
454
455                 _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_TRACK_LENGTH"),
456                                                               duration_format);
457
458
459                 if (genre && strlen(genre))
460                          _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_GENRE"), genre);
461
462                 if (author && strlen(author))
463                         _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_AUTHOR"), author);
464
465                 if (copyright && strlen(copyright))
466                          _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_COPYRIGHT"), copyright);
467
468                 {
469                         if (mp_drm_get_description(ad, cur_item->filename))
470                                 _mp_play_view_create_info_item(genlist,
471                                                                               ("IDS_MUSIC_BODY_DESCRIPTION"),
472                                                                               ad->drm_info.description);
473                         else
474                                 _mp_play_view_create_info_item(genlist,
475                                                                               ("IDS_MUSIC_BODY_DESCRIPTION"),
476                                                                               "-");
477
478
479                         if (ad->drm_info.forward)
480                                 _mp_play_view_create_info_item(genlist,
481                                                                               ("IDS_MUSIC_BODY_FORWARDING"),
482                                                                               ("IDS_MUSIC_BODY_POSSIBLE"));
483                         else
484                                 _mp_play_view_create_info_item(genlist,
485                                                                               ("IDS_MUSIC_BODY_FORWARDING"),
486                                                                               ("IDS_MUSIC_BODY_IMPOSSIBLE"));
487
488                         /* right status */
489                         _mp_play_view_append_drm_info(genlist, cur_item->filename);
490                 }
491
492                 if (track_num && strlen(track_num))
493                 {
494                          _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_TRACK_NUMBER"), track_num);
495                 }
496
497                 if (format && strlen(format))
498                 {
499
500                         _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_FORMAT"), format);
501
502                 }
503
504                         _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_MUSIC_LOCATION"),
505                                                               cur_item->filename);
506         }
507         else
508         {
509                 mp_tag_info_t tag_info;
510                 mp_file_tag_info_get_all_tag(cur_item->filename, &tag_info);
511
512                 if (tag_info.artist && strlen(tag_info.artist))
513                 {
514
515                                 _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_ARTIST"),
516                                                                       tag_info.artist);
517
518                 }
519
520                 if (tag_info.title && strlen(tag_info.title))
521                 {
522
523                                 _mp_play_view_create_info_item(genlist, ("IDS_COM_BODY_DETAILS_TITLE"),
524                                                                       tag_info.title);
525
526                 }
527
528                 if (tag_info.album && strlen(tag_info.album))
529                 {
530
531                                 _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_ALBUM"),
532                                                                       tag_info.album);
533
534                 }
535
536                 char duration_format[10] = { 0, };
537                 int dur_sec = tag_info.duration / 1000;
538                 int sec = dur_sec % 60;
539                 int min = dur_sec / 60;
540                 snprintf(duration_format, sizeof(duration_format), "%02u:%02u", min, sec);
541
542
543                         _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_TRACK_LENGTH"),
544                                                               duration_format);
545
546
547                 if (tag_info.genre && strlen(tag_info.genre))
548                 {
549
550                                 _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_GENRE"),
551                                                                       tag_info.genre);
552
553                 }
554
555                 if (tag_info.author && strlen(tag_info.author))
556                 {
557
558                                 _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_AUTHOR"),
559                                                                       tag_info.author);
560
561                 }
562
563                 if (tag_info.copyright && strlen(tag_info.copyright))
564                 {
565
566                                 _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_COPYRIGHT"), tag_info.copyright);
567
568                 }
569
570                 {
571                         if (mp_drm_get_description(ad, cur_item->filename))
572
573                                         _mp_play_view_create_info_item(genlist,
574                                                                               ("IDS_MUSIC_BODY_DESCRIPTION"),
575                                                                               ad->drm_info.description);
576                         else
577
578                                         _mp_play_view_create_info_item(genlist,
579                                                                               ("IDS_MUSIC_BODY_DESCRIPTION"),
580                                                                               "-");
581
582
583                         if (ad->drm_info.forward)
584
585                                         _mp_play_view_create_info_item(genlist,
586                                                                               ("IDS_MUSIC_BODY_FORWARDING"),
587                                                                               ("IDS_MUSIC_BODY_POSSIBLE"));
588                         else
589
590                                         _mp_play_view_create_info_item(genlist,
591                                                                               ("IDS_MUSIC_BODY_FORWARDING"),
592                                                                               ("IDS_MUSIC_BODY_IMPOSSIBLE"));
593
594                         /* right status */
595                         _mp_play_view_append_drm_info(genlist, cur_item->filename);
596                 }
597
598                 if (tag_info.track && strlen(tag_info.track))
599                 {
600                         if (!strstr(tag_info.track, "-") && g_strcmp0(tag_info.track, "0"))
601                         {
602
603                                         _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_TRACK_NUMBER"),
604                                                                               tag_info.track);
605
606                         }
607                 }
608
609                 if (tag_info.rating && strlen(tag_info.rating))
610                 {
611
612                                 _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_PARENT_RATING"),
613                                                                       tag_info.rating);
614
615                 }
616
617                 GString *format = g_string_new("");
618                 if (tag_info.audio_bitrate > 0)
619                         g_string_append_printf(format, "%dkbps ", tag_info.audio_bitrate / 1000);
620
621                 if (tag_info.audio_samplerate > 0)
622                         g_string_append_printf(format, "%.1fkHz ", (double)tag_info.audio_samplerate / 1000);
623
624                 if (tag_info.audio_channel > 0)
625                         g_string_append_printf(format, "%dch", tag_info.audio_channel);
626
627                 if (format)
628                 {
629
630                                 _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_FORMAT"),
631                                                                       format->str);
632
633                         g_string_free(format, TRUE);
634                 }
635
636
637                         _mp_play_view_create_info_item(genlist, ("IDS_MUSIC_BODY_MUSIC_LOCATION"),
638                                                               cur_item->filename);
639
640
641                 mp_file_tag_free(&tag_info);
642         }
643
644         evas_object_show(genlist);
645
646         mp_media_info_destroy(svc_audio_item);
647         elm_object_part_content_set(parent, "mi_content", genlist);
648         return genlist;
649 }
650
651 static void
652 mp_play_view_create_info_contents(Evas_Object * parent, void *data)
653 {
654         struct appdata *ad = (struct appdata *)data;
655         MP_CHECK(ad);
656         mp_playing_view *playing_view = ad->playing_view;
657         MP_CHECK(playing_view);
658         music_list_item *cur_item = mp_play_list_get_current_item(ad->playing_list);
659         MP_CHECK(cur_item);
660
661         /***********create left area start********************/
662         Evas_Object *info_view_left_area = mp_common_load_edj(parent, PLAY_VIEW_EDJ_NAME, "info_view_left_area");
663         MP_CHECK(info_view_left_area);
664         elm_object_part_content_set(parent, "left_area", info_view_left_area);
665         evas_object_show(info_view_left_area);
666
667         Evas_Object *video_play_img = elm_image_add(info_view_left_area);
668         elm_image_file_set(video_play_img, ICON_DIRECTORY "/music_player/T02_Video_play.png", NULL);
669         elm_object_part_content_set(info_view_left_area, "video_play_img", video_play_img);
670         evas_object_show(video_play_img);
671
672         //add current albumart image
673         Evas_Object *album_image = elm_image_add(info_view_left_area);
674         if (strlen(cur_item->albumart) && mp_util_is_image_valid(ad->evas, cur_item->albumart))
675         {
676                 elm_image_file_set(album_image, cur_item->albumart, NULL);
677         }
678         else
679         {
680                 elm_image_file_set(album_image, DEFAULT_THUMBNAIL, NULL);
681         }
682         elm_object_part_content_set(info_view_left_area, "left_album_bg", album_image);
683         evas_object_show(album_image);
684         evas_object_event_callback_add(video_play_img, EVAS_CALLBACK_MOUSE_DOWN, NULL, NULL);
685         evas_object_event_callback_add(video_play_img, EVAS_CALLBACK_MOUSE_MOVE, NULL, NULL);
686         evas_object_event_callback_add(video_play_img, EVAS_CALLBACK_MOUSE_UP,
687                                        _mp_play_view_sb_click_info_albumart, ad);
688         /***********create left area end********************/
689
690         /***********create right area start********************/
691         Evas_Object *right_base_box = mp_common_load_edj(parent, PLAY_VIEW_EDJ_NAME, "base_box_no_xml");
692         MP_CHECK(right_base_box);
693         elm_object_part_content_set(parent, "base_box", right_base_box);
694         evas_object_show(right_base_box);
695
696         Evas_Object *right_base_box_detail =
697                 mp_common_load_edj(right_base_box, PLAY_VIEW_EDJ_NAME, "mi_base_box_detail");
698         MP_CHECK(right_base_box_detail);
699         elm_object_part_content_set(right_base_box, "no_sim_media_content", right_base_box_detail);
700         evas_object_show(right_base_box_detail);
701         edje_object_part_text_set(_EDJ(right_base_box_detail), "title", GET_STR("IDS_MUSIC_BODY_DETAILS_MEADIA_INFO"));
702         mp_language_mgr_register_object(right_base_box_detail, OBJ_TYPE_EDJE_OBJECT, "title", "IDS_MUSIC_BODY_DETAILS_MEADIA_INFO");
703         Evas_Object *item = _mp_play_view_create_info_detail(right_base_box_detail, ad);
704         MP_CHECK(item);
705         elm_object_part_content_set(right_base_box_detail, "mi_scroller", item);
706         /***********create right area end********************/
707
708         //add scroller to right area
709         elm_object_part_content_set(parent, "no_xml_no_sim_detail_scroller", right_base_box_detail);
710 }
711
712 static void
713 _mp_play_view_popup_bt_cb(void *data, Evas_Object * obj, void *event_info)
714 {
715         DEBUG_TRACE_FUNC();
716         struct appdata *ad = (struct appdata *)data;
717
718         int ret = sound_manager_set_active_route(SOUND_ROUTE_OUT_BLUETOOTH);
719         if (ret != SOUND_MANAGER_ERROR_NONE)
720                 WARN_TRACE("Error: sound_manager_set_route_policy(0x%x)", ret);
721         else
722                 elm_radio_value_set(ad->radio_group, MP_SND_PATH_BT);
723
724         mp_popup_destroy(ad);
725 }
726
727 static void
728 _mp_play_view_popup_headphone_cb(void *data, Evas_Object * obj, void *event_info)
729 {
730         DEBUG_TRACE_FUNC();
731         struct appdata *ad = (struct appdata *)data;
732
733         int ret = sound_manager_set_active_route(SOUND_ROUTE_OUT_WIRED_ACCESSORY);
734         if (ret != SOUND_MANAGER_ERROR_NONE)
735                 WARN_TRACE("Error: sound_manager_set_route_policy(0x%x)", ret);
736         else
737                 elm_radio_value_set(ad->radio_group, MP_SND_PATH_EARPHONE);
738
739         mp_popup_destroy(ad);
740 }
741
742 //2 merge play view at 20110118
743 static void
744 _mp_play_view_popup_speaker_cb(void *data, Evas_Object * obj, void *event_info)
745 {
746         DEBUG_TRACE_FUNC();
747         struct appdata *ad = (struct appdata *)data;
748
749         int ret = 0;
750         ret = sound_manager_set_active_route(SOUND_ROUTE_OUT_SPEAKER);
751         if (ret != SOUND_MANAGER_ERROR_NONE)
752                 WARN_TRACE("Error: sound_manager_set_route_policy(0x%x)", ret);
753         else
754                 elm_radio_value_set(ad->radio_group, MP_SND_PATH_SPEAKER);
755
756         mp_popup_destroy(ad);
757 }
758
759 static void
760 _mp_play_view_append_snd_path_device(struct appdata *ad, char *bt_name, int bt_connected, int earjack, Evas_Object *popup)
761 {
762         MP_CHECK(ad);
763         MP_CHECK(popup);
764
765         if (bt_connected)
766                 mp_genlist_popup_item_append(popup, bt_name, ad->radio_group, _mp_play_view_popup_bt_cb, ad);
767
768         if (earjack)
769                 mp_genlist_popup_item_append(popup, GET_SYS_STR("IDS_COM_OPT_HEADPHONES_ABB"), ad->radio_group, _mp_play_view_popup_headphone_cb, ad);
770
771         mp_genlist_popup_item_append(popup, GET_SYS_STR("IDS_COM_OPT_SPEAKER_ABB"), ad->radio_group, _mp_play_view_popup_speaker_cb, ad);
772
773         mp_util_get_sound_path(&(ad->snd_path));
774 }
775
776 void
777 mp_play_view_update_snd_path(struct appdata *ad)
778 {
779         startfunc;
780         MP_CHECK(ad);
781
782         bool popup_exist = false;
783         bool bt_connected = false;
784         int earjack = 0;
785         static char *bt_name;
786         int ret = 0;
787         Evas_Object *popup = NULL;
788
789         popup = ad->popup[MP_POPUP_GENLIST];
790         if(popup)
791         {
792                 popup_exist = evas_object_data_get(popup, "sound_path");
793         }
794
795         //update or destroy popup..
796         if(popup_exist)
797         {
798                 IF_FREE(bt_name);
799                 ret = sound_manager_get_a2dp_status(&bt_connected, &bt_name);
800                 if (ret != SOUND_MANAGER_ERROR_NONE)
801                 {
802                         WARN_TRACE("Fail to sound_manager_get_a2dp_status ret = [%d]", ret);
803                 }
804                 if (vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack))
805                         WARN_TRACE("Earjack state get Fail...");
806
807                 if (!bt_connected && !earjack)
808                 {
809                         evas_object_del(popup);
810                 }
811                 else
812                 {
813                         // TODO: updating list is not working now.. there is timing issue... complete it after MMFW support..
814                         evas_object_del(popup);
815                 }
816         }
817
818         //update button
819         mp_play_view_set_snd_path_sensitivity(ad);
820
821 }
822
823 void
824 mp_play_view_set_snd_path_cb(void *data, Evas_Object *obj, void *event_info)
825 {
826         startfunc;
827
828         struct appdata *ad = (struct appdata *)data;
829
830         Evas_Object *group = NULL;
831         Evas_Object *popup = NULL;
832
833         int ret = 0;
834         bool bt_connected = false;
835         int earjack = 0;
836
837         // use bt_name as static. bt_name can be used again in gl_label_get function when genlist of popup scrolled.
838         static char *bt_name = NULL;
839
840         popup = mp_genlist_popup_create(ad->win_main, MP_POPUP_SOUND_PATH, ad, ad);
841         mp_retm_if(!popup, "Error: popup is null...");
842
843         group = elm_radio_add(popup);
844         ad->radio_group = group;
845
846         Evas_Object *genlist = evas_object_data_get(popup, "genlist");
847         MP_CHECK(genlist);
848         evas_object_data_set(genlist, "ad", ad);
849
850         IF_FREE(bt_name);
851         ret = sound_manager_get_a2dp_status(&bt_connected, &bt_name);
852         if (ret != SOUND_MANAGER_ERROR_NONE)
853         {
854                 WARN_TRACE("Fail to sound_manager_get_a2dp_status ret = [%d]", ret);
855         }
856
857         if (vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack))
858                 WARN_TRACE("Earjack state get Fail...");
859
860         _mp_play_view_append_snd_path_device(ad, bt_name, bt_connected, earjack, popup);
861
862 }
863
864 static void
865 _mp_play_view_destory_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
866 {
867         startfunc;
868         mp_playing_view *playing_view = (mp_playing_view *)(data);
869         MP_CHECK(playing_view);
870
871         struct appdata *ad = playing_view->ad;
872         MP_CHECK(ad);
873
874         mp_evas_object_del(playing_view->albumart_image_reflection);
875         mp_evas_object_del(playing_view->pre_albumart_image_reflection);
876         playing_view->flick_direction = 0;
877         playing_view->hide_image_flag = false;
878         //hide mute popup
879         if (playing_view->play_view)
880                 edje_object_signal_emit(_EDJ(playing_view->play_view), SIGNAL_MAIN_MUTE_HIDE, "*");
881         mp_ecore_timer_del(ad->volume_down_timer);
882         mp_ecore_timer_del(ad->mute_popup_show_timer);
883         //reset flag
884         ad->volume_long_pressed = false;
885
886         mp_ecore_timer_del(playing_view->favourite_timer);
887         mp_ecore_timer_del(playing_view->progressbar_timer);
888         mp_ecore_timer_del(playing_view->show_ctrl_timer);
889
890         if(ad->backup_playing_view == playing_view)
891         {
892                 IF_FREE(ad->backup_playing_view);
893                 ad->backup_layout_play_view = NULL;
894         }
895         else if(ad->playing_view == playing_view)
896         {
897                 IF_FREE(ad->playing_view);
898         }
899         else
900                 ERROR_TRACE("++++++++ check here ++++++++++");
901
902         mp_ecore_idler_del(ad->playview_show_idler);
903
904         endfunc;
905
906         return;
907 }
908
909 void
910 mp_play_view_show_default_info(struct appdata *ad)
911 {
912         MP_CHECK(ad);
913         mp_playing_view *playing_view = ad->playing_view;
914         MP_CHECK(playing_view);
915
916         mp_evas_object_del(playing_view->play_info);
917         Evas_Object *parent = NULL;
918 #ifdef MP_SOUND_PLAYER
919         parent = sp_view_mgr_get_naviframe(ad->view_mgr);
920 #else
921         parent = ad->naviframe;
922 #endif
923         playing_view->play_info =
924                 mp_common_load_edj(parent, PLAY_VIEW_EDJ_NAME, "richinfo/test_rich_info");
925
926         mp_play_view_create_info_contents(playing_view->play_info, ad);
927
928 #ifdef MP_SOUND_PLAYER
929         sp_view_mgr_push_view_content(ad->view_mgr, playing_view->play_info, SP_VIEW_TYPE_INFO);
930         sp_view_mgr_set_title_label(ad->view_mgr, GET_STR("IDS_MUSIC_BODY_DETAILSMEADIAINFO"));
931         sp_view_mgr_set_back_button(ad->view_mgr, mp_play_view_info_back_cb, ad);
932 #else
933         view_data_t *view_data = evas_object_data_get(ad->naviframe, "view_data");
934         mp_view_manager_push_view_content(view_data, playing_view->play_info, MP_VIEW_CONTENT_INFO);
935         mp_view_manager_set_title_and_buttons(view_data, "IDS_MUSIC_BODY_DETAILSMEADIAINFO",
936                                               ad);
937 #endif
938 }
939
940 void
941 mp_play_view_info_cb(void *data, Evas_Object * obj, void *event_info)
942 {
943         struct appdata *ad = (struct appdata *)data;
944         MP_CHECK(ad);
945         if (ad->info_click_flag && !ad->info_ug)
946                 return ;
947         if (!ad->info_ug)
948                 ad->info_click_flag = TRUE;
949         else
950                 ad->info_click_flag = FALSE;
951         ad->info_back_play_view_flag = FALSE;
952         mp_retm_if(ad->navi_effect_in_progress, "navi effect in progress");
953
954         mp_playing_view *playing_view = ad->playing_view;
955         MP_CHECK(playing_view);
956
957         EVAS_OBJ_HIDE(playing_view->albumart_img);
958         EVAS_OBJ_HIDE(playing_view->albumart_image_reflection);
959         //hide mute popup
960         if (playing_view->play_view)
961                 edje_object_signal_emit(_EDJ(playing_view->play_view), SIGNAL_MAIN_MUTE_HIDE, "*");
962         //show volume button
963         if (!ad->mute_flag)
964                 edje_object_signal_emit(_EDJ(playing_view->play_icon), "unmute", "volume");
965         else
966                 edje_object_signal_emit(_EDJ(playing_view->play_icon), "mute", "volume");
967         mp_ecore_timer_del(ad->volume_down_timer);
968         mp_ecore_timer_del(ad->mute_popup_show_timer);
969
970         mp_play_view_show_default_info(ad);
971
972 }
973
974 static bool
975 _mp_play_view_load_track_info(void *data, music_list_item * item)
976 {
977         struct appdata *ad = (struct appdata *)data;
978         MP_CHECK_FALSE(ad);
979
980         mp_playing_view *playing_view = ad->playing_view;
981         MP_CHECK_FALSE(playing_view);
982
983         if (ad->mute_flag)
984         {
985                 //set mute
986                 mp_player_mgr_set_mute(true);
987                 edje_object_signal_emit(_EDJ(playing_view->play_icon), "mute", "volume");
988         }
989         else
990         {
991                 //reset volume
992                 mp_player_mgr_set_mute(false);
993                 edje_object_signal_emit(_EDJ(playing_view->play_icon), "unmute", "volume");
994         }
995
996         MP_CHECK_FALSE(item);
997
998         music_list_item *current_item = mp_play_list_get_current_item(ad->playing_list);
999         MP_CHECK_FALSE(current_item);
1000
1001         DEBUG_TRACE("category: %d", current_item->category);
1002         if (current_item->category == MP_MEDIA_TYPE_MUSIC)
1003         {
1004                 if (current_item->key_id > 0
1005                     && current_item->favorite)
1006                 {
1007                         edje_object_signal_emit(_EDJ(playing_view->play_menu), "favorite_on", "play_view");
1008                 }
1009                 else
1010                 {
1011                         edje_object_signal_emit(_EDJ(playing_view->play_menu), "favorite_off", "play_view");
1012                 }
1013         }
1014         else
1015         {
1016                 edje_object_signal_emit(_EDJ(playing_view->play_menu), "favorite_invisible", "play_view");
1017         }
1018
1019         if (item == current_item) {
1020         #ifdef MP_SOUND_PLAYER
1021                 sp_view_mgr_play_view_title_label_set(ad->view_mgr, item->title);
1022         #else
1023                 mp_view_manager_play_view_title_label_set(ad, item->title);
1024         #endif
1025         }
1026         if(playing_view->play_head)
1027                 elm_object_item_text_set(playing_view->play_head, current_item->title);
1028
1029         edje_object_part_text_set(_EDJ(playing_view->play_title), "artist", current_item->artist);
1030         edje_object_part_text_set(_EDJ(playing_view->play_title), "album", current_item->album);
1031
1032         return true;
1033 }
1034
1035 static Evas_Object *
1036 _mp_play_view_create_next_item(music_list_item * next_item, void *data)
1037 {
1038         Evas_Object *next_view = NULL;
1039         Evas_Object *album_img = NULL;
1040
1041         struct appdata *ad = (struct appdata *)data;
1042         MP_CHECK_NULL(ad);
1043
1044         mp_playing_view *playing_view = ad->playing_view;
1045         MP_CHECK_NULL(playing_view);
1046
1047         MP_CHECK_NULL(next_item);
1048
1049         mp_debug("next item : %s", next_item->title);
1050
1051         next_view = elm_layout_add(playing_view->layout);
1052
1053         if (playing_view->play_view_screen_mode == MP_SCREEN_MODE_LANDSCAPE)
1054         {
1055                 mp_debug_temp
1056                         (" invalid state MP_SCREEN_MODE_LANDSCAPE MP_SCREEN_MODE_LANDSCAPE MP_SCREEN_MODE_LANDSCAPE MP_SCREEN_MODE_LANDSCAPE");
1057                 elm_layout_file_set(next_view, PLAY_VIEW_EDJ_NAME, "mp_play_view_landscape");
1058                 evas_object_size_hint_max_set(next_view, 480 * elm_scale_get(), 480 * elm_scale_get());
1059                 evas_object_size_hint_align_set(next_view, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
1060                 evas_object_size_hint_weight_set(next_view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1061                 elm_win_resize_object_add(ad->win_main, next_view);
1062         }
1063         else
1064         {
1065
1066                 next_view = mp_common_load_edj(playing_view->layout, PLAY_VIEW_EDJ_NAME, "mp_play_view");
1067                 evas_object_size_hint_max_set(next_view, 480 * elm_scale_get(), 800 * elm_scale_get());
1068         }
1069
1070         evas_object_show(next_view);
1071
1072         if (playing_view->play_view_screen_mode == MP_SCREEN_MODE_LANDSCAPE)
1073         {
1074                 album_img = elm_bg_add(next_view);
1075                 if (strlen(next_item->albumart) && mp_util_is_image_valid(ad->evas, next_item->albumart))
1076                 {
1077                         elm_bg_file_set(album_img, next_item->albumart, NULL);
1078                 }
1079                 else
1080                 {
1081                         elm_bg_file_set(album_img, DEFAULT_THUMBNAIL, NULL);
1082                 }
1083         }
1084         else
1085         {
1086                 album_img = evas_object_image_add(ad->evas);
1087                 int w, h;
1088                 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
1089                 evas_object_image_load_size_set(album_img, w, h*HD_ALBUM_IMAGE_H_SCALE);
1090                 evas_object_image_fill_set(album_img, 0, 0, w, h*HD_ALBUM_IMAGE_H_SCALE);
1091                 if (strlen(next_item->albumart) && mp_util_is_image_valid(ad->evas, next_item->albumart))
1092                 {
1093                         evas_object_image_file_set(album_img, next_item->albumart, NULL);
1094                 }
1095                 else
1096                 {
1097                         evas_object_image_file_set(album_img, DEFAULT_THUMBNAIL, NULL);
1098                 }
1099         }
1100
1101         elm_object_part_content_set(next_view, "album_art", album_img);
1102         evas_object_show(album_img);
1103
1104         Evas_Object *progress = NULL;
1105         Evas_Object *play_ctrl = NULL;
1106
1107         play_ctrl = _mp_play_view_create_ctrl_layout(data, next_view, &progress, FALSE);
1108         playing_view->play_progressbar = progress;
1109         evas_object_show(progress);
1110
1111         _mp_play_view_load_track_info(data, next_item);
1112
1113         return next_view;
1114 }
1115
1116 static void
1117 _mp_play_view_eventbox_clicked_cb(void *data, Evas_Object * obj, void *event_info)
1118 {
1119         struct appdata *ad = (struct appdata *)data;
1120         MP_CHECK(ad);
1121
1122         mp_playing_view *playing_view = ad->playing_view;
1123         MP_CHECK(playing_view);
1124
1125         DEBUG_TRACE("[%d]", ad->show_optional_menu);
1126
1127         mp_play_view_set_menu_state(ad, !ad->show_optional_menu, true);
1128
1129         return;
1130 }
1131
1132 static bool
1133 _mp_play_view_clear_next_view(void *data)
1134 {
1135         startfunc;
1136         struct appdata *ad = (struct appdata *)data;
1137         MP_CHECK_FALSE(ad);
1138
1139         mp_playing_view *playing_view = ad->playing_view;
1140         MP_CHECK_FALSE(playing_view);
1141
1142         Evas_Object *content = elm_object_part_content_unset(playing_view->layout, "list_content_temp");
1143         evas_object_del(content);
1144         playing_view->play_view_next = NULL;
1145
1146         edje_object_signal_emit(elm_layout_edje_get(playing_view->layout), "set_default", "list_content");
1147
1148         IF_FREE(playing_view->playing_list_item);
1149
1150         playing_view->transition_state = false;
1151
1152         return true;
1153 }
1154
1155 static void
1156 _mp_play_view_eventbox_flick_left_cb(void *data, Evas_Object * obj, void *event_info)
1157 {
1158         startfunc;
1159         struct appdata *ad = (struct appdata *)data;
1160         MP_CHECK(ad);
1161
1162         mp_playing_view *playing_view = ad->playing_view;
1163         MP_CHECK(playing_view);
1164
1165         if (ad->playing_list && ad->playing_list->count <= 1)
1166                 return;
1167
1168         music_list_item *next_item = NULL;
1169
1170         if (mp_play_list_get_next_item(data, ad->playing_list, &next_item, TRUE)== MP_PLST_RET_OK)
1171         {
1172                 playing_view->flick_direction = 1;
1173                 IF_FREE(ad->latest_playing_key_id);
1174                 _mp_play_view_transit_by_item(data, next_item, true);
1175         }
1176
1177         IF_FREE(next_item);
1178
1179         return;
1180 }
1181
1182 static void
1183 _mp_play_view_eventbox_flick_right_cb(void *data, Evas_Object * obj, void *event_info)
1184 {
1185         startfunc;
1186         struct appdata *ad = (struct appdata *)data;
1187         MP_CHECK(ad);
1188
1189         mp_playing_view *playing_view = ad->playing_view;
1190         MP_CHECK(playing_view);
1191
1192         if (ad->playing_list && ad->playing_list->count <= 1)
1193                 return;
1194
1195         music_list_item *next_item = NULL;
1196
1197         if (mp_play_list_get_prev_item(data, ad->playing_list, &next_item))
1198         {
1199                 playing_view->flick_direction = 2;
1200                 IF_FREE(ad->latest_playing_key_id);
1201                 _mp_play_view_transit_by_item(data, next_item, false);
1202         }
1203         else
1204                 mp_error("can not get next item");
1205
1206         IF_FREE(next_item);
1207
1208
1209         return;
1210 }
1211
1212 static Eina_Bool
1213 _mp_play_view_favourite_timer_cb(void *data)
1214 {
1215         struct appdata *ad = (struct appdata *)data;
1216         mp_retvm_if(!ad, ECORE_CALLBACK_CANCEL, "ad");
1217
1218         mp_playing_view *playing_view = ad->playing_view;
1219         mp_retvm_if(!playing_view, ECORE_CALLBACK_CANCEL, "ad");
1220
1221         mp_ecore_timer_del(playing_view->favourite_timer);
1222
1223         return ECORE_CALLBACK_CANCEL;
1224 }
1225
1226 static void
1227 _mp_play_view_favourite_cb(void *data, Evas_Object * o, const char *emission, const char *source)
1228 {
1229         struct appdata *ad = (struct appdata *)data;
1230         MP_CHECK(ad);
1231
1232         mp_playing_view *playing_view = ad->playing_view;
1233         MP_CHECK(playing_view);
1234
1235         DEBUG_TRACE("%s", emission);
1236
1237         if (!strcmp(emission, "favorite_down"))
1238         {
1239                 playing_view->favour_longpress = 0;
1240
1241                 mp_ecore_timer_del(playing_view->favourite_timer);
1242
1243                 playing_view->favourite_timer =
1244                         ecore_timer_add(FAVOUR_LONG_PRESS_TIME, _mp_play_view_favourite_timer_cb, ad);
1245         }
1246         else if (!strcmp(emission, "favorite_up"))
1247         {
1248                 mp_ecore_timer_del(playing_view->favourite_timer);
1249
1250                 if (playing_view->favour_longpress)
1251                 {
1252                         playing_view->favour_longpress = 0;
1253                 }
1254                 else
1255                 {
1256                         int ret = 0;
1257                         mp_media_info_h media = NULL;
1258                         music_list_item *current_item = mp_play_list_get_current_item(ad->playing_list);
1259                         MP_CHECK(current_item);
1260
1261                         ret = mp_media_info_create(&media, current_item->key_id);
1262                         MP_CHECK(ret == 0);
1263                         ret = mp_media_info_set_favorite(media, !current_item->favorite);
1264                         mp_media_info_destroy(media);
1265                         if(ret)
1266                         {
1267                                 if(current_item->favorite)
1268                                         mp_util_create_notify(ad, GET_STR("IDS_MUSIC_POP_UNABLE_TO_ADD"));
1269                                 else
1270                                         mp_util_create_notify(ad, GET_STR("IDS_MUSIC_POP_ITEM_NOT_REMOVE"));
1271
1272                                 return;
1273                         }
1274                         current_item->favorite = !current_item->favorite;
1275
1276                         if (!current_item->favorite)
1277                         {
1278                                 edje_object_signal_emit(_EDJ(playing_view->play_menu), "favorite_off", "play_view");
1279                                 mp_util_create_notify(ad, GET_SYS_STR("IDS_COM_POP_REMOVED"));
1280                         }
1281                         else
1282                         {
1283                                 edje_object_signal_emit(_EDJ(playing_view->play_menu), "favorite_on", "play_view");
1284                                 mp_util_create_notify(ad, GET_STR("IDS_MUSIC_POP_ADDED"));
1285                         }
1286
1287                 }
1288         }
1289 #ifndef MP_SOUND_PLAYER
1290         MP_CHECK(ad->naviframe);
1291         view_data_t *view_data = (view_data_t *) evas_object_data_get(ad->naviframe, "view_data");
1292         MP_CHECK(view_data);
1293         if (view_data->view_type == MP_VIEW_TYPE_PLAYLIST)
1294                 mp_library_update_view(ad);
1295 #endif
1296         return;
1297 }
1298
1299 static void
1300 _mp_play_view_progressbar_down_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
1301 {
1302         startfunc;
1303         if (data == NULL && obj == NULL && event_info == NULL)
1304                 return;
1305
1306         evas_object_data_set(obj, "pressed", (void *)1);
1307
1308         struct appdata *ad = (struct appdata *)data;
1309         MP_CHECK(ad);
1310
1311         mp_playing_view *playing_view = ad->playing_view;
1312         MP_CHECK(playing_view);
1313
1314         Evas_Event_Mouse_Down *ev = event_info;
1315         Evas_Object *progressbar = obj;
1316         int duration = 0, w = 0, current = 0, x = 0;
1317         double ratio = 0.0;
1318
1319         if (ad->player_state == PLAY_STATE_INIT)
1320         {
1321                 ERROR_TRACE("Invaild player_state : %d", ad->player_state);
1322                 return;
1323         }
1324
1325         mp_play_view_progress_timer_freeze(ad);
1326         evas_object_geometry_get(progressbar, &x, NULL, &w, NULL);
1327         current = ev->canvas.x - x;
1328
1329         if (current < 0)
1330                 current = 0;
1331         else if (current > w)
1332                 current = w;
1333
1334         ratio = (double)current / w;
1335         duration = mp_player_mgr_get_duration();
1336
1337         ad->music_length = duration / 1000.;
1338
1339         ad->music_pos = ratio * ad->music_length;
1340         mp_play_view_update_progressbar(ad);
1341
1342         return;
1343 }
1344
1345 static void
1346 _mp_play_view_progressbar_seek_done_cb(void *data)
1347 {
1348         startfunc;
1349         struct appdata *ad = data;
1350
1351         mp_play_view_progress_timer_thaw(ad);
1352 }
1353
1354 static void
1355 _mp_play_view_progressbar_up_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
1356 {
1357         startfunc;
1358         if (data == NULL && obj == NULL && event_info == NULL)
1359                 return;
1360
1361         evas_object_data_set(obj, "pressed", (void *)0);
1362
1363         struct appdata *ad = (struct appdata *)data;
1364         MP_CHECK(ad);
1365
1366         mp_playing_view *playing_view = ad->playing_view;
1367         MP_CHECK(playing_view);
1368
1369         Evas_Event_Mouse_Up *ev = event_info;
1370         Evas_Object *progressbar = obj;
1371         int duration = 0, w = 0, current = 0, x = 0;
1372         double ratio = 0.0;
1373
1374         if (ad->player_state == PLAY_STATE_INIT)
1375         {
1376                 ERROR_TRACE("Invaild player_state : %d", ad->player_state);
1377                 return;
1378         }
1379
1380         evas_object_geometry_get(progressbar, &x, NULL, &w, NULL);
1381
1382         current = ev->canvas.x - x;
1383
1384         if (current < 0)
1385                 current = 0;
1386         else if (current > w)
1387                 current = w;
1388
1389         ratio = (double)current / w;
1390
1391         duration = mp_player_mgr_get_duration();
1392
1393         ad->music_length = duration / 1000.;
1394
1395         ad->music_pos = ratio * ad->music_length;
1396
1397         if (mp_player_mgr_set_position(ad->music_pos * 1000, _mp_play_view_progressbar_seek_done_cb, ad))
1398                 mp_play_view_update_progressbar(ad);
1399         else
1400                 _mp_play_view_progressbar_seek_done_cb(ad);
1401
1402
1403         return;
1404 }
1405
1406 static void
1407 _mp_play_progressbar_move_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
1408 {
1409         if (data == NULL && obj == NULL && event_info == NULL)
1410                 return;
1411
1412         int pressed = (int)evas_object_data_get(obj, "pressed");
1413         if (!pressed) {
1414                 mp_debug("-_- progressbar is not pressed yet!");
1415                 return;
1416         }
1417
1418         struct appdata *ad = (struct appdata *)data;
1419         MP_CHECK(ad);
1420
1421         mp_playing_view *playing_view = ad->playing_view;
1422         MP_CHECK(playing_view);
1423
1424         Evas_Event_Mouse_Move *ev = event_info;
1425
1426         if (ad->player_state == PLAY_STATE_INIT)
1427         {
1428                 ERROR_TRACE("Invaild player_state : %d", ad->player_state);
1429                 return;
1430         }
1431
1432         Evas_Object *progressbar = obj;
1433         int w = 0, current = 0;
1434         int x;
1435         double ratio = 0.0;
1436         int new_pos;
1437
1438         if (ad->player_state == PLAY_STATE_INIT)
1439                 return;
1440
1441         evas_object_geometry_get(progressbar, &x, NULL, &w, NULL);
1442
1443         current = ev->cur.canvas.x - x;
1444
1445         if (current < 0)
1446                 current = 0;
1447         else if (current > w)
1448                 current = w;
1449
1450         ratio = (double)current / w;
1451
1452         new_pos= ratio * ad->music_length;
1453         if(new_pos != mp_player_mgr_get_position()/1000 )
1454         {
1455                 mp_player_mgr_set_position(ad->music_pos*1000, NULL, NULL);
1456                 ad->music_pos = new_pos;
1457                 mp_play_view_update_progressbar(ad);
1458         }
1459
1460         return;
1461 }
1462
1463
1464 static Eina_Bool
1465 _mp_play_view_update_progressbar_cb(void *data)
1466 {
1467         struct appdata *ad = data;
1468         MP_CHECK_CANCEL(ad);
1469
1470         mp_playing_view *playing_view = ad->playing_view;
1471         MP_CHECK_CANCEL(playing_view);
1472
1473         if(!ad->app_is_foreground)
1474         {
1475                 WARN_TRACE("Check here.. progress timer should be freezed..");
1476                 ecore_timer_freeze(playing_view->progressbar_timer);
1477         }
1478
1479         int duration = 0, pos = 0;
1480         double get_length = 0., get_pos = 0.;
1481
1482         if (ad->player_state == PLAY_STATE_PLAYING || ad->player_state == PLAY_STATE_PAUSED)
1483         {
1484                 duration = mp_player_mgr_get_duration();
1485                 if ((duration / 1000) > 0)
1486                 {
1487                         pos = mp_player_mgr_get_position();
1488                         get_length = duration / 1000.;
1489                         get_pos = pos / 1000.;
1490                 }
1491
1492                 if (get_length != ad->music_length || get_pos != ad->music_pos)
1493                 {
1494                         // update only value is changed
1495                         ad->music_length = get_length;
1496                         ad->music_pos = get_pos;
1497
1498                         mp_play_view_update_progressbar(ad);
1499                 }
1500         }
1501
1502         ecore_timer_interval_set(playing_view->progressbar_timer, 0.5);
1503
1504         return 1;
1505 }
1506
1507 static void
1508 _mp_play_view_menu_visible_set(void *data, bool menu_enable, bool animation)
1509 {
1510         struct appdata *ad = data;
1511
1512         mp_retm_if(ad == NULL, "appdata is NULL");
1513         mp_retm_if(ad->playing_view == NULL, "playing_view is NULL");
1514         mp_retm_if(ad->playing_view->play_view == NULL, "play_view is NULL");
1515
1516         if (menu_enable)
1517                 edje_object_signal_emit(_EDJ(ad->playing_view->layout), "option_menu_visible", "player_option_menu");
1518         else
1519         {
1520                 if(animation)
1521                         edje_object_signal_emit(_EDJ(ad->playing_view->layout), "option_menu_invisible",
1522                                         "player_option_menu");
1523                 else
1524                         edje_object_signal_emit(_EDJ(ad->playing_view->layout), "option_hide",
1525                                         "player_option_menu");
1526         }
1527 }
1528
1529 static void
1530 _mp_play_view_progress_visible_set(void *data, bool progressbar_enable)
1531 {
1532         struct appdata *ad = data;
1533
1534         mp_retm_if(ad == NULL, "appdata is NULL");
1535         mp_retm_if(ad->playing_view == NULL, "playing_view is NULL");
1536         mp_retm_if(ad->playing_view->play_view == NULL, "play_view is NULL");
1537
1538         if (progressbar_enable)
1539                 edje_object_signal_emit(_EDJ(ad->playing_view->play_ctrl), "progressbar_visible", "player_progress");
1540         else
1541                 edje_object_signal_emit(_EDJ(ad->playing_view->play_ctrl), "progressbar_invisible", "player_progress");
1542 }
1543
1544
1545 void
1546 _mp_play_view_add_progress_timer(void *data)
1547 {
1548         struct appdata *ad = data;
1549         MP_CHECK(ad);
1550
1551         mp_playing_view *playing_view = ad->playing_view;
1552         MP_CHECK(playing_view);
1553
1554         mp_ecore_timer_del(playing_view->progressbar_timer);
1555
1556         playing_view->progressbar_timer = ecore_timer_add(0.1, _mp_play_view_update_progressbar_cb, ad);
1557         if(ad->player_state != PLAY_STATE_PLAYING || !ad->app_is_foreground)
1558                 ecore_timer_freeze(playing_view->progressbar_timer);
1559
1560         return;
1561 }
1562
1563 static bool
1564 _mp_play_view_init_progress_bar(void *data)
1565 {
1566         struct appdata *ad = (struct appdata *)data;
1567         MP_CHECK_FALSE(ad);
1568
1569         mp_playing_view *playing_view = ad->playing_view;
1570         MP_CHECK_FALSE(playing_view);
1571
1572         int pos = 0, duration = 0;
1573         pos = mp_player_mgr_get_position();
1574         duration = mp_player_mgr_get_duration();
1575         ad->music_pos = pos / 1000.;
1576         ad->music_length = duration / 1000.;
1577         mp_play_view_update_progressbar(ad);
1578         _mp_play_view_add_progress_timer(ad);
1579
1580         return true;
1581 }
1582
1583 bool
1584 _mp_play_view_set_menu_item(void *data)
1585 {
1586         struct appdata *ad = (struct appdata *)data;
1587         MP_CHECK_FALSE(ad);
1588
1589         int shuffle_state = 0;
1590         int repeat_state = 0;
1591
1592         if (!mp_setting_get_shuffle_state(&shuffle_state))
1593         {
1594                 mp_play_control_shuffle_set(ad, shuffle_state);
1595                 ad->play_shuffle_state = shuffle_state;
1596         }
1597
1598         if (!mp_setting_get_repeat_state(&repeat_state))
1599                 mp_play_control_repeat_set(ad, repeat_state);
1600
1601         return true;
1602 }
1603
1604
1605 static bool
1606 _mp_play_view_create_menu(void *data)
1607 {
1608         startfunc;
1609         struct appdata *ad = (struct appdata *)data;
1610         MP_CHECK_FALSE(ad);
1611
1612         mp_playing_view *playing_view = ad->playing_view;
1613         MP_CHECK_FALSE(playing_view);
1614
1615         playing_view->play_menu = mp_common_load_edj(playing_view->play_view, PLAY_VIEW_EDJ_NAME, "mp_play_menu");
1616         elm_object_part_content_set(playing_view->layout, "player_option_menu", playing_view->play_menu);
1617         edje_object_signal_callback_add(_EDJ(playing_view->play_menu), "favorite_down", "*", _mp_play_view_favourite_cb,
1618                                         ad);
1619         edje_object_signal_callback_add(_EDJ(playing_view->play_menu), "favorite_up", "*", _mp_play_view_favourite_cb,
1620                                         ad);
1621
1622         if (playing_view->play_view_screen_mode == MP_SCREEN_MODE_LANDSCAPE)
1623                 evas_object_size_hint_max_set(playing_view->play_menu, elm_scale_get(), 70 * elm_scale_get());
1624         edje_object_signal_callback_add(_EDJ(playing_view->play_menu), SIGNAL_SHUFFLE, "*", mp_play_control_menu_cb,
1625                                         ad);
1626         edje_object_signal_callback_add(_EDJ(playing_view->play_menu), SIGNAL_SHUFNON, "*", mp_play_control_menu_cb,
1627                                         ad);
1628         edje_object_signal_callback_add(_EDJ(playing_view->play_menu), SIGNAL_REPALL, "*", mp_play_control_menu_cb, ad);
1629         edje_object_signal_callback_add(_EDJ(playing_view->play_menu), SIGNAL_REPNON, "*", mp_play_control_menu_cb, ad);
1630         edje_object_signal_callback_add(_EDJ(playing_view->play_menu), SIGNAL_REP1, "*", mp_play_control_menu_cb, ad);
1631
1632         _mp_play_view_set_menu_item(ad);
1633
1634         _mp_play_view_menu_visible_set(ad, FALSE, false);
1635         endfunc;
1636         return true;
1637
1638 }
1639
1640 void
1641 mp_play_view_set_snd_path_sensitivity(void *data)
1642 {
1643         startfunc;
1644         struct appdata *ad = (struct appdata *)data;
1645         MP_CHECK(ad);
1646
1647         int ret = 0;
1648         bool bt_connected = 0;
1649         char *bt_name = NULL;
1650         int earjack = 0;
1651         Elm_Object_Item *navi_item = NULL;
1652         Elm_Object_Item *land_navi_item = NULL;
1653         Evas_Object *btn = NULL;
1654         Evas_Object *land_btn = NULL;
1655
1656         mp_playing_view *playing_view = ad->playing_view;
1657         MP_CHECK(playing_view);
1658
1659         if (playing_view->play_view_screen_mode == MP_SCREEN_MODE_LANDSCAPE)
1660         {
1661                 DEBUG_TRACE("");
1662                 land_navi_item = playing_view->play_head;
1663         }
1664 #ifdef MP_SOUND_PLAYER
1665         navi_item = sp_view_mgr_get_play_view_navi_item(ad->view_mgr);
1666 #else
1667         navi_item =  mp_view_manager_get_play_view_navi_item(ad);
1668 #endif
1669
1670         if(navi_item)
1671                 btn = elm_object_item_part_content_get(navi_item, ELM_NAVIFRAME_ITEM_TITLE_LEFT_BTN);
1672
1673         if(land_navi_item)
1674                 land_btn = elm_object_item_part_content_get(land_navi_item, ELM_NAVIFRAME_ITEM_TITLE_LEFT_BTN);
1675
1676
1677         ret = sound_manager_get_a2dp_status(&bt_connected, &bt_name);
1678         if (ret != SOUND_MANAGER_ERROR_NONE)
1679         {
1680                 WARN_TRACE("Fail to sound_manager_get_a2dp_status ret = [%d]", ret);
1681         }
1682
1683         if (!bt_connected)
1684         {
1685                 if (vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack))
1686                         WARN_TRACE("Earjack state get Fail...");
1687         }
1688         IF_FREE(bt_name);
1689         if (!bt_connected && !earjack)
1690         {
1691                 if(btn)
1692                 {
1693                         elm_object_item_part_content_unset(navi_item, ELM_NAVIFRAME_ITEM_TITLE_LEFT_BTN);
1694                         evas_object_del(btn);
1695                 }
1696                 if(land_btn)
1697                 {
1698                         elm_object_item_part_content_unset(land_navi_item, ELM_NAVIFRAME_ITEM_TITLE_LEFT_BTN);
1699                         evas_object_del(land_btn);
1700                 }
1701         }
1702         else
1703         {
1704                 if(!btn && navi_item)
1705                 {
1706                         Evas_Object *parent = NULL;
1707 #ifdef MP_SOUND_PLAYER
1708                         parent = sp_view_mgr_get_naviframe(ad->view_mgr);
1709 #else
1710                         parent = ad->naviframe;
1711 #endif
1712                         Evas_Object *btn = mp_widget_create_title_btn(parent, NULL, MP_ICON_SOUND_PATH,
1713                                                                         mp_play_view_set_snd_path_cb, ad);
1714                         elm_object_item_part_content_set(navi_item, ELM_NAVIFRAME_ITEM_TITLE_LEFT_BTN, btn);
1715                 }
1716                 if(!land_btn && land_navi_item)
1717                 {
1718                         Evas_Object *btn = mp_widget_create_title_btn(playing_view->land_naviframe, NULL, MP_ICON_SOUND_PATH,
1719                                                                         mp_play_view_set_snd_path_cb, ad);
1720                         elm_object_item_part_content_set(land_navi_item, ELM_NAVIFRAME_ITEM_TITLE_LEFT_BTN, btn);
1721                 }
1722         }
1723 }
1724
1725 static void
1726 mp_play_view_back_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1727 {
1728 #ifdef MP_SOUND_PLAYER
1729         struct appdata *ad = (struct appdata *)data;
1730 #else
1731         view_data_t *view_data = (view_data_t *) data;
1732         MP_CHECK(view_data);
1733         MP_CHECK_VIEW_DATA(view_data);
1734
1735         struct appdata *ad = view_data->ad;
1736 #endif
1737         MP_CHECK(ad);
1738         mp_retm_if(ad->navi_effect_in_progress, "navi effect in progress");
1739
1740 #ifdef MP_SOUND_PLAYER
1741         if (ad->player_state == PLAY_STATE_PLAYING || ad->player_state == PLAY_STATE_PAUSED) {
1742                 mp_debug("mm player alive");
1743                 elm_win_lower(ad->win_main);
1744         } else {
1745                 mp_debug("terminate");
1746                 mp_app_exit(ad);
1747         }
1748 #else
1749         if(ad->direct_win_minimize)
1750                 elm_win_lower(ad->win_main);
1751         else
1752                 mp_common_back_button_cb(data, obj, NULL);
1753
1754         if (ad->music_setting_change_flag)
1755         {
1756                 mp_debug("# menu update #");
1757                 mp_util_set_library_controlbar_items(ad);
1758                 ad->music_setting_change_flag = false;
1759         }
1760 #endif
1761 }
1762
1763 static bool
1764 _mp_play_view_create_control_bar(void *data)
1765 {
1766         startfunc;
1767         struct appdata *ad = (struct appdata *)data;
1768         MP_CHECK_FALSE(ad);
1769
1770         mp_playing_view *playing_view = ad->playing_view;
1771         MP_CHECK_FALSE(playing_view);
1772
1773         Evas_Object *play_control = NULL, *play_icon = NULL;
1774
1775         if (playing_view->play_view_screen_mode == MP_SCREEN_MODE_LANDSCAPE)
1776                 play_control =
1777                         mp_common_load_edj(playing_view->layout, PLAY_VIEW_EDJ_NAME, "music/playing/main/control_ls");
1778         else
1779                 play_control =
1780                         mp_common_load_edj(playing_view->layout, PLAY_VIEW_EDJ_NAME, "music/playing/main/control");
1781
1782         MP_CHECK_FALSE(play_control);
1783
1784         play_icon = mp_common_load_edj(play_control, PLAY_VIEW_EDJ_NAME, "music/playing/main/control/buttons");
1785
1786         if (!play_icon)
1787         {
1788                 mp_evas_object_del(play_control);
1789                 MP_CHECK_FALSE(play_icon);
1790         }
1791
1792         elm_object_part_content_set(play_control, "buttons", play_icon);
1793         evas_object_data_set(play_control, "buttons", play_icon);
1794 #ifdef MP_SOUND_PLAYER
1795                 edje_object_signal_callback_add(_EDJ(play_icon), "info_clicked", CTR_EDJ_SIG_SRC, mp_play_view_back_cb, ad);
1796 #else
1797                 edje_object_signal_callback_add(_EDJ(play_icon), "info_clicked", CTR_EDJ_SIG_SRC, mp_play_view_back_cb,
1798                                         mp_util_get_view_data(ad));
1799 #endif
1800         edje_object_signal_callback_add(_EDJ(play_icon), "volume_clicked", CTR_EDJ_SIG_SRC, mp_play_control_volume_cb,
1801                                         ad);
1802 #ifdef MP_FEATURE_VOLMUE_MUTE
1803         edje_object_signal_callback_add(_EDJ(play_icon), "vol_btn_down", CTR_EDJ_SIG_SRC,
1804                                         mp_play_control_volume_down_cb, ad);
1805         edje_object_signal_callback_add(_EDJ(play_icon), "vol_btn_up", CTR_EDJ_SIG_SRC, mp_play_control_volume_up_cb,
1806                                         ad);
1807 #endif
1808         edje_object_signal_callback_add(_EDJ(play_icon), "play_clicked", CTR_EDJ_SIG_SRC, mp_play_control_play_cb, ad);
1809         edje_object_signal_callback_add(_EDJ(play_icon), "pause_clicked", CTR_EDJ_SIG_SRC, mp_play_control_play_cb, ad);
1810
1811         edje_object_signal_callback_add(_EDJ(play_icon), "ff_btn_down", CTR_EDJ_SIG_SRC, mp_play_control_ff_cb, ad);
1812         edje_object_signal_callback_add(_EDJ(play_icon), "ff_btn_up", CTR_EDJ_SIG_SRC, mp_play_control_ff_cb, ad);
1813
1814         edje_object_signal_callback_add(_EDJ(play_icon), "rew_btn_down", CTR_EDJ_SIG_SRC, mp_play_control_rew_cb, ad);
1815         edje_object_signal_callback_add(_EDJ(play_icon), "rew_btn_up", CTR_EDJ_SIG_SRC, mp_play_control_rew_cb, ad);
1816
1817         player_state_e player_state = mp_player_mgr_get_state();
1818         if (player_state != PLAYER_STATE_PLAYING)
1819                 edje_object_signal_emit(_EDJ(play_icon), "play", CTR_PROG_SIG_SRC);
1820         else
1821                 edje_object_signal_emit(_EDJ(play_icon), "pause", CTR_PROG_SIG_SRC);
1822
1823         playing_view->play_control = play_control;
1824
1825         //show volume button
1826         if (!ad->mute_flag)
1827                 edje_object_signal_emit(_EDJ(play_icon), "unmute", "volume");
1828         else
1829                 edje_object_signal_emit(_EDJ(play_icon), "mute", "volume");
1830         playing_view->play_icon = play_icon;
1831
1832         elm_object_part_content_set(playing_view->layout, "elm.swallow.controlbar", playing_view->play_control);
1833         endfunc;
1834         return true;
1835 }
1836
1837
1838
1839 static void
1840 _mp_play_progress_val_set(void *data, double position)
1841 {
1842         struct appdata *ad = (struct appdata *)data;
1843         MP_CHECK(ad);
1844
1845         mp_playing_view *playing_view = ad->playing_view;
1846         MP_CHECK(playing_view);
1847         MP_CHECK(playing_view->play_progressbar);
1848
1849         Evas_Object *pbar = evas_object_data_get(playing_view->play_progressbar, "progress_bar");
1850
1851         edje_object_part_drag_value_set(_EDJ(pbar), "progressbar_control", position, 0.0);
1852
1853         return;
1854 }
1855
1856 static void
1857 _mp_play_view_transit_by_item_complete_cb(void *data, Evas_Object * obj, const char *emission, const char *source)
1858 {
1859         struct appdata *ad = (struct appdata *)data;
1860         MP_CHECK(ad);
1861
1862         mp_playing_view *playing_view = ad->playing_view;
1863         MP_CHECK(playing_view);
1864
1865         DEBUG_TRACE("emission: %s, source: %s", emission, source);
1866         if (source)
1867         {
1868                 if (strcmp(source, "list") == 0)
1869                 {
1870                         mp_play_item_play(ad, playing_view->playing_list_item->key_id);
1871                         mp_play_view_refresh(ad);
1872
1873                         _mp_play_view_clear_next_view(data);
1874
1875                         _mp_play_view_init_progress_bar(data);
1876                         evas_object_show(playing_view->layout);
1877
1878                         edje_object_signal_callback_del(elm_layout_edje_get(playing_view->layout), "transit_done", "*",
1879                                                         _mp_play_view_transit_by_item_complete_cb);
1880                 }
1881         }
1882
1883         return;
1884 }
1885
1886 static bool
1887 _mp_play_view_transit_by_item(void *data, struct music_list_item *it, bool move_left)
1888 {
1889         struct appdata *ad = (struct appdata *)data;
1890         MP_CHECK_FALSE(ad);
1891
1892         mp_playing_view *playing_view = ad->playing_view;
1893         MP_CHECK_FALSE(playing_view);
1894
1895         if (playing_view->play_view)
1896         {
1897                 mp_ecore_timer_del(ad->mute_popup_show_timer);
1898                 //hide mute popup
1899                 edje_object_signal_emit(_EDJ(playing_view->play_view), SIGNAL_MAIN_MUTE_HIDE, "*");
1900                 //show volume button
1901                 if (!ad->mute_flag)
1902                         edje_object_signal_emit(_EDJ(playing_view->play_icon), "unmute", "volume");
1903                 else
1904                         edje_object_signal_emit(_EDJ(playing_view->play_icon), "mute", "volume");
1905         }
1906
1907         Evas_Object *next = NULL;
1908         music_list_item *current_item = mp_play_list_get_current_item(ad->playing_list);
1909         MP_CHECK_FALSE(current_item);
1910
1911         if (!g_strcmp0(ad->latest_playing_key_id ,it->key_id))
1912         {
1913                 mp_debug("same file selected plz check state");
1914                 return FALSE;
1915         }
1916
1917         if (playing_view->transition_state)     // transiton(transition_state)  should be transiit callback
1918         {
1919                 mp_debug("skip_by transiton effect");
1920                 return FALSE;
1921         }
1922
1923         mp_play_view_stop_transit(data);
1924
1925         mp_play_view_progress_timer_freeze(ad);
1926
1927         mp_play_view_set_menu_state(ad, false, false);
1928
1929         mp_debug("current index = %d, set index = %d", current_item->list_index, it->list_index);
1930
1931         IF_FREE(playing_view->playing_list_item);
1932         mp_play_list_item_copy(&playing_view->playing_list_item, it);
1933
1934         next = _mp_play_view_create_next_item(it, ad);
1935         MP_CHECK_FALSE(next);
1936         playing_view->play_view_next = next;
1937         elm_object_part_content_set(playing_view->layout, "list_content_temp", next);
1938         edje_object_signal_callback_add(elm_layout_edje_get(playing_view->layout), "transit_done", "*",
1939                                         _mp_play_view_transit_by_item_complete_cb, ad);
1940
1941         if (!move_left)
1942         {
1943                 edje_object_signal_emit(elm_layout_edje_get(playing_view->layout), "set_left", "list_content_temp");
1944                 edje_object_signal_emit(elm_layout_edje_get(playing_view->layout), "flick_right", "list_content");
1945         }
1946         else
1947         {
1948                 edje_object_signal_emit(elm_layout_edje_get(playing_view->layout), "set_right", "list_content_temp");
1949                 edje_object_signal_emit(elm_layout_edje_get(playing_view->layout), "flick_left", "list_content");
1950         }
1951
1952         edje_object_signal_emit(elm_layout_edje_get(playing_view->layout), "set_default", "list_content_temp");
1953
1954         playing_view->transition_state = true;
1955
1956         if (!playing_view->play_view_screen_mode)
1957         {
1958                 mp_evas_object_del(playing_view->albumart_image);
1959                 playing_view->albumart_image = _mp_play_view_create_bg_map(data, playing_view->play_view, it);
1960                 elm_object_part_content_set(playing_view->play_view, "album_art", playing_view->albumart_image);
1961                 evas_object_show(playing_view->albumart_image);
1962                 evas_object_repeat_events_set(playing_view->albumart_image, 1);
1963         }
1964
1965         return true;
1966 }
1967
1968 static bool
1969 _mp_play_view_push_navibar(void *data)
1970 {
1971         struct appdata *ad = (struct appdata *)data;
1972         MP_CHECK_FALSE(ad);
1973
1974         mp_playing_view *playing_view = ad->playing_view;
1975         MP_CHECK_FALSE(playing_view);
1976         {
1977                 elm_object_part_content_set(playing_view->layout, "list_content", playing_view->play_view);
1978
1979                 mp_playing_view *playing_view = ad->playing_view;
1980                 MP_CHECK_FALSE(playing_view);
1981
1982 #ifdef MP_SOUND_PLAYER
1983                 sp_view_mgr_push_view_content(ad->view_mgr, playing_view->layout, SP_VIEW_TYPE_PLAY);
1984                 sp_view_mgr_set_title_label(ad->view_mgr, GET_SYS_STR("IDS_COM_SK_PLAY"));
1985                 mp_play_view_set_snd_path_sensitivity(ad);
1986 #else
1987                 MP_CHECK_FALSE(ad->naviframe);
1988
1989                 view_data_t *view_data = NULL;
1990                 view_data = evas_object_data_get(ad->naviframe, "view_data");
1991                 MP_CHECK_FALSE(view_data);
1992                 mp_view_manager_push_view_content(view_data, playing_view->layout, MP_VIEW_CONTENT_PLAY);
1993
1994                 MP_TA_ACUM_ITEM_BEGIN("          mp_view_manager_set_title_and_buttons", 0);
1995                 mp_view_manager_set_title_and_buttons(view_data, NULL, ad);
1996                 MP_TA_ACUM_ITEM_END("          mp_view_manager_set_title_and_buttons", 0);
1997 #endif
1998         }
1999
2000         return true;
2001
2002 }
2003
2004 static void
2005 _mp_play_view_play_option_cb(void *data, Evas_Object * obj, const char *emission, const char *source)
2006 {
2007         MP_CHECK(emission);
2008
2009         struct appdata *ad = (struct appdata *)data;
2010         MP_CHECK(ad);
2011
2012         if (!strcmp(emission, "option_1_clicked"))
2013                 mp_menu_share_cb(data, obj, NULL);
2014         else if (!strcmp(emission, "option_2_clicked"))
2015                 mp_menu_set_cb(data, obj, NULL);
2016         else if (!strcmp(emission, "option_3_clicked"))
2017         {
2018                 MP_CHECK(ad->playing_view);
2019                 if (ad->playing_view->play_view_screen_mode != MP_SCREEN_MODE_LANDSCAPE)
2020                         mp_play_view_info_cb(data, obj, NULL);
2021         }
2022 }
2023
2024 static Evas_Object *
2025 _mp_play_view_create_ctrl_layout(void *data, Evas_Object * parents, Evas_Object ** progress, bool remove_signal)
2026 {
2027         struct appdata *ad = (struct appdata *)data;
2028         MP_CHECK_FALSE(ad);
2029
2030         mp_playing_view *playing_view = ad->playing_view;
2031         MP_CHECK_FALSE(playing_view);
2032
2033         Evas_Object *ctrl_layout = NULL;
2034
2035         ctrl_layout = mp_common_load_edj(playing_view->layout, PLAY_VIEW_EDJ_NAME, "music/playing/play_ctrl");
2036
2037         elm_object_part_content_set(parents, "player_info", ctrl_layout);
2038
2039         //2 Create progress bar
2040         if (playing_view->play_view_screen_mode == MP_SCREEN_MODE_LANDSCAPE)
2041                 *progress =
2042                         mp_common_load_edj(playing_view->layout, PLAY_VIEW_EDJ_NAME, "music/playing/progress_box_ls");
2043         else
2044                 *progress = mp_common_load_edj(playing_view->layout, PLAY_VIEW_EDJ_NAME, "music/playing/progress_box");
2045
2046         Evas_Object *play_progress =
2047                 mp_common_load_edj(playing_view->layout, PLAY_VIEW_EDJ_NAME, "music/playing/progress_box/progress_bar");
2048         elm_object_part_content_set(*progress, "progress_bar", play_progress);
2049         evas_object_data_set(*progress, "progress_bar", play_progress);
2050
2051         if (!remove_signal)
2052         {
2053                 edje_object_signal_callback_add(_EDJ(ctrl_layout), "favorite_down", "*", _mp_play_view_favourite_cb,
2054                                                 ad);
2055                 edje_object_signal_callback_add(_EDJ(ctrl_layout), "favorite_up", "*", _mp_play_view_favourite_cb, ad);
2056
2057                 evas_object_event_callback_add(play_progress, EVAS_CALLBACK_MOUSE_DOWN,
2058                                                _mp_play_view_progressbar_down_cb, ad);
2059                 evas_object_event_callback_add(play_progress, EVAS_CALLBACK_MOUSE_UP, _mp_play_view_progressbar_up_cb,
2060                                                ad);
2061                 evas_object_event_callback_add(play_progress, EVAS_CALLBACK_MOUSE_MOVE, _mp_play_progressbar_move_cb,
2062                                                ad);
2063         }
2064
2065         elm_object_part_content_set(playing_view->layout, "player_progress", *progress);
2066
2067         Evas_Object *play_info = mp_common_load_edj(playing_view->layout, PLAY_VIEW_EDJ_NAME, "player_view_info");
2068         elm_object_part_content_set(playing_view->layout, "player_info", play_info);
2069         playing_view->play_title = play_info;
2070
2071         if (playing_view->play_view_screen_mode != MP_SCREEN_MODE_LANDSCAPE)
2072         {
2073                 Evas_Object *play_options =
2074                         mp_common_load_edj(playing_view->layout, PLAY_VIEW_EDJ_NAME, "player_view_options");
2075
2076                 edje_object_part_text_set(_EDJ(play_options), "option_1", GET_SYS_STR("IDS_COM_BUTTON_SHARE"));
2077                 mp_language_mgr_register_object(play_options, OBJ_TYPE_EDJE_OBJECT, "option_1", "IDS_COM_BUTTON_SHARE");
2078                 edje_object_part_text_set(_EDJ(play_options), "option_2", GET_SYS_STR("IDS_COM_SK_SET"));
2079                 mp_language_mgr_register_object(play_options, OBJ_TYPE_EDJE_OBJECT, "option_2", "IDS_COM_SK_SET");
2080                 edje_object_part_text_set(_EDJ(play_options), "option_3", GET_SYS_STR("IDS_COM_BODY_DETAILS"));
2081                 mp_language_mgr_register_object(play_options, OBJ_TYPE_EDJE_OBJECT, "option_3", "IDS_COM_BODY_DETAILS");
2082
2083                 elm_object_part_content_set(playing_view->layout, "player_options", play_options);
2084
2085                 edje_object_signal_callback_add(_EDJ(play_options), "option_1_clicked", "*", _mp_play_view_play_option_cb,
2086                                                 ad);
2087                 edje_object_signal_callback_add(_EDJ(play_options), "option_2_clicked", "*", _mp_play_view_play_option_cb,
2088                                                 ad);
2089                 edje_object_signal_callback_add(_EDJ(play_options), "option_3_clicked", "*", _mp_play_view_play_option_cb,
2090                                                 ad);
2091         }
2092
2093         return ctrl_layout;
2094 }
2095
2096 static void
2097 _mp_play_view_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
2098 {
2099         struct appdata *ad = data;
2100         MP_CHECK(ad);
2101
2102         mp_playing_view *playing_view = ad->playing_view;
2103         MP_CHECK(playing_view);
2104
2105         Evas_Coord w, h;
2106         edje_object_part_geometry_get(_EDJ(playing_view->play_view), "album_bg", NULL, NULL, &w, &h);
2107         mp_debug("album bg size =  [%d * %d]", w, h);
2108
2109         if (playing_view->albumart_bg)
2110         {
2111                 evas_object_image_load_size_set(playing_view->albumart_bg, w, h);
2112                 evas_object_image_fill_set(playing_view->albumart_bg, 0, 0, w, h);
2113         }
2114 }
2115
2116
2117 static bool
2118 _mp_play_view_create_playing_layout(void *data, Evas_Object * parents_layout, bool b_next)
2119 {
2120         startfunc;
2121
2122         struct appdata *ad = (struct appdata *)data;
2123         MP_CHECK_FALSE(ad);
2124
2125         mp_playing_view *playing_view = ad->playing_view;
2126         MP_CHECK_FALSE(playing_view);
2127
2128         //2 Create playing view
2129         if (playing_view->play_view_screen_mode == MP_SCREEN_MODE_LANDSCAPE)
2130                 playing_view->play_view =
2131                         mp_common_load_edj(parents_layout, PLAY_VIEW_EDJ_NAME, "mp_play_view_landscape");
2132         else
2133                 playing_view->play_view = mp_common_load_edj(parents_layout, PLAY_VIEW_EDJ_NAME, "mp_play_view");
2134
2135         MP_CHECK_FALSE(playing_view->play_view);
2136
2137         evas_object_event_callback_add(playing_view->play_view, EVAS_CALLBACK_RESIZE, _mp_play_view_resize_cb, ad);
2138
2139         //hide mute popup
2140         edje_object_signal_emit(_EDJ(playing_view->play_view), SIGNAL_MAIN_MUTE_HIDE, "*");
2141
2142         Evas_Object *event_box = mp_smart_event_box_add(playing_view->play_view);
2143
2144         evas_object_size_hint_weight_set(event_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2145         evas_object_size_hint_align_set(event_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
2146         evas_object_smart_callback_add(event_box, "mouse.clicked", _mp_play_view_eventbox_clicked_cb, ad);
2147         evas_object_smart_callback_add(event_box, "mouse.flick.left", _mp_play_view_eventbox_flick_left_cb, ad);
2148         evas_object_smart_callback_add(event_box, "mouse.flick.right", _mp_play_view_eventbox_flick_right_cb, ad);
2149
2150         evas_object_show(event_box);
2151         elm_object_part_content_set(playing_view->play_view, "event_box", event_box);
2152         evas_object_data_set(playing_view->play_view, "event_box", event_box);
2153
2154         if (playing_view->play_view_screen_mode == MP_SCREEN_MODE_LANDSCAPE)
2155         {                       // landscape mode
2156                 playing_view->albumart_img = elm_bg_add(playing_view->play_view);
2157                 elm_bg_load_size_set(playing_view->albumart_img, MP_PLAY_VIEW_ARTWORK_SIZE, MP_PLAY_VIEW_ARTWORK_SIZE);
2158                 elm_object_part_content_set(playing_view->play_view, "album_art", playing_view->albumart_img);
2159         }
2160         else
2161         {
2162                 mp_evas_object_del(playing_view->albumart_bg);
2163                 playing_view->albumart_bg = evas_object_image_add(ad->evas);
2164                 elm_object_part_content_set(playing_view->play_view, "album_bg", playing_view->albumart_bg);
2165         }
2166
2167         playing_view->play_ctrl =
2168                 _mp_play_view_create_ctrl_layout(ad, playing_view->play_view, &playing_view->play_progressbar, FALSE);
2169
2170         _mp_play_view_progress_visible_set(ad, TRUE);
2171         _mp_play_progress_val_set(ad, 0.0);
2172
2173         evas_object_show(playing_view->play_progressbar);
2174
2175         endfunc;
2176
2177         return TRUE;
2178 }
2179
2180 static Eina_Bool
2181 _mp_play_view_idler_cb(void *data)
2182 {
2183         startfunc;
2184
2185         struct appdata *ad = (struct appdata *)data;
2186         MP_CHECK_FALSE(ad);
2187         MP_CHECK_FALSE(ad->playing_view->albumart_bg);
2188
2189         Evas_Coord img_x, img_y, img_w, img_h;
2190         evas_object_geometry_get(ad->playing_view->albumart_bg, &img_x, &img_y, &img_w, &img_h);
2191
2192         ad->album_image_w = img_w;
2193         ad->album_image_h = img_h;
2194
2195         _mp_play_view_album_art_update(ad);
2196         ad->playview_show_idler = NULL;
2197
2198         endfunc;
2199         return EINA_FALSE;
2200 }
2201
2202 static bool
2203 _mp_play_view_create_layout(void *data)
2204 {
2205         startfunc;
2206
2207         struct appdata *ad = (struct appdata *)data;
2208         MP_CHECK_FALSE(ad);
2209
2210         mp_playing_view *playing_view = ad->playing_view;
2211         MP_CHECK_FALSE(playing_view);
2212
2213         //2 Create main layout
2214
2215         if (playing_view->layout)
2216         {
2217                 mp_debug("already created skip create layout");
2218                 return TRUE;
2219         }
2220
2221         {
2222                 Evas_Object *parent = NULL;
2223 #ifdef MP_SOUND_PLAYER
2224                 parent = sp_view_mgr_get_naviframe(ad->view_mgr);
2225 #else
2226                 MP_CHECK_FALSE(ad->naviframe);
2227                 parent = ad->naviframe;
2228 #endif
2229                 playing_view->layout =
2230                         mp_common_load_edj(parent, PLAY_VIEW_EDJ_NAME, "mp_play_view_layout");
2231                 MP_CHECK_FALSE(playing_view->layout);
2232         }
2233
2234         MP_CHECK_FALSE(playing_view->layout);
2235         evas_object_event_callback_add(playing_view->layout, EVAS_CALLBACK_DEL, _mp_play_view_destory_cb, playing_view);
2236         //2 Create playing view
2237         MP_TA_ACUM_ITEM_BEGIN("      mp_play_view_create_playing_layout", 0);
2238         _mp_play_view_create_playing_layout(ad, playing_view->layout, FALSE);
2239         MP_TA_ACUM_ITEM_END("      mp_play_view_create_playing_layout", 0);
2240
2241         //2 Create menu layout
2242         _mp_play_view_create_menu(ad);
2243
2244         //2 Create control bar
2245         _mp_play_view_create_control_bar(ad);
2246
2247         //2 Push at navibar
2248         MP_TA_ACUM_ITEM_BEGIN("      mp_play_view_push_navibar", 0);
2249         _mp_play_view_push_navibar(ad);
2250         MP_TA_ACUM_ITEM_END("      mp_play_view_push_navibar", 0);
2251
2252         if(!ad->playview_show_idler)
2253                 ad->playview_show_idler = ecore_idler_add(_mp_play_view_idler_cb, ad);
2254
2255         mp_debug("");
2256
2257         endfunc;
2258
2259         return true;
2260 }
2261
2262 void
2263 _mp_play_view_delete_progress_timer(void *data)
2264 {
2265         struct appdata *ad = (struct appdata *)data;
2266         MP_CHECK(ad);
2267
2268         mp_playing_view *playing_view = ad->playing_view;
2269         MP_CHECK(playing_view);
2270
2271         mp_ecore_timer_del(playing_view->progressbar_timer);
2272 }
2273
2274 bool
2275 mp_play_view_set_menu_state(void *data, bool show, bool anim)
2276 {
2277         struct appdata *ad = (struct appdata *)data;
2278         MP_CHECK_FALSE(ad);
2279
2280         ad->show_optional_menu = show;
2281
2282         if (!show)
2283         {
2284                 mp_debug("set hide state");
2285
2286                 mp_ecore_timer_del(ad->longpress_timer);
2287
2288                 _mp_play_view_menu_visible_set(ad, FALSE, anim);
2289         }
2290         else
2291         {
2292                 mp_debug("set show state");
2293
2294                 _mp_play_view_menu_visible_set(ad, TRUE, anim);
2295         }
2296
2297         return true;
2298
2299 }
2300
2301 void
2302 mp_play_view_progress_timer_thaw(void *data)
2303 {
2304         struct appdata *ad = (struct appdata *)data;
2305         MP_CHECK(ad);
2306
2307         mp_playing_view *playing_view = ad->playing_view;
2308         MP_CHECK(playing_view);
2309         MP_CHECK(playing_view->progressbar_timer);
2310
2311         if (ad->player_state == PLAY_STATE_PLAYING)
2312         {
2313                 ecore_timer_thaw(playing_view->progressbar_timer);
2314         }
2315         else if (ad->player_state == PLAY_STATE_PAUSED)
2316         {
2317                 mp_play_view_update_progressbar(ad);
2318         }
2319 }
2320
2321 void
2322 mp_play_view_progress_timer_freeze(void *data)
2323 {
2324         struct appdata *ad = (struct appdata *)data;
2325         MP_CHECK(ad);
2326
2327         mp_playing_view *playing_view = ad->playing_view;
2328         MP_CHECK(playing_view);
2329
2330         if (playing_view->progressbar_timer)
2331         {
2332                 ecore_timer_freeze(playing_view->progressbar_timer);
2333         }
2334 }
2335
2336 void
2337 mp_play_view_update_progressbar(void *data)
2338 {
2339         struct appdata *ad = (struct appdata *)data;
2340         MP_CHECK(ad);
2341
2342         mp_playing_view *playing_view = ad->playing_view;
2343         MP_CHECK(playing_view);
2344
2345         music_list_item *current_item = mp_play_list_get_current_item(ad->playing_list);
2346         MP_CHECK(current_item);
2347
2348         char play_time[16] = { 0, };
2349         char total_time[16] = { 0, };
2350
2351         if (ad->music_length > 0.)
2352         {
2353                 if (ad->music_length > 3600.)
2354                 {
2355                         snprintf(total_time, sizeof(total_time), "%" MUSIC_TIME_FORMAT,
2356                                  MUSIC_TIME_ARGS(ad->music_length));
2357                         snprintf(play_time, sizeof(play_time), "%" MUSIC_TIME_FORMAT, MUSIC_TIME_ARGS(ad->music_pos));
2358                 }
2359                 else
2360                 {
2361                         snprintf(total_time, sizeof(total_time), "%" PLAY_TIME_FORMAT,
2362                                  PLAY_TIME_ARGS(ad->music_length));
2363                         snprintf(play_time, sizeof(play_time), "%" PLAY_TIME_FORMAT, PLAY_TIME_ARGS(ad->music_pos));
2364                 }
2365         }
2366         else
2367         {                       //if the duration which is getting from mmfw is 0, it will use  duration which is getting from mp-svc
2368                 snprintf(total_time, sizeof(total_time), "%s", current_item->time);
2369                 snprintf(play_time, sizeof(play_time), "%" PLAY_TIME_FORMAT, PLAY_TIME_ARGS(ad->music_pos));
2370         }
2371
2372         double played_ratio = 0.;
2373         if(ad->music_length > 0. && ad->music_pos > 0.)
2374                 played_ratio = ad->music_pos / ad->music_length;
2375         _mp_play_progress_val_set(ad, played_ratio);
2376         edje_object_part_text_set(_EDJ(playing_view->play_progressbar), "progress_text_total", total_time);
2377         edje_object_part_text_set(_EDJ(playing_view->play_progressbar), "progress_text_playing", play_time);
2378
2379         _mp_play_view_progress_visible_set(ad, TRUE);
2380
2381         return;
2382
2383 }
2384
2385 bool
2386 mp_play_view_stop_transit(void *data)
2387 {
2388         struct appdata *ad = (struct appdata *)data;
2389         MP_CHECK_FALSE(ad);
2390
2391         mp_playing_view *playing_view = ad->playing_view;
2392         MP_CHECK_FALSE(playing_view);
2393
2394         if (playing_view->play_view_next && playing_view->playing_list_item)
2395         {
2396                 mp_play_list_set_current_item(ad, ad->playing_list, playing_view->playing_list_item->key_id);
2397                 mp_play_view_refresh(ad);
2398                 _mp_play_view_clear_next_view(data);
2399                 _mp_play_view_init_progress_bar(data);
2400                 edje_object_signal_callback_del(elm_layout_edje_get(playing_view->layout), "transit_done", "*",
2401                                                 _mp_play_view_transit_by_item_complete_cb);
2402         }
2403
2404         return true;
2405 }
2406
2407 static void
2408 _mp_play_view_album_art_update(void *data)
2409 {
2410         struct appdata *ad = (struct appdata *)data;
2411         MP_CHECK(ad);
2412         mp_playing_view *playing_view = ad->playing_view;
2413         MP_CHECK(playing_view);
2414
2415         Evas_Coord img_x, img_y, img_w, img_h;
2416         evas_object_geometry_get(playing_view->albumart_image, &img_x, &img_y, &img_w, &img_h);
2417         if ( playing_view->albumart_width <= 0 && playing_view->albumart_height <= 0
2418             && ad->album_image_w > 0 && ad->album_image_h > 0
2419             && img_w == ad->album_image_w && img_h == ad->album_image_h ) {
2420                 playing_view->albumart_width = img_w;
2421                 playing_view->albumart_height = img_h;
2422         }
2423         DEBUG_TRACE ("albumart_width=%d, albumart_height=%d", playing_view->albumart_width, playing_view->albumart_height);
2424
2425         if (0 == img_x && playing_view->albumart_width == img_w && playing_view->albumart_height == img_h)
2426         {
2427                 mp_evas_object_del(playing_view->pre_albumart_image_reflection);
2428         }
2429         if (ad->info_ug_base && !ad->info_back_play_view_flag)
2430         {
2431                 EVAS_OBJ_HIDE(playing_view->albumart_image_reflection);
2432                 EVAS_OBJ_HIDE(playing_view->pre_albumart_image_reflection);
2433         }
2434         else
2435         {
2436                 EVAS_OBJ_SHOW(playing_view->albumart_image_reflection);
2437                 EVAS_OBJ_SHOW(playing_view->pre_albumart_image_reflection);
2438         }
2439
2440         double zoomx = 1.0, zoomy = 1.0;
2441         int x = 0, y = 0;
2442         int albumart_image_raw_w = 0, albumart_image_raw_h = 0;
2443         int albumart_image_x = 0, albumart_image_y = 0, albumart_image_w = 0, albumart_image_h = 0;
2444
2445         if (playing_view->albumart_image_reflection)
2446         {
2447                 if (playing_view->flick_direction == 1)
2448                 {
2449                         x = img_x + playing_view->albumart_width;
2450                 }
2451                 else if (playing_view->flick_direction == 2)
2452                 {
2453                         x = img_x - playing_view->albumart_width;
2454                 }
2455                 y = img_y + playing_view->albumart_height;
2456
2457                 evas_object_geometry_get(playing_view->albumart_image_reflection, &albumart_image_x,
2458                                          &albumart_image_y, &albumart_image_w, &albumart_image_h);
2459                 evas_object_image_size_get(playing_view->albumart_image_reflection, &albumart_image_raw_w,
2460                                            &albumart_image_raw_h);
2461
2462                 x = x - (albumart_image_raw_w - playing_view->albumart_width) / 2;
2463                 y = y - (albumart_image_raw_h - playing_view->albumart_height) / 2;
2464                 zoomx = playing_view->albumart_width / ((double)albumart_image_raw_w);
2465                 zoomy = playing_view->albumart_height / ((double)albumart_image_raw_h);
2466
2467                 Evas_Map *m2 = evas_map_new(4);
2468                 MP_CHECK(m2);
2469                 evas_map_smooth_set(m2, EINA_TRUE);
2470                 evas_map_point_coord_set(m2, 0, x, y, 0);
2471                 evas_map_point_image_uv_set(m2, 0, 0, albumart_image_raw_h);
2472                 if (img_x == 0 && playing_view->hide_image_flag)
2473                 {
2474                         evas_map_point_color_set(m2, 0, ALBUMART_IMAGE_SHADOW_RGBA1);
2475                 }
2476                 else
2477                 {
2478                         evas_map_point_color_set(m2, 0, ALBUMART_IMAGE_SHADOW_RGBA);
2479                 }
2480
2481                 evas_map_point_coord_set(m2, 1, (x + albumart_image_raw_w), y, 0);
2482                 evas_map_point_image_uv_set(m2, 1, albumart_image_raw_w, albumart_image_raw_h);
2483                 if (img_x == 0 && playing_view->hide_image_flag)
2484                 {
2485                         evas_map_point_color_set(m2, 1, ALBUMART_IMAGE_SHADOW_RGBA1);
2486                 }
2487                 else
2488                 {
2489                         evas_map_point_color_set(m2, 1, ALBUMART_IMAGE_SHADOW_RGBA);
2490                 }
2491
2492                 evas_map_point_coord_set(m2, 2, (x + albumart_image_raw_w), (y + albumart_image_raw_h), 0);
2493                 evas_map_point_image_uv_set(m2, 2, albumart_image_raw_w, 0);
2494                 evas_map_point_color_set(m2, 2, ALBUMART_IMAGE_SHADOW_RGBA2);
2495
2496                 evas_map_point_coord_set(m2, 3, x, (y + albumart_image_raw_h), 0);
2497                 evas_map_point_image_uv_set(m2, 3, 0, 0);
2498                 evas_map_point_color_set(m2, 3, ALBUMART_IMAGE_SHADOW_RGBA2);
2499
2500                 evas_map_util_3d_rotate(m2, 0, 0, 0, x + (albumart_image_raw_w / 2), y + (albumart_image_raw_h / 2), 0);
2501                 evas_map_util_3d_perspective(m2, x, y, 0, albumart_image_raw_w * 10);
2502                 evas_map_util_zoom(m2, zoomx, zoomy, x + (albumart_image_raw_w / 2), y + (albumart_image_raw_h / 2));
2503                 evas_object_map_enable_set(playing_view->albumart_image_reflection, EINA_TRUE);
2504                 evas_object_map_set(playing_view->albumart_image_reflection, m2);
2505                 evas_map_free(m2);
2506
2507                 evas_object_repeat_events_set(playing_view->albumart_image_reflection, 1);
2508         }
2509
2510         if (playing_view->pre_albumart_image_reflection)
2511         {
2512                 x = img_x;
2513                 y = img_y + playing_view->albumart_height;
2514                 evas_object_geometry_get(playing_view->pre_albumart_image_reflection, &albumart_image_x,
2515                                          &albumart_image_y, &albumart_image_w, &albumart_image_h);
2516                 evas_object_image_size_get(playing_view->pre_albumart_image_reflection, &albumart_image_raw_w,
2517                                            &albumart_image_raw_h);
2518                 x = x - (albumart_image_raw_w - playing_view->albumart_width) / 2;
2519                 y = y - (albumart_image_raw_h - playing_view->albumart_height) / 2;
2520                 zoomx = playing_view->albumart_width / ((double)albumart_image_raw_w);
2521                 zoomy = playing_view->albumart_height / ((double)albumart_image_raw_h);
2522
2523                 Evas_Map *m4 = evas_map_new(4);
2524                 MP_CHECK(m4);
2525                 evas_map_smooth_set(m4, EINA_TRUE);
2526                 evas_map_point_coord_set(m4, 0, x, y, 0);
2527                 evas_map_point_image_uv_set(m4, 0, 0, albumart_image_raw_h);
2528                 if (img_x == 0 && playing_view->hide_image_flag)
2529                 {
2530                         evas_map_point_color_set(m4, 0, ALBUMART_IMAGE_SHADOW_RGBA1);
2531                 }
2532                 else
2533                 {
2534                         evas_map_point_color_set(m4, 0, ALBUMART_IMAGE_SHADOW_RGBA);
2535                 }
2536
2537                 evas_map_point_coord_set(m4, 1, (x + albumart_image_raw_w), y, 0);
2538                 evas_map_point_image_uv_set(m4, 1, albumart_image_raw_w, albumart_image_raw_h);
2539                 if (img_x == 0 && playing_view->hide_image_flag)
2540                 {
2541                         evas_map_point_color_set(m4, 1, ALBUMART_IMAGE_SHADOW_RGBA1);
2542                 }
2543                 else
2544                 {
2545                         evas_map_point_color_set(m4, 1, ALBUMART_IMAGE_SHADOW_RGBA);
2546                 }
2547
2548                 evas_map_point_coord_set(m4, 2, (x + albumart_image_raw_w), (y + albumart_image_raw_h), 0);
2549                 evas_map_point_image_uv_set(m4, 2, albumart_image_raw_w, 0);
2550                 evas_map_point_color_set(m4, 2, ALBUMART_IMAGE_SHADOW_RGBA2);
2551
2552                 evas_map_point_coord_set(m4, 3, x, (y + albumart_image_raw_h), 0);
2553                 evas_map_point_image_uv_set(m4, 3, 0, 0);
2554                 evas_map_point_color_set(m4, 3, ALBUMART_IMAGE_SHADOW_RGBA2);
2555
2556                 evas_map_util_3d_rotate(m4, 0, 0, 0, x + (albumart_image_raw_w / 2), y + (albumart_image_raw_h / 2), 0);
2557                 evas_map_util_zoom(m4, zoomx, zoomy, x + (albumart_image_raw_w / 2), y + (albumart_image_raw_h / 2));
2558                 evas_map_util_3d_perspective(m4, x, y, 0, albumart_image_raw_w * 10);
2559                 evas_object_map_enable_set(playing_view->pre_albumart_image_reflection, EINA_TRUE);
2560                 evas_object_map_set(playing_view->pre_albumart_image_reflection, m4);
2561                 evas_map_free(m4);
2562         }
2563 }
2564
2565
2566 static void
2567 _mp_play_view_bg_map_move(void *data, Evas * e, Evas_Object * obj, void *event_info)
2568 {
2569         struct appdata *ad = (struct appdata *)data;
2570         MP_CHECK(ad);
2571         mp_playing_view *playing_view = ad->playing_view;
2572         MP_CHECK(ad->playing_view);
2573
2574         _mp_play_view_album_art_update(data);
2575
2576         if (playing_view->hide_image_flag && playing_view->flick_direction == 0)
2577         {
2578                 EVAS_OBJ_HIDE(playing_view->pre_albumart_image_reflection);
2579         }
2580
2581         EVAS_OBJ_SHOW(obj);
2582 }
2583
2584 static void
2585 _mp_play_view_bg_map_resize(void *data, Evas * e, Evas_Object * obj, void *event_info)
2586 {
2587         startfunc;
2588
2589         struct appdata *ad = (struct appdata *)data;
2590         MP_CHECK(ad);
2591         mp_playing_view *playing_view = ad->playing_view;
2592         MP_CHECK(playing_view);
2593
2594         playing_view->hide_image_flag = true;
2595
2596         if (playing_view->hide_image_flag && playing_view->flick_direction == 0)
2597         {
2598                 EVAS_OBJ_HIDE(playing_view->pre_albumart_image_reflection);
2599         }
2600
2601         endfunc;
2602 }
2603
2604
2605 static void
2606 _mp_play_view_bg_map_hide(void *data, Evas * e, Evas_Object * obj, void *event_info)
2607 {
2608         startfunc;
2609
2610         endfunc;
2611 }
2612
2613 static void
2614 _mp_play_view_bg_map_show(void *data, Evas * e, Evas_Object * obj, void *event_info)
2615 {
2616         startfunc;
2617
2618         if (!data)
2619         {
2620                 return;
2621         }
2622
2623         _mp_play_view_album_art_update(data);
2624         EVAS_OBJ_SHOW(obj);
2625
2626         endfunc;
2627 }
2628
2629 static void
2630 _mp_play_view_texture_destory_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
2631 {
2632         startfunc;
2633         struct appdata *ad = (struct appdata *)data;
2634         MP_CHECK(ad);
2635         MP_CHECK(ad->playing_view);
2636
2637         if(obj == ad->playing_view->albumart_image_reflection)
2638                 ad->playing_view->albumart_image_reflection = NULL;
2639         else if(obj == ad->playing_view->pre_albumart_image_reflection)
2640                 ad->playing_view->pre_albumart_image_reflection = NULL;
2641         else
2642                 ERROR_TRACE("++++++++ check here ++++++++++");
2643 }
2644
2645 static Evas_Object *
2646 _mp_play_view_load_texture(void *data, const char *const tex_path, const int tex_size_width, const int tex_size_height)
2647 {
2648         struct appdata *ad = (struct appdata *)data;
2649         MP_CHECK_NULL(ad);
2650
2651         Evas_Object *o = evas_object_image_add(ad->evas);
2652         evas_object_image_file_set(o, tex_path, NULL);
2653         int w = 0, h = 0;
2654         evas_object_image_size_get(o, &w, &h);
2655         evas_object_image_fill_set(o, 0, 0, w, h);
2656         evas_object_resize(o, w, h);
2657         evas_object_image_smooth_scale_set(o, 0);
2658
2659         evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _mp_play_view_texture_destory_cb, ad);
2660
2661         EVAS_OBJ_HIDE(o);
2662         return o;
2663 }
2664
2665 static void
2666 _mp_play_view_set_album_art(void *data, char *file_path)
2667 {
2668         startfunc;
2669         struct appdata *ad = (struct appdata *)data;
2670         MP_CHECK(ad);
2671         mp_playing_view *playing_view = ad->playing_view;
2672         MP_CHECK(ad->playing_view);
2673
2674         EVAS_OBJ_HIDE(playing_view->albumart_image);
2675
2676         if (playing_view->albumart_image_reflection)
2677         {
2678                 mp_evas_object_del(playing_view->pre_albumart_image_reflection);
2679                 playing_view->pre_albumart_image_reflection = playing_view->albumart_image_reflection;
2680                 playing_view->albumart_image_reflection = NULL;
2681                 evas_object_hide(playing_view->pre_albumart_image_reflection);
2682                 playing_view->hide_image_flag = false;
2683         }
2684         playing_view->albumart_image_reflection =
2685                 _mp_play_view_load_texture(data, file_path, 0, 0);
2686
2687         endfunc;
2688 }
2689
2690 Evas_Object *
2691 _mp_play_view_create_bg_map(void *data, Evas_Object * parents, music_list_item * current_item)
2692 {
2693         startfunc;
2694         struct appdata *ad = (struct appdata *)data;
2695         MP_CHECK_NULL(ad);
2696         MP_CHECK_NULL(parents);
2697         mp_playing_view *playing_view = ad->playing_view;
2698         MP_CHECK_NULL(ad->playing_view);
2699
2700         Evas_Object *obj = NULL;
2701         Evas *evas = NULL;
2702
2703         evas = evas_object_evas_get(parents);
2704
2705         if (evas == NULL)
2706         {
2707                 return NULL;
2708         }
2709
2710         obj = edje_object_add(evas);
2711
2712         MP_CHECK_NULL(current_item);
2713
2714         //2 get alubmart
2715         if (!strstr(PREFIX, current_item->albumart) && mp_util_is_image_valid(ad->evas, current_item->albumart))
2716         {
2717                 mp_debug(" draw album art");
2718                 _mp_play_view_set_album_art(data, current_item->albumart);
2719         }
2720         else
2721         {
2722                 _mp_play_view_set_album_art(data, DEFAULT_THUMBNAIL);
2723         }
2724
2725         if (playing_view->albumart_image_reflection)
2726         {
2727                 evas_object_smart_member_add(playing_view->albumart_image_reflection, obj);
2728         }
2729
2730         evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _mp_play_view_bg_map_resize, data);
2731         evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _mp_play_view_bg_map_move, data);
2732         evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _mp_play_view_bg_map_show, data);
2733         evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _mp_play_view_bg_map_hide, data);
2734
2735         endfunc;
2736         return obj;
2737 }
2738
2739 static void
2740 _mp_play_view_update_option_btn_sensitivity(struct appdata *ad)
2741 {
2742         startfunc;
2743
2744         MP_CHECK(ad);
2745         mp_playing_view *playing_view = ad->playing_view;
2746         MP_CHECK(playing_view);
2747
2748         music_list_item *current_item = mp_play_list_get_current_item(ad->playing_list);
2749         MP_CHECK(current_item);
2750
2751         const char *filename =current_item->filename;
2752
2753         if (playing_view->play_view_screen_mode != MP_SCREEN_MODE_LANDSCAPE)
2754         {
2755                 Evas_Object *play_options = elm_object_part_content_get(playing_view->layout, "player_options");
2756                 MP_CHECK(play_options);
2757
2758                 const char *signal = NULL;
2759                 if (mp_check_file_exist(filename))
2760                         signal = "sig_enable_option_btn";
2761                 else
2762                         signal = "sig_disable_option_btn";
2763
2764                 edje_object_signal_emit(_EDJ(play_options), signal, "c_source");
2765         }
2766 }
2767
2768
2769 bool
2770 mp_play_view_load_track(void *data)
2771 {
2772         startfunc;
2773
2774         struct appdata *ad = (struct appdata *)data;
2775         MP_CHECK_FALSE(ad);
2776
2777         mp_playing_view *playing_view = ad->playing_view;
2778         MP_CHECK_FALSE(playing_view);
2779         MP_CHECK_FALSE(ad->playing_list);
2780
2781         music_list_item *current_item = mp_play_list_get_current_item(ad->playing_list);
2782         MP_CHECK_FALSE(current_item);
2783
2784         DEBUG_TRACE("ad->screen_mode=%d,flick_direction=%d", ad->screen_mode, playing_view->flick_direction);
2785         if (playing_view->play_view_screen_mode)
2786         {                       // landscape mode
2787                 // get alubmart
2788                 if (!strstr(PREFIX, current_item->albumart) && mp_util_is_image_valid(ad->evas, current_item->albumart))
2789                 {
2790                         elm_bg_file_set(playing_view->albumart_img, current_item->albumart, NULL);
2791                 }
2792                 else
2793                 {
2794                         elm_bg_file_set(playing_view->albumart_img, DEFAULT_THUMBNAIL, NULL);
2795                 }
2796                 evas_object_show(playing_view->albumart_img);
2797         }
2798         else
2799         {                       //portrait mode
2800                 if (playing_view->flick_direction || MP_SCREEN_MODE_PORTRAIT == ad->screen_mode)
2801                 {
2802                         // get alubmart
2803                         if (!strstr(PREFIX, current_item->albumart) && mp_util_is_image_valid(ad->evas, current_item->albumart))
2804                         {
2805                                 evas_object_image_file_set(playing_view->albumart_bg, current_item->albumart, NULL);
2806                         }
2807                         else
2808                         {
2809                                 evas_object_image_file_set(playing_view->albumart_bg, DEFAULT_THUMBNAIL, NULL);
2810                         }
2811                         evas_object_show(playing_view->albumart_bg);
2812
2813                         mp_evas_object_del(playing_view->albumart_image);
2814                         music_list_item *current_item = mp_play_list_get_current_item(ad->playing_list);
2815                         playing_view->albumart_image =
2816                                 _mp_play_view_create_bg_map(data, playing_view->play_view, current_item);
2817                         elm_object_part_content_set(playing_view->play_view, "album_art", playing_view->albumart_image);
2818                         evas_object_show(playing_view->albumart_image);
2819                         evas_object_repeat_events_set(playing_view->albumart_image, 1);
2820                         playing_view->flick_direction = 0;
2821                 }
2822         }
2823
2824         MP_TA_ACUM_ITEM_BEGIN("        _mp_play_view_load_track_info", 0);
2825         _mp_play_view_load_track_info(data, mp_play_list_get_current_item(ad->playing_list));
2826         MP_TA_ACUM_ITEM_END("        _mp_play_view_load_track_info", 0);
2827
2828         /* disable share/set button when file do not exist */
2829         _mp_play_view_update_option_btn_sensitivity(ad);
2830
2831         endfunc;
2832
2833         return true;
2834 }
2835
2836 #ifndef MP_SOUND_PLAYER
2837 /**
2838  * load play view by path use for add to home case
2839  *
2840  * @param struct appdata *ad, char *path, int fid
2841  * @return FALSE or TRUE if it success create
2842  * @author aramie.kim@samsung.com
2843  */
2844
2845 bool
2846 mp_play_view_load_by_path(struct appdata * ad, char *path)
2847 {
2848         MP_CHECK_FALSE(ad);
2849         MP_CHECK_FALSE(path);
2850
2851         //create play list and set playing request item
2852         mp_play_list_create_by_path(ad, &ad->playing_list, path);
2853
2854         //reget current item
2855         music_list_item *current_item = mp_play_list_get_current_item(ad->playing_list);;
2856         MP_CHECK_FALSE(current_item);
2857
2858         DEBUG_TRACE("current_item->artist: %s", current_item->artist);
2859
2860         mp_setting_save_last_played(NULL);
2861
2862         mp_play_destory(ad);
2863         ad->paused_by_user = FALSE;
2864
2865         if (ad->playing_view)
2866         {
2867                 mp_evas_object_del(ad->playing_view->play_control);
2868                 _mp_play_view_create_control_bar(ad);
2869                 mp_play_view_play_item(ad, current_item, false, true);
2870         }
2871         else
2872         {
2873                 mp_play_view_load(ad);
2874                 MP_CHECK_FALSE(ad->naviframe);
2875                 evas_object_smart_callback_add(ad->naviframe, "transition,finished",
2876                                                                        _mp_play_view_start_request, ad);
2877         }
2878
2879         return true;
2880 }
2881
2882
2883 static void
2884 _mp_play_view_start_request(void *data, Evas_Object * obj, void *event_info)
2885 {
2886         MP_TA_ACUM_ITEM_END("navi_frame_transition_time", 0);
2887         struct appdata *ad = (struct appdata *)data;
2888         mp_retm_if(!ad, "ad");
2889
2890         mp_playing_view *playing_view = ad->playing_view;
2891         mp_retm_if(!playing_view, "ad");
2892
2893         startfunc;
2894         ad->paused_by_user = FALSE;
2895         mp_play_new_file(data, TRUE);
2896
2897         _mp_play_view_init_progress_bar(data);
2898
2899         evas_object_smart_callback_del(ad->naviframe, "transition,finished", _mp_play_view_start_request);
2900
2901         endfunc;
2902
2903         return;
2904 }
2905
2906
2907 bool
2908 mp_play_view_load_by_index(mp_layout_data_t * layout_data, int index, bool effect_value)
2909 {
2910         MP_CHECK_FALSE(layout_data);
2911         MP_CHECK_LAYOUT_DATA(layout_data);
2912
2913         struct appdata *ad = layout_data->ad;
2914         MP_CHECK_FALSE(ad);
2915
2916         bool reqest_play = false;
2917         char *latest_key_id = NULL;
2918         bool result = false;
2919
2920         music_list_item *current_item = mp_play_list_get_current_item(ad->playing_list);
2921
2922         if (current_item)
2923                 latest_key_id = g_strdup(current_item->key_id);
2924         else
2925                 reqest_play = true;
2926
2927         MP_TA_ACUM_ITEM_BEGIN("  create_play_list", 0);
2928         mp_media_list_h svc_handle = NULL;
2929         int item_count = 0;
2930         if (layout_data->view_mode == MP_VIEW_MODE_DEFAULT) {
2931                 svc_handle = layout_data->svc_handle;           //set current item here!!1
2932                 item_count = layout_data->item_count;
2933         }
2934         else {
2935                 svc_handle = layout_data->track_handle;         //use track_handle when playback started from search result...
2936                 item_count = layout_data->track_count;
2937         }
2938
2939         result = mp_play_list_create_play_list(ad, svc_handle, item_count, index, layout_data->playlist_id);    //set current item here!!1
2940
2941         MP_TA_ACUM_ITEM_END("  create_play_list", 0);
2942
2943         current_item = mp_play_list_get_current_item(ad->playing_list); //reget current item
2944
2945         MP_CHECK_EXCEP(current_item);
2946         MP_CHECK_EXCEP(result);
2947         MP_CHECK_EXCEP(ad->playing_list);
2948
2949         // TODO: support recent play for voice ui.
2950         if (ad->loadtype != LOAD_VOICE_UI) {
2951                 MP_TA_ACUM_ITEM_BEGIN("  mp_setting_save_last_played", 0);
2952                 mp_setting_save_last_played(layout_data);       //store playlist info.
2953                 MP_TA_ACUM_ITEM_END("  mp_setting_save_last_played", 0);
2954         }
2955
2956         if (layout_data->type_str)
2957                 ad->playing_list->type_string = g_strdup(layout_data->type_str);
2958         if (layout_data->filter_str)
2959                 ad->playing_list->filter_string = g_strdup(layout_data->filter_str);
2960         ad->playing_list->playlist_id = layout_data->playlist_id;
2961
2962
2963         ad->playing_list->item_type = layout_data->track_type;
2964
2965         if (ad->loadtype == LOAD_VOICE_UI)      //when there is no transition effect, directly play track.
2966         {
2967                 ad->paused_by_user = FALSE;
2968                 mp_play_destory(ad);
2969                 mp_play_view_load(ad);
2970                 mp_play_new_file(ad, TRUE);
2971                 _mp_play_view_init_progress_bar(ad);
2972         }
2973         else
2974         {
2975                 if (g_strcmp0(latest_key_id, current_item->key_id))
2976                 {
2977                         reqest_play = true;
2978                         mp_play_destory(ad);
2979                 }
2980
2981                 if (effect_value)
2982                 {
2983                         _mp_play_view_transit_by_item(ad, current_item, true);
2984                 }
2985                 else
2986                 {
2987                         MP_TA_ACUM_ITEM_BEGIN("  mp_play_view_load", 0);
2988                         mp_play_view_load(ad);
2989                         MP_TA_ACUM_ITEM_END("  mp_play_view_load", 0);
2990                         {
2991                                 if (reqest_play)
2992                                         evas_object_smart_callback_add(ad->naviframe, "transition,finished",
2993                                                                        _mp_play_view_start_request, ad);
2994
2995                         }
2996                 }
2997         }
2998
2999         IF_FREE(latest_key_id);
3000         return true;
3001
3002         mp_exception:
3003         IF_FREE(latest_key_id);
3004         return false;
3005
3006 }
3007 #endif
3008
3009 bool
3010 mp_play_view_play_item(void *data, struct music_list_item * it, bool effect_value, bool move_left)
3011 {
3012         struct appdata *ad = (struct appdata *)data;
3013         MP_CHECK_FALSE(ad);
3014
3015         mp_playing_view *playing_view = ad->playing_view;
3016         MP_CHECK_FALSE(playing_view);
3017
3018         MP_CHECK_FALSE(it);
3019         MP_CHECK_FALSE(ad->playing_list);
3020
3021         if (effect_value && (ad->playing_list->count > 1))
3022         {
3023                 if(ad->app_is_foreground)
3024                         _mp_play_view_transit_by_item(data, it, move_left);
3025                 else
3026                 {
3027                         IF_FREE(playing_view->playing_list_item);
3028                         mp_play_list_item_copy(&playing_view->playing_list_item, it);
3029                         mp_play_item_play(ad, playing_view->playing_list_item->key_id);
3030                         mp_play_view_refresh(data);
3031                 }
3032         }
3033         else
3034         {
3035                 if (ad->playing_list)
3036                 {
3037                         MP_CHECK_FALSE(ad->playing_list->current_item);
3038                         mp_play_item_play(data, ad->playing_list->current_item->key_id);
3039                 }
3040                 mp_play_view_refresh(data);
3041         }
3042
3043         return true;
3044 }
3045
3046
3047
3048 bool
3049 mp_play_view_set_screen_mode(void *data, int mode)
3050 {
3051         startfunc;
3052
3053         struct appdata *ad = (struct appdata *)data;
3054         MP_CHECK_FALSE(ad);
3055
3056         if (mode == MP_SCREEN_MODE_LANDSCAPE)
3057         {
3058                 mp_playing_view *playing_view = ad->playing_view;
3059
3060                 if (playing_view)
3061                 {
3062                         playing_view->play_view_screen_mode = mode;
3063
3064                         if (playing_view->layout)
3065                         {
3066                                 evas_object_hide(playing_view->layout);
3067
3068                                 mp_play_view_stop_transit(data);
3069
3070                                 if (playing_view->layout)
3071                                 {
3072                                         ad->backup_layout_play_view = playing_view->layout;
3073                                         playing_view->layout = NULL;
3074                                 }
3075
3076                                 ad->backup_playing_view = playing_view;
3077                                 if(playing_view->progressbar_timer)
3078                                         ecore_timer_freeze(playing_view->progressbar_timer);
3079
3080                                 ad->playing_view = NULL;
3081                         }
3082                 }
3083         }
3084         else
3085         {
3086                 if (mp_play_list_get_current_item(ad->playing_list)
3087                     && ad->backup_playing_view && ad->backup_layout_play_view)
3088                 {
3089                         ad->playing_view = ad->backup_playing_view;
3090                         ad->playing_view->layout = ad->backup_layout_play_view;
3091                         ad->playing_view->play_view_screen_mode = MP_SCREEN_MODE_PORTRAIT;
3092
3093                         mp_play_view_stop_transit(ad);  //reset transition effect
3094
3095                         _mp_play_view_set_menu_item(ad);        //reset menu item
3096
3097                         mp_play_view_refresh(ad);
3098
3099                         evas_object_show(ad->playing_view->layout);
3100                         evas_object_show(ad->base_layout_main);
3101
3102                         ad->backup_playing_view = NULL;
3103                         ad->backup_layout_play_view = NULL;
3104
3105                 }
3106                 else
3107                         evas_object_show(ad->base_layout_main);
3108
3109         }
3110
3111         endfunc;
3112
3113         return true;
3114 }
3115
3116 #ifndef MP_SOUND_PLAYER
3117 bool
3118 mp_play_view_create_library(void *data)
3119 {
3120         // create library view , that function use for loadtype is track , that do not support one one track view
3121         startfunc;
3122
3123         struct appdata *ad = data;
3124         MP_CHECK_FALSE(ad);
3125
3126         if (!ad->base_layout_main)
3127         {
3128                 ad->request_group_type = -1;
3129
3130                 mp_library_create(ad);
3131                 MP_CHECK_FALSE(ad->library);
3132         }
3133
3134         ad->b_add_tracks = 0;
3135         elm_toolbar_item_selected_set(ad->library->ctltab_songs, EINA_TRUE);
3136         Evas_Object *layout = mp_view_manager_get_last_view_layout(ad);
3137         mp_view_layout_set_edit_mode(mp_util_get_layout_data(layout), false);
3138         endfunc;
3139
3140         return true;
3141 }
3142 #endif
3143 /**
3144  * create play view
3145  *
3146  * @param data ,appdata
3147  * @return FALSE or TRUE if it success create
3148  * @author aramie.kim@samsung.com
3149  */
3150
3151 bool
3152 mp_play_view_create(void *data)
3153 {
3154         struct appdata *ad = data;
3155         mp_retvm_if(!ad, FALSE, "ad is invalid");
3156
3157         mp_retvm_if(ad->playing_view != NULL, FALSE, "ad playing_view is is valid exit create");
3158
3159         ad->playing_view = malloc(sizeof(mp_playing_view));
3160         MP_CHECK_FALSE(ad->playing_view);
3161         memset(ad->playing_view, 0, sizeof(mp_playing_view));
3162
3163         ad->playing_view->ad = ad;
3164
3165         _mp_play_view_init(ad);
3166
3167         return true;
3168 }
3169
3170 bool
3171 mp_play_view_destory(void *data)
3172 {
3173         startfunc;
3174         struct appdata *ad = (struct appdata *)data;
3175         MP_CHECK_FALSE(ad);
3176
3177         mp_playing_view *playing_view = ad->playing_view;
3178         MP_CHECK_FALSE(playing_view);
3179
3180         if (playing_view->layout)
3181         {
3182                 mp_evas_object_del(playing_view->layout);       //=> call _mp_play_view_layout_del_cb watchout
3183         }
3184         else
3185                 IF_FREE(ad->playing_view);
3186
3187         return true;
3188 }
3189
3190 bool
3191 mp_play_view_load(void *data)
3192 {
3193         startfunc;
3194
3195         struct appdata *ad = (struct appdata *)data;
3196         MP_CHECK_FALSE(ad);
3197
3198         MP_TA_ACUM_ITEM_BEGIN("    mp_play_view_create", 0);
3199         mp_play_view_create(data);
3200         MP_TA_ACUM_ITEM_END("    mp_play_view_create", 0);
3201
3202         mp_playing_view *playing_view = ad->playing_view;
3203         MP_CHECK_FALSE(playing_view);
3204
3205         MP_TA_ACUM_ITEM_BEGIN("    _mp_play_view_create_layout", 0);
3206         _mp_play_view_create_layout(data);
3207         MP_TA_ACUM_ITEM_END("    _mp_play_view_create_layout", 0);
3208         MP_CHECK_FALSE(playing_view->layout);
3209
3210         MP_TA_ACUM_ITEM_BEGIN("    mp_play_view_refresh", 0);
3211         mp_play_view_refresh(data);
3212         MP_TA_ACUM_ITEM_END("    mp_play_view_refresh", 0);
3213
3214         endfunc;
3215
3216         return true;
3217 }
3218
3219 bool
3220 mp_play_view_pop(void *data)
3221 {
3222         startfunc;
3223         struct appdata *ad = (struct appdata *)data;
3224         MP_CHECK_FALSE(ad);
3225
3226         mp_playing_view *playing_view = ad->playing_view;
3227         MP_CHECK_FALSE(playing_view);
3228 #ifdef MP_SOUND_PLAYER
3229         mp_play_view_unswallow_info_ug_layout(ad);
3230
3231         if (ad->playing_view)
3232                 sp_view_mgr_pop_view_to(ad->view_mgr, SP_VIEW_TYPE_PLAY);
3233 #else
3234         mp_view_manager_pop_play_view(ad);
3235 #endif
3236         endfunc;
3237         return true;
3238 }
3239
3240 bool
3241 mp_play_view_refresh(void *data)
3242 {
3243         startfunc;
3244
3245         struct appdata *ad = (struct appdata *)data;
3246         MP_CHECK_FALSE(ad);
3247
3248         mp_playing_view *playing_view = ad->playing_view;
3249         MP_CHECK_FALSE(playing_view);
3250
3251         MP_TA_ACUM_ITEM_BEGIN("      mp_play_view_load_track", 0);
3252         mp_play_view_load_track(ad);
3253         MP_TA_ACUM_ITEM_END("      mp_play_view_load_track", 0);
3254
3255         mp_play_view_set_menu_state(ad, false, false);
3256
3257         _mp_play_view_init_progress_bar(data);
3258
3259         const Evas_Object *play_icon = elm_object_part_content_get(ad->playing_view->play_control, "buttons");
3260         if (play_icon != NULL)
3261         {
3262                 player_state_e player_state = mp_player_mgr_get_state();
3263                 if (player_state != PLAYER_STATE_PLAYING)
3264                 {
3265                         edje_object_signal_emit(_EDJ(play_icon), "play", CTR_PROG_SIG_SRC);
3266                 }
3267                 else
3268                 {
3269                         edje_object_signal_emit(_EDJ(play_icon), "pause", CTR_PROG_SIG_SRC);
3270                 }
3271         }
3272
3273         endfunc;
3274         return true;
3275 }
3276
3277 #ifdef MP_SOUND_PLAYER
3278 void mp_play_view_unswallow_info_ug_layout(struct appdata *ad)
3279 {
3280         MP_CHECK(ad);
3281
3282         if(ad->info_ug_base)
3283         {
3284                 edje_object_part_unswallow(ad->info_ug_base, ad->info_ug_layout);
3285                 evas_object_hide(ad->info_ug_layout);
3286                 mp_ug_send_message(ad, MP_UG_MESSAGE_DEL);
3287         }
3288 }
3289
3290 #else
3291 static void
3292 _mp_play_view_popup_response_cb(void *data, Evas_Object * obj, void *event_info)
3293 {
3294         mp_evas_object_del(obj);
3295         mp_app_exit(data);
3296 }
3297
3298 bool
3299 mp_play_view_load_by_voice_ui(struct appdata *ad, const char *request_title)
3300 {
3301         startfunc;
3302         MP_CHECK_FALSE(ad);
3303
3304         bool success = true;
3305         char *popup_txt = NULL;
3306         mp_layout_data_t *layout_data = NULL;
3307         int index = 0;
3308
3309         switch (ad->launch_type)
3310         {
3311         case MP_LAUNCH_PLAY_RECENT:
3312                 {
3313                         if (ecore_file_exists(MP_RECENT_PLAYED_INI_FILE_NAME) || !ecore_file_exists(MP_NOWPLAYING_INI_FILE_NAME))
3314                         {
3315                                 layout_data = calloc(1, sizeof(mp_layout_data_t));
3316                                 index = 0;
3317                                 MP_CHECK_FALSE(layout_data);
3318                                 MP_SET_LAYOUT_DATA_MAGIC(layout_data);
3319                                 if (mp_util_get_recent_play_data(layout_data, &index, NULL))
3320                                 {
3321                                         layout_data->ad = ad;
3322
3323                                         mp_play_view_load_by_index(layout_data, index, false);
3324
3325                                         if (layout_data->svc_handle)
3326                                         {
3327                                                 mp_media_info_list_destroy(layout_data->svc_handle);
3328                                         }
3329                                 }
3330                                 else
3331                                 {
3332                                         success = false;
3333                                         popup_txt = GET_SYS_STR("IDS_COM_POP_FILE_NOT_EXIST");
3334                                 }
3335                                 IF_FREE(layout_data->type_str);
3336                                 IF_FREE(layout_data->filter_str);
3337                                 free(layout_data);
3338                         }
3339                         else
3340                         {
3341                                 if (ecore_file_exists(MP_NOWPLAYING_INI_FILE_NAME))
3342                                 {
3343                                         char *path;
3344                                         if (mp_util_get_recent_play_data(NULL, NULL, &path))
3345                                         {
3346                                                 mp_play_view_load_by_path(ad, path);
3347                                                 IF_FREE(path);
3348                                         }
3349                                         else
3350                                         {
3351                                                 success = false;
3352                                                 popup_txt = GET_SYS_STR("IDS_COM_POP_FILE_NOT_EXIST");
3353                                         }
3354                                 }
3355                                 else
3356                                 {
3357                                         success = false;
3358                                         popup_txt = GET_SYS_STR("IDS_COM_POP_FILE_NOT_EXIST");
3359                                 }
3360
3361                         }
3362
3363                         break;
3364                 }
3365         case MP_LAUNCH_PLAY_PLAYLIST:
3366                 {
3367                         layout_data = calloc(1, sizeof(mp_layout_data_t));
3368                         index = 0;
3369                         MP_CHECK_FALSE(layout_data);
3370                         MP_SET_LAYOUT_DATA_MAGIC(layout_data);
3371                         if (mp_util_get_playlist_data(layout_data, &index, request_title))
3372                         {
3373                                 layout_data->ad = ad;
3374
3375                                 mp_play_view_load_by_index(layout_data, index, false);
3376
3377                                 if (layout_data->svc_handle)
3378                                 {
3379                                         mp_media_info_list_destroy(layout_data->svc_handle);
3380                                 }
3381                         }
3382                         else
3383                         {
3384                                 success = false;
3385                                 popup_txt = GET_SYS_STR("IDS_COM_BODY_NO_CONTENTS");
3386                         }
3387                         free(layout_data);
3388                         break;
3389                 }
3390         case MP_LAUNCH_PLAY_GROUP:
3391                 {
3392                         layout_data = calloc(1, sizeof(mp_layout_data_t));
3393                         MP_CHECK_FALSE(layout_data);
3394                         MP_SET_LAYOUT_DATA_MAGIC(layout_data);
3395
3396                         layout_data->ad = ad;
3397                         layout_data->filter_str = (char *)request_title;
3398                         layout_data->track_type = ad->track_type;
3399                         layout_data->group_type = ad->group_type;
3400                         layout_data->playlist_id = -1;
3401
3402                         if (mp_util_get_list_data(layout_data))
3403                         {
3404                                 mp_play_view_load_by_index(layout_data, 0, false);
3405
3406                                 if (layout_data->svc_handle)
3407                                 {
3408                                         mp_media_info_group_list_destroy(layout_data->svc_handle);
3409                                 }
3410                         }
3411                         else
3412                         {
3413                                 success = false;
3414                                 popup_txt = GET_SYS_STR("IDS_COM_BODY_NO_CONTENTS");
3415                         }
3416                         free(layout_data);
3417                         break;
3418                 }
3419         case MP_LAUNCH_PLAY_SOMETHING:
3420                 {
3421                         layout_data = calloc(1, sizeof(mp_layout_data_t));
3422                         MP_CHECK_FALSE(layout_data);
3423                         MP_SET_LAYOUT_DATA_MAGIC(layout_data);
3424
3425                         layout_data->ad = ad;
3426                         layout_data->filter_str = (char *)request_title;
3427                         layout_data->playlist_id = -1;
3428
3429                         if (mp_util_get_list_data(layout_data))
3430                         {
3431                                 layout_data->ad = ad;
3432
3433                                 mp_play_view_load_by_index(layout_data, 0, false);
3434
3435                                 if (layout_data->svc_handle)
3436                                 {
3437                                         mp_media_info_group_list_destroy(layout_data->svc_handle);
3438                                 }
3439                         }
3440                         else
3441                         {
3442                                 success = false;
3443                                 popup_txt = GET_SYS_STR("IDS_COM_BODY_NO_CONTENTS");
3444                         }
3445                         free(layout_data);
3446                         break;
3447                 }
3448
3449         default:
3450                 WARN_TRACE("Unsupported type: %d", ad->launch_type);
3451                 break;
3452         }
3453
3454         if (!success)
3455         {
3456                 Evas_Object *popup = mp_popup_create(ad->win_main, MP_POPUP_NORMAL, NULL, ad, _mp_play_view_popup_response_cb, ad);
3457                 elm_object_text_set(popup, popup_txt);
3458                 mp_popup_button_set(popup, MP_POPUP_BTN_1, GET_SYS_STR("IDS_COM_SK_OK"), MP_POPUP_YES);
3459                 mp_popup_timeout_set(popup, MP_POPUP_TIMEOUT);
3460                 evas_object_show(ad->win_main);
3461                 evas_object_show(popup);
3462         }
3463         endfunc;
3464         return true;
3465 }
3466 #endif
3467