2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <Elementary.h>
20 #include "AppCommon.h"
21 #include <InputHandler.h>
26 #include "song_info.h"
27 #include "album_info.h"
28 #include "music-controller.h"
29 #include "volume-control.h"
31 #include "common-ui.h"
34 #include "playback-view.h"
35 #include "context-view.h"
36 #include "HandleVolume.h"
37 #include <app-res-defines.h>
38 #include "PlaySettingCtxPopup.h"
42 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
43 #define TITLE_FONT_SIZE 50
44 #define ARTIST_FONT_SIZE 30
45 #define TOTAL_CONTROL_BTNS 6
46 #define TOTAL_EDIT_BTNS 3
47 #define S_INTERVAL 1 /* seconds */
48 #define LP_INTERVAL 0.5 /* seconds */
49 #define WAIT_INTERVAL 0.5 /* seconds */
50 #define SLIDER_STEP 5000 /* milli seconds */
51 #define LP_CHANGE 10000 /* milli seconds */
52 #define S_INCREMENT 1000 /* milli seconds */
58 EO_ERROR_POPUP_BUTTON,
62 EO_DELETE, // TOTAL_EDIT_BTNS
69 EO_BTN_FORWARD, // TOTAL_CONTROL_BTNS
80 Elm_Object_Item *item;
87 struct SPlaybackView {
91 CPlaySettingCtxPopup *eoCtxPopup;
92 Evas_Object *eoErrPopup;
93 Evas_Object *eoPlaylist;
95 Elm_Object_Item *focused_item;
97 Evas_Object *eoBtnControl[TOTAL_CONTROL_BTNS];
98 Evas_Object *eoBtnEdit[TOTAL_EDIT_BTNS];
100 Evas_Object *eoAlbumCover;
101 Evas_Object *eoSlider;
102 Evas_Object *eoPressedObj;
105 Ecore_Timer *etSlider;
106 Ecore_Timer *etLongPress;
108 CMusicController *hMusicController; //! NOT NULL
111 SItemInfo *cs_itinfo;
112 SContentInfo *ctxtinfo;
115 CHandleVolume *pHandleVolume;
118 memset(this, 0, sizeof(SPlaybackView));
119 pHandleVolume = new CHandleVolume;
122 delete pHandleVolume;
167 Eina_Bool CPlaybackView::sm_CbUpdateSlider(void *dt)
169 SPlaybackView *m = (SPlaybackView *)dt;
170 char *timestr = NULL;
175 return ECORE_CALLBACK_CANCEL;
177 if (!m->hMusicController->GetPosition(&value)) {
179 return ECORE_CALLBACK_CANCEL;
182 duration = m->csinfo->Duration();
184 value = value + S_INCREMENT;
185 if (value > duration) {
187 return ECORE_CALLBACK_CANCEL;
190 elm_slider_value_set(m->eoSlider, value);
191 timestr = CCommonUI::TimeStrFromMilSeconds(value);
193 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
198 return ECORE_CALLBACK_RENEW;
202 Eina_Bool CPlaybackView::sm_CbLongpressTimer(void *dt)
204 CPlaybackView *root = (CPlaybackView *)dt;
206 root->m_OnLongpressTimer();
208 return ECORE_CALLBACK_RENEW;
212 void CPlaybackView::m_OnLongpressTimer(void)
214 m_HandleOnRepeated();
218 Eina_Bool CPlaybackView::sm_CbWaitTimer(void *dt)
220 CPlaybackView *root = (CPlaybackView *)dt;
222 root->m_OnWaitTimer();
224 return ECORE_CALLBACK_CANCEL;
228 void CPlaybackView::m_OnWaitTimer(void)
230 m->press_status = PRESS_LONG;
231 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
232 /* Handle long press */
234 m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, this);
237 m->press_status = PRESS_LONG_PAUSE;
244 void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
246 CPlaybackView *root = (CPlaybackView *)dt;
248 root->m_OnCtxtUpdate(type, lid);
252 void CPlaybackView::m_OnCtxtUpdate(EActionType type, int lid)
254 SItemInfo *itinfo = NULL;
255 Elm_Object_Item *focusedItem = NULL;
257 if (!m->ctxtinfo || !m->ctxtinfo->context)
260 itinfo = m_FindItemInfoFromSong(m->elInfo,
261 (CSongInfo *)m->ctxtinfo->context);
263 _ERR(" Unable to find song in the list ");
267 if (type == ACTION_TYPE_DELETE) {
268 itinfo->check_status = true;
269 m_DeleteSelectedItems();
271 if (!m->mgr->PopView()) {
272 _ERR("CViewMgr::PopView failed");
277 memset(&parcel, 0, sizeof(SParcel));
278 parcel.updateType = E_PLAYLIST_UPDATE;
281 focusedItem = m->cs_itinfo->item;
283 else { // ACTION_TYPE_PLAY
284 if (m->ctxtinfo->status == PLAY_STATUS_PLAY)
287 if (itinfo == m->cs_itinfo)
290 m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
293 if (!m->mgr->PopView()) {
294 _ERR("CViewMgr::PopView failed");
298 focusedItem = m->focused_item;
302 elm_genlist_item_show(focusedItem, ELM_GENLIST_ITEM_SCROLLTO_IN);
303 elm_object_item_focus_set(focusedItem, EINA_TRUE);
308 void CPlaybackView::sm_CbCtxtClose(void *dt)
310 CPlaybackView *root = (CPlaybackView *)dt;
312 root->m_OnCtxtClose();
316 void CPlaybackView::m_OnCtxtClose(void)
318 if (!m->mgr->PopView()) {
319 _ERR("CViewMgr::PopView failed");
323 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
327 void CPlaybackView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text)
329 CPlaybackView *root = (CPlaybackView *)cookie;
331 root->m_CbCtxPopupBtnSelected(instance, text);
335 void CPlaybackView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text)
337 int type = CInfo::PlaybackSettingType();
341 m_FromPlaybackToEditMode();
345 m->hMusicController->Stop();
346 m->hMusicController->EmptyPlaylist();
347 eina_list_free(m->elInfo);
349 elm_genlist_clear(m->eoPlaylist);
350 m_UpdateEmptySongInfo();
359 void CPlaybackView::m_RemoveTimer(int timer_code)
361 ETimers timerCode = (ETimers)timer_code;
366 ecore_timer_del(m->etSlider);
373 ecore_timer_del(m->etWait);
378 case TIMER_LONGPRESS:
379 if (m->etLongPress) {
380 ecore_timer_del(m->etLongPress);
381 m->etLongPress = NULL;
386 m->pHandleVolume->RemoveTimer();
390 _ERR(" invalid value ");
396 void CPlaybackView::m_PlaybackPause(void)
398 m->hMusicController->Pause();
401 ecore_timer_freeze(m->etSlider);
405 void CPlaybackView::m_PlaybackResume(void)
407 m->hMusicController->Resume();
410 ecore_timer_thaw(m->etSlider);
414 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
416 SItemInfo *itinfo = NULL;
420 EINA_LIST_FOREACH(list, l, obj) {
421 itinfo = (SItemInfo *)obj;
422 itinfo->edit_mode = flag;
427 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
429 SItemInfo *itinfo = NULL;
433 EINA_LIST_FOREACH(list, l, obj) {
434 itinfo = (SItemInfo *)obj;
435 itinfo->check_status = false;
440 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
442 if (!pItemInfo || !pItemInfo->item)
445 elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
446 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
448 pItemInfo->select_status = true;
452 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
454 if (!pItemInfo || !pItemInfo->item)
457 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
458 MUSIC_PLAYBACK_VIEW);
460 pItemInfo->select_status = false;
464 void CPlaybackView::m_UpdateControlBtns(void)
468 state = m->hMusicController->PlayState();
469 if (state != PLAY_STATUS_STOP) {
470 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
471 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
475 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
476 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
477 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
480 if (state == PLAY_STATUS_PLAY) {
481 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
484 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
487 state = m->hMusicController->ShuffleState();
488 if (state == SHUFFLE_STATUS_OFF) {
489 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
492 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
495 state = m->hMusicController->RepeatState();
496 if (state == REPEAT_STATUS_NONE) {
497 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
499 else if (state == REPEAT_STATUS_ALL) {
500 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
503 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
508 void CPlaybackView::m_UpdateCurrentSongProgressbar(void)
511 char *timestr = NULL;
518 elm_slider_value_set(m->eoSlider, 0);
519 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
521 state = m->hMusicController->PlayState();
523 if (state == PLAY_STATUS_STOP) {
524 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
525 m_RemoveTimer(TIMER_SLIDER);
529 elm_object_disabled_set(m->eoSlider, EINA_FALSE);
531 duration = m->csinfo->Duration();
533 m_RemoveTimer(TIMER_SLIDER);
534 m->etSlider = ecore_timer_add(S_INTERVAL,
535 sm_CbUpdateSlider, m);
537 elm_slider_min_max_set(m->eoSlider, 0, duration);
538 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
540 elm_object_part_text_set(m->eoBase,
541 MUSIC_PART_FULLTIME, timestr);
545 step = (double)SLIDER_STEP / (double)duration;
546 elm_slider_step_set(m->eoSlider, step);
551 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
554 char buf[MAX_LENGTH];
556 if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
559 path = m->cs_itinfo->sinfo->ThumbnailPath();
561 elm_image_file_set(m->eoAlbumCover, path, NULL);
563 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
564 MUSIC_IMAGE_DEFAULT_THUMB_450);
565 elm_image_file_set(m->eoAlbumCover, buf, NULL);
570 void CPlaybackView::m_UpdateCurrentSongLabels(void)
572 char buf[MAX_LENGTH];
577 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
580 snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
583 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
587 void CPlaybackView::m_UpdateEmptySongInfo(void)
589 char buf[MAX_LENGTH];
591 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
592 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
593 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
594 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
595 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
596 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
597 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
598 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
599 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
600 elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
601 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
602 elm_slider_value_set(m->eoSlider, 0);
603 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
604 _(NO_PLAYLIST_MESSAGE));
605 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
606 _(NO_PLAYLIST_MESSAGE_SUB));
607 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
608 MUSIC_IMAGE_DEFAULT_THUMB_450);
609 elm_image_file_set(m->eoAlbumCover, buf, NULL);
610 m->hMusicController->SetPlayState(PLAY_STATUS_INITIAL);
614 void CPlaybackView::m_UpdateCtxtView(int playStatus)
616 if (!m->cs_itinfo || !m->ctxtinfo)
619 if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
622 if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
623 m->ctxtinfo->status = (EPlayStatus)playStatus;
626 memset(&parcel, 0, sizeof(SParcel));
627 parcel.updateType = E_SONG_UPDATE;
628 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
633 void CPlaybackView::m_UpdateCurrentSongItem(int index)
635 SItemInfo *pItemInfo = NULL;
638 m_UnselectItem(m->cs_itinfo);
639 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
642 pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
645 m->cs_itinfo = pItemInfo;
646 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
647 elm_genlist_item_bring_in(pItemInfo->item,
648 ELM_GENLIST_ITEM_SCROLLTO_IN);
651 m_SelectItem(pItemInfo);
652 m_UpdateCtxtView(PLAY_STATUS_PLAY);
658 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
660 elm_object_focus_next_object_set(m->eoPlaylist,
661 m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
662 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
663 m->eoPlaylist, ELM_FOCUS_RIGHT);
664 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnEdit[BTN_CANCEL],
669 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
671 elm_object_focus_next_object_set(m->eoSlider, m->eoPlaylist,
673 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnControl[BTN_PLAY],
675 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
676 elm_object_focus_next_object_set(m->eoPlaylist,
677 m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
678 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
679 m->eoPlaylist, ELM_FOCUS_RIGHT);
682 elm_object_focus_next_object_set(m->eoPlaylist,
683 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
684 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
685 m->eoPlaylist, ELM_FOCUS_RIGHT);
686 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
687 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
692 void CPlaybackView::m_UpdateCurrentSongInfo(void)
694 CSongInfo *sinfo = NULL;
697 if (eina_list_count(m->elInfo) == 0) {
698 m_UpdateEmptySongInfo();
702 if (!m->hMusicController->GetCurrentSongIndex(&index)) {
703 _ERR(" music get current song index failed ");
707 if (!m->hMusicController->GetSonginfoFromIndex(index, &sinfo)) {
708 _ERR(" music get songinfo failed ");
713 m_UpdateCurrentSongItem(index);
714 m_UpdateCurrentSongLabels();
715 m_UpdateCurrentSongThumbnail();
716 m_UpdateCurrentSongProgressbar();
717 m_UpdateControlBtns();
718 m_UpdatePlaymodeFocusSequence();
722 void CPlaybackView::m_DisableEditButtons(bool flag)
724 /* flag - 1 means disable edit buttons and 0 means enable */
726 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
728 elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
729 elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
731 m_UpdateEditmodeFocusSequence();
732 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
735 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
736 m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
737 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE],
738 m->eoPlaylist, ELM_FOCUS_RIGHT);
739 elm_object_focus_next_object_set(m->eoPlaylist,
740 m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
745 void CPlaybackView::m_CreateErrorPopup(void)
747 Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
749 popup = elm_popup_add(m->eoBase);
753 elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
754 evas_object_show(popup);
756 label = elm_label_add(popup);
758 evas_object_del(popup);
762 elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
763 elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
764 elm_object_content_set(popup, label);
766 btn = elm_button_add(popup);
768 evas_object_del(popup);
772 elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
773 elm_object_text_set(btn, MUSIC_TEXT_OK);
774 elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
776 m->eoErrPopup = popup;
778 Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
780 elm_object_focus_set(btn, EINA_TRUE);
786 void CPlaybackView::m_DestroyErrorPopup(void)
791 evas_object_del(m->eoErrPopup);
792 m->eoErrPopup = NULL;
796 void CPlaybackView::m_CreateSettingsPopup(void)
798 CPlaySettingCtxPopup *eoCtxPopup = new CPlaySettingCtxPopup;
799 CCtxPopup::SCallback cb;
801 cb.onSelected = sm_CbCtxPopupBtnSelected;
803 eoCtxPopup->Create(m->eoWin, &cb);
805 m->eoCtxPopup = eoCtxPopup;
809 void CPlaybackView::m_DestroySettingsPopup(void)
814 if (m->eoCtxPopup->FlagCreate())
815 m->eoCtxPopup->Destroy();
817 delete m->eoCtxPopup;
818 m->eoCtxPopup = NULL;
822 void CPlaybackView::m_FromEditToPlaybackMode(void)
824 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
825 elm_genlist_item_bring_in(m->cs_itinfo->item,
826 ELM_GENLIST_ITEM_SCROLLTO_IN);
829 m_SelectItem(m->cs_itinfo);
831 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
832 MUSIC_PLAYBACK_VIEW);
833 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
835 m_ChangeEditmodeAll(m->elInfo, false);
837 elm_genlist_realized_items_update(m->eoPlaylist);
839 m_UpdatePlaymodeFocusSequence();
843 void CPlaybackView::m_FromPlaybackToEditMode(void)
845 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_EDIT_MODE,
846 MUSIC_PLAYBACK_VIEW);
848 m_DisableEditButtons(true);
850 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
852 m_ChangeEditmodeAll(m->elInfo, true);
854 elm_genlist_realized_items_update(m->eoPlaylist);
856 m_UpdateEditmodeFocusSequence();
860 void CPlaybackView::m_HandleOnRepeated(void)
862 Evas_Object *obj = NULL;
865 char *timestr = NULL;
867 if (!m->eoPressedObj)
870 obj = m->eoPressedObj;
872 value = elm_slider_value_get(m->eoSlider);
873 duration = m->cs_itinfo->sinfo->Duration();
875 if (obj == m->eoBtnControl[BTN_REWIND]) {
877 m_RemoveTimer(TIMER_LONGPRESS);
880 value = value - LP_CHANGE;
885 if (value == duration) {
886 if (m->hMusicController->PlayNextSong())
887 m_UpdateCurrentSongInfo();
889 _ERR(" music play next song failed ");
891 m->press_status = PRESS_LONG_PAUSE;
892 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE,
893 MUSIC_PLAYBACK_VIEW);
895 m_RemoveTimer(TIMER_LONGPRESS);
899 value = value + LP_CHANGE;
900 if (value >= duration)
904 m->hMusicController->SetPosition(value);
905 elm_slider_value_set(m->eoSlider, value);
906 timestr = CCommonUI::TimeStrFromMilSeconds(value);
908 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
917 void CPlaybackView::m_DeleteSelectedItems(void)
919 Eina_List *l = NULL, *l_next = NULL;
920 SItemInfo *pItemInfo = NULL;
925 m_DisableEditButtons(true);
926 EINA_LIST_FOREACH_SAFE(m->elInfo, l, l_next, obj) {
927 pItemInfo = (SItemInfo *)obj;
928 if (pItemInfo->check_status) {
929 if (m->cs_itinfo == pItemInfo) {
931 m_UnselectItem(m->cs_itinfo);
932 m_RemoveTimer(TIMER_SLIDER);
934 m->hMusicController->SetPlayState(PLAY_STATUS_STOP);
935 m->hMusicController->Stop();
937 index = elm_genlist_item_index_get(pItemInfo->item);
938 m->hMusicController->RemoveSong(pItemInfo->sinfo, index);
940 m->elInfo = eina_list_remove(m->elInfo,
942 elm_object_item_del(pItemInfo->item);
946 if (eina_list_count(m->elInfo) == 0) {
947 m_UpdateEmptySongInfo();
948 elm_genlist_realized_items_update(m->eoPlaylist);
949 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
954 m_UpdateCurrentSongInfo();
956 elm_genlist_realized_items_update(m->eoPlaylist);
957 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
961 void CPlaybackView::m_KeyBackPress(void)
964 m_DestroySettingsPopup();
965 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_FALSE);
966 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
975 void CPlaybackView::m_KeyExitPress(void)
977 m_RemoveTimer(TIMER_SLIDER);
978 m->hMusicController->Stop();
983 void CPlaybackView::m_KeyPlayPress(void)
987 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
990 state = m->hMusicController->PlayState();
991 if (state == PLAY_STATUS_PAUSE) {
993 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
994 MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
996 else if (state != PLAY_STATUS_PLAY) {
997 if (m->hMusicController)
998 m->hMusicController->Start();
1000 m_UpdateCurrentSongInfo();
1005 void CPlaybackView::m_KeyPausePress(void)
1009 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1012 state = m->hMusicController->PlayState();
1013 if (state == PLAY_STATUS_PLAY) {
1014 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1015 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1021 void CPlaybackView::m_KeyNextPress(void)
1023 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1026 m_HandleOnPressed(m->eoBtnControl[BTN_FORWARD]);
1030 void CPlaybackView::m_KeyPreviousPress(void)
1032 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1035 m_HandleOnPressed(m->eoBtnControl[BTN_REWIND]);
1039 void CPlaybackView::m_KeyNextUnpress(void)
1041 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1044 m_HandleOnUnpressed(m->eoBtnControl[BTN_FORWARD]);
1048 void CPlaybackView::m_KeyPreviousUnpress(void)
1050 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1053 m_HandleOnUnpressed(m->eoBtnControl[BTN_REWIND]);
1057 void CPlaybackView::m_HandleKeyPress(char *keyname)
1059 if (!strcmp(keyname, (char *)KEY_EXIT))
1061 else if (!strcmp(keyname, (char *)KEY_BACK) ||
1062 !strcmp(keyname, (char *)KEY_BACK_REMOTE))
1064 else if (!strcmp(keyname, (char *)KEY_PLAY))
1066 else if (!strcmp(keyname, (char *)KEY_PAUSE))
1068 else if (!strcmp(keyname, (char *)KEY_NEXT))
1070 else if (!strcmp(keyname, (char *)KEY_PREVIOUS))
1071 m_KeyPreviousPress();
1072 else if (!strcmp(keyname, (char *)KEY_VOLUMEUP))
1073 m->pHandleVolume->Up();
1074 else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN))
1075 m->pHandleVolume->Down();
1076 else if (!strcmp(keyname, (char *)KEY_MUTE))
1077 m->pHandleVolume->Mute();
1081 void CPlaybackView::m_HandleKeyUnpress(char *keyname)
1083 if (!strcmp(keyname, KEY_PREVIOUS))
1084 m_KeyPreviousUnpress();
1085 else if (!strcmp(keyname, KEY_NEXT))
1090 void CPlaybackView::m_AddSlider(void)
1092 Evas_Object *eoSlider = NULL;
1094 eoSlider = elm_slider_add(m->eoBase);
1098 elm_slider_indicator_show_set(eoSlider, EINA_FALSE);
1099 elm_slider_indicator_show_on_focus_set(eoSlider, EINA_FALSE);
1100 elm_object_style_set(eoSlider, MUSIC_STYLE_SLIDER);
1101 elm_slider_horizontal_set(eoSlider, EINA_TRUE);
1102 elm_object_part_content_set(m->eoBase, MUSIC_PART_PROGRESSBAR, eoSlider);
1104 Connect(eoSlider, EO_SLIDER, TYPE_CHANGED | TYPE_MOUSE_MOVE);
1106 evas_object_show(eoSlider);
1107 m->eoSlider = eoSlider;
1111 void CPlaybackView::m_AddAlbumCover(void)
1113 Evas_Object *eoAlbumCover = NULL;
1115 eoAlbumCover = elm_image_add(m->eoBase);
1119 evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
1121 elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
1123 elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
1125 evas_object_show(eoAlbumCover);
1126 m->eoAlbumCover = eoAlbumCover;
1131 void CPlaybackView::m_AddCurrentSonginfo(void)
1138 void CPlaybackView::m_AddEditPlaylistButtons(void)
1140 Evas_Object *box = NULL;
1142 SBtnInfo btninfo[TOTAL_EDIT_BTNS];
1144 btninfo[BTN_CANCEL].txt = MUSIC_TEXT_CANCEL;
1145 btninfo[BTN_CANCEL].type = EO_CANCEL;
1147 btninfo[BTN_DESELECT].txt = MUSIC_TEXT_DESELECT;
1148 btninfo[BTN_DESELECT].type = EO_DESELECT;
1150 btninfo[BTN_DELETE].txt = MUSIC_TEXT_DELETE;
1151 btninfo[BTN_DELETE].type = EO_DELETE;
1153 box = CCommonUI::AddBox(m->eoBase);
1157 elm_box_horizontal_set(box, EINA_TRUE);
1158 elm_box_padding_set(box,
1159 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
1161 for (i = 0; i < TOTAL_EDIT_BTNS; i++) {
1162 m->eoBtnEdit[i] = elm_button_add(m->eoBase);
1163 if (!m->eoBtnEdit[i])
1166 elm_object_style_set(m->eoBtnEdit[i],
1167 MUSIC_STYLE_EDIT_BTN);
1168 evas_object_size_hint_weight_set(m->eoBtnEdit[i],
1169 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1170 elm_box_pack_end(box, m->eoBtnEdit[i]);
1171 elm_object_text_set(m->eoBtnEdit[i], _(btninfo[i].txt));
1173 Connect(m->eoBtnEdit[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1175 evas_object_show(m->eoBtnEdit[i]);
1177 elm_object_part_content_set(m->eoBase, MUSIC_PART_EDITBTNS, box);
1178 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
1179 MUSIC_PLAYBACK_VIEW);
1183 void CPlaybackView::m_AddControlButtons(void)
1185 Evas_Object *box = NULL;
1187 SBtnInfo btninfo[TOTAL_CONTROL_BTNS];
1189 btninfo[BTN_SETTINGS].txt = MUSIC_STYLE_BTN_SETTINGS;
1190 btninfo[BTN_SETTINGS].type = EO_BTN_SETTINGS;
1192 btninfo[BTN_SHUFFLE].txt = MUSIC_STYLE_BTN_SHUFFLE;
1193 btninfo[BTN_SHUFFLE].type = EO_BTN_SHUFFLE;
1195 btninfo[BTN_REPEAT].txt = MUSIC_STYLE_BTN_REPEAT;
1196 btninfo[BTN_REPEAT].type = EO_BTN_REPEAT;
1198 btninfo[BTN_REWIND].txt = MUSIC_STYLE_BTN_REWIND;
1199 btninfo[BTN_REWIND].type = EO_BTN_REWIND;
1201 btninfo[BTN_PLAY].txt = MUSIC_STYLE_BTN_PLAY;
1202 btninfo[BTN_PLAY].type = EO_BTN_PLAY;
1204 btninfo[BTN_FORWARD].txt = MUSIC_STYLE_BTN_FORWARD;
1205 btninfo[BTN_FORWARD].type = EO_BTN_FORWARD;
1207 box = elm_box_add(m->eoBase);
1211 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
1212 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
1213 elm_box_horizontal_set(box, EINA_TRUE);
1214 elm_box_padding_set(box,
1215 MUSIC_CONTROL_BTNS_PADDING * elm_config_scale_get(), 0);
1217 for (i = 0; i < TOTAL_CONTROL_BTNS; i++) {
1218 m->eoBtnControl[i] = elm_button_add(m->eoBase);
1219 if (!m->eoBtnControl[i])
1222 elm_object_style_set(m->eoBtnControl[i], btninfo[i].txt);
1223 evas_object_size_hint_weight_set(m->eoBtnControl[i],
1224 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1225 elm_box_pack_end(box, m->eoBtnControl[i]);
1227 if (i == BTN_REWIND || i == BTN_FORWARD) {
1228 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_PRESSED | TYPE_UNPRESSED | TYPE_MOUSE_MOVE);
1231 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1233 evas_object_show(m->eoBtnControl[i]);
1236 elm_object_part_content_set(m->eoBase, MUSIC_PART_CONTROLBTNS, box);
1240 SItemInfo *CPlaybackView::m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo)
1242 Eina_List *l = NULL;
1243 SItemInfo *itinfo = NULL;
1246 EINA_LIST_FOREACH(list, l, obj) {
1247 itinfo = (SItemInfo *)obj;
1248 if (itinfo->sinfo == sinfo)
1256 SItemInfo *CPlaybackView::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
1258 Eina_List *l = NULL;
1259 SItemInfo *itinfo = NULL;
1262 EINA_LIST_FOREACH(list, l, obj) {
1263 itinfo = (SItemInfo *)obj;
1264 if (itinfo->item == item)
1272 void CPlaybackView::m_UpdateItemCheck(SItemInfo *itinfo)
1275 _ERR(" No item info to Update check ");
1279 if (itinfo->check_status) {
1280 elm_object_item_signal_emit(itinfo->item,
1281 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1282 itinfo->check_status = false;
1286 elm_object_item_signal_emit(itinfo->item,
1287 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
1288 itinfo->check_status = true;
1292 class CElmGenlistItemClass {
1294 static char *sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
1296 CSongInfo *sinfo = NULL;
1297 SItemInfo *pItemInfo = (SItemInfo *)data;
1298 char buf[MAX_LENGTH];
1299 char *timestr = NULL;
1303 if (!pItemInfo || !obj)
1306 sinfo = pItemInfo->sinfo;
1308 snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY);
1310 if (!strcmp(part, "elm.text0")) {
1311 index = elm_genlist_item_index_get(pItemInfo->item);
1312 snprintf(buf, sizeof(buf), "%d", index);
1314 else if (!strcmp(part, "elm.text1"))
1315 snprintf(buf, sizeof(buf), "%s", sinfo->Name());
1316 else if (!strcmp(part, "elm.text2"))
1317 snprintf(buf, sizeof(buf), "%s - %s",
1320 else if (!strcmp(part, "elm.text3")) {
1321 duration = sinfo->Duration();
1322 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
1324 snprintf(buf, sizeof(buf), "%s", timestr);
1329 if (strcmp(buf, MUSIC_STR_EMPTY))
1334 static Evas_Object *sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
1336 CSongInfo *sinfo = NULL;
1337 SItemInfo *pItemInfo = (SItemInfo *)data;
1338 Evas_Object *img = NULL;
1340 char buf[MAX_LENGTH];
1342 if (!pItemInfo || !obj)
1345 sinfo = pItemInfo->sinfo;
1347 img = elm_image_add(obj);
1351 elm_image_aspect_fixed_set(img, EINA_FALSE);
1353 if (!strcmp(part, "elm.swallow.icon")) {
1354 path = sinfo->ThumbnailPath();
1356 elm_image_file_set(img, path, "NULL");
1358 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
1359 MUSIC_IMAGE_DEFAULT_THUMB_126);
1360 elm_image_file_set(img, buf, "NULL");
1367 static void sm_CbDel(void *data, Evas_Object *obj)
1374 Elm_Genlist_Item_Class *CPlaybackView::m_GetItemClass(void)
1376 Elm_Genlist_Item_Class *list_item = NULL;
1378 list_item = elm_genlist_item_class_new();
1380 _ERR(" elm_genlist_item_class_new failed ");
1384 list_item->item_style = MUSIC_STYLE_PLAYLIST;
1385 list_item->func.text_get = CElmGenlistItemClass::sm_CbTextGet;
1386 list_item->func.content_get = CElmGenlistItemClass::sm_CbContentGet;
1387 list_item->func.state_get = NULL;
1388 list_item->func.del = CElmGenlistItemClass::sm_CbDel;
1394 void CPlaybackView::m_AddGenlist(void)
1396 Evas_Object *genlist = NULL;
1397 Evas_Object *eoBase = NULL;
1400 genlist = elm_genlist_add(eoBase);
1404 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1405 evas_object_size_hint_weight_set(genlist,
1406 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1407 elm_object_part_content_set(eoBase, MUSIC_PART_PLAYLIST, genlist);
1408 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
1409 elm_genlist_multi_select_set(genlist, EINA_FALSE);
1411 Connect(genlist, EO_PLAYLIST, TYPE_REALIZED | TYPE_MOUSE_MOVE |
1412 TYPE_KEY_DOWN | TYPE_ACTIVATED);
1414 evas_object_show(genlist);
1415 m->eoPlaylist = genlist;
1419 void CPlaybackView::m_AddPlaylist(void)
1421 Elm_Genlist_Item_Class *list_item = NULL;
1424 CSongInfo *sinfo = NULL;
1425 Elm_Object_Item *item = NULL;
1426 SItemInfo *pItemInfo = NULL;
1432 list_item = m_GetItemClass();
1434 evas_object_del(m->eoPlaylist);
1438 if (!m->hMusicController->GetTotalSongs(&ts)) {
1439 _ERR(" music get total songs failed ");
1443 if (!m->hMusicController->GetCurrentSongIndex(&index))
1444 _ERR(" music get current song index failed ");
1446 for (i = 0; i < ts; i++) {
1447 if (!m->hMusicController->GetSonginfoFromIndex(i, &sinfo)) {
1448 _ERR(" music get songinfo failed ");
1451 pItemInfo = (SItemInfo *)calloc(1, sizeof(*pItemInfo));
1454 pItemInfo->sinfo = sinfo;
1455 pItemInfo->edit_mode = false;
1456 pItemInfo->check_status = false;
1457 pItemInfo->select_status = false;
1459 // event handling will be done in OnActivated function
1460 item = elm_genlist_item_append(m->eoPlaylist, list_item,
1461 pItemInfo, NULL, ELM_GENLIST_ITEM_NONE,
1463 pItemInfo->item = item;
1466 pItemInfo->select_status = true;
1467 m->cs_itinfo = pItemInfo;
1469 m->elInfo = eina_list_append(m->elInfo, pItemInfo);
1474 void CPlaybackView::m_RemovePlaylist(void)
1476 if (m->eoPlaylist) {
1477 elm_genlist_clear(m->eoPlaylist);
1478 m->eoPlaylist = NULL;
1482 eina_list_free(m->elInfo);
1488 void CPlaybackView::m_HandleRewindBtnClicked(Evas_Object *obj)
1490 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1491 MUSIC_PLAYBACK_VIEW);
1493 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1496 if (!m->hMusicController->PlayPreviousSong()){
1497 _ERR(" music play previous song failed ");
1501 m_UpdateCurrentSongInfo();
1505 void CPlaybackView::m_HandleForwardBtnClicked(Evas_Object *obj)
1507 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1508 MUSIC_PLAYBACK_VIEW);
1510 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1513 if (!m->hMusicController->PlayNextSong()) {
1514 _ERR(" music play next song failed ");
1518 m_UpdateCurrentSongInfo();
1522 void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
1524 m->press_status = PRESS_SHORT;
1525 m->eoPressedObj = obj;
1527 m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, this);
1531 void CPlaybackView::m_HandleOnUnpressed(Evas_Object *obj)
1533 m_RemoveTimer(TIMER_WAIT);
1534 m_RemoveTimer(TIMER_LONGPRESS);
1536 if (m->press_status == PRESS_SHORT) {
1537 /* Handle song change */
1538 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY)
1541 if (obj == m->eoBtnControl[BTN_FORWARD])
1542 m_HandleForwardBtnClicked(obj);
1544 m_HandleRewindBtnClicked(obj);
1546 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1549 else if (m->press_status == PRESS_LONG) {
1550 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1554 m->press_status = PRESS_SHORT;
1558 void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_Item *genListItem)
1561 SItemInfo *itinfo = NULL;
1563 if (!obj || !genListItem)
1566 itinfo = m_FindItemInfoFromItem(m->elInfo, genListItem);
1568 _ERR(" no item info found ");
1572 if (itinfo->edit_mode) {
1573 m_UpdateItemCheck(itinfo);
1574 m_DisableEditButtons(false);
1578 index = elm_genlist_item_index_get(genListItem);
1580 m->hMusicController->PlayIndexSong(--index);
1581 m_UpdateCurrentSongInfo();
1585 bool CPlaybackView::Create(void *data)
1590 _CHECK(m = new SPlaybackView)
1591 _CHECK(m->mgr = CViewMgr::GetInstance())
1592 _CHECK(m->eoWin = m->mgr->Window())
1593 _CHECK(m->hMusicController = CMusicController::GetInstance())
1594 _CHECK(m->eoBase = CCommonUI::AddBase(m->eoWin, MUSIC_PLAYBACK_VIEW))
1595 _CHECK(CBaseView::Create(data))
1596 _CHECK(m->hMusicController->AddListener(this))
1599 m->press_status = PRESS_SHORT;
1600 evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1602 m_AddControlButtons();
1603 m_AddEditPlaylistButtons();
1604 m_AddCurrentSonginfo();
1607 m->pHandleVolume->Create(m->eoBase);
1608 m_UpdatePlaymodeFocusSequence();
1610 Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1613 _CHECK_FAIL{ m->hMusicController->RemoveListener(this); }
1614 _CHECK_FAIL{ CBaseView::Destroy(); }
1615 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1616 _CHECK_FAIL{ /* CMusicController::GetInstance())*/ }
1617 _CHECK_FAIL{ /* mgr->Window() */ }
1618 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1619 _CHECK_FAIL{ delete m; m = NULL; }
1620 }_CREATE_END_AND_CATCH{ return false; }
1626 void CPlaybackView::Destroy(void)
1630 Disconnect(m->eoBase);
1631 m->hMusicController->RemoveListener(this);
1633 m_DestroyErrorPopup();
1635 m_RemoveTimer(TIMER_SLIDER);
1636 m_RemoveTimer(TIMER_WAIT);
1637 m_RemoveTimer(TIMER_LONGPRESS);
1638 m_DestroySettingsPopup();
1640 m->pHandleVolume->Destroy();
1641 CBaseView::Destroy();
1642 evas_object_del(m->eoBase);
1650 Evas_Object* CPlaybackView::Base(void)
1658 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1660 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1662 if (eina_list_count(m->elInfo) == 0)
1665 elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1666 m_DestroySettingsPopup();
1667 m_CreateSettingsPopup();
1671 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1673 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1675 switch (m->hMusicController->ShuffleState()) {
1676 case SHUFFLE_STATUS_OFF:
1677 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_ON);
1678 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1682 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_OFF);
1683 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1689 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1691 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1693 switch (m->hMusicController->RepeatState()) {
1694 case REPEAT_STATUS_NONE:
1695 m->hMusicController->SetRepeatState(REPEAT_STATUS_ALL);
1696 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1699 case REPEAT_STATUS_ALL:
1700 m->hMusicController->SetRepeatState(REPEAT_STATUS_ONE);
1701 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1705 m->hMusicController->SetRepeatState(REPEAT_STATUS_NONE);
1706 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1712 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1714 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1716 switch (m->hMusicController->PlayState()) {
1717 case PLAY_STATUS_PAUSE:
1719 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1722 case PLAY_STATUS_PLAY:
1723 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1728 if (m->hMusicController)
1729 m->hMusicController->Start();
1730 m_UpdateCurrentSongInfo();
1736 void CPlaybackView::t_OnShow(void)
1742 m_UpdateCurrentSongInfo();
1744 state = m->hMusicController->PlayState();
1745 if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
1748 m->hMusicController->Start();
1749 m_UpdateCurrentSongInfo();
1753 elm_genlist_item_show(m->cs_itinfo->item,
1754 ELM_GENLIST_ITEM_SCROLLTO_IN);
1755 elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
1758 evas_object_show(m->eoBase);
1762 void CPlaybackView::t_OnUpdate(void *data)
1766 SParcel *parcel = (SParcel *)data;
1768 char *keyEvent = NULL;
1771 updateType = E_PLAYLIST_UPDATE;
1773 updateType = parcel->updateType;
1774 keyEvent = (char *)parcel->keyEvent;
1777 switch (updateType) {
1778 case E_PLAYLIST_UPDATE:
1781 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
1782 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
1783 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
1784 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
1785 m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
1786 m_FromEditToPlaybackMode();
1790 m_HandleKeyPress(keyEvent);
1794 m_HandleKeyUnpress(keyEvent);
1803 void CPlaybackView::t_OnHide(void)
1807 evas_object_hide(m->eoBase);
1811 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
1815 m_HandleKeyPress(ev->keyname);
1818 case EO_ERROR_POPUP_BUTTON:
1819 if (!strcmp(ev->keyname, KEY_BACK) ||
1820 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1821 m_DestroyErrorPopup();
1822 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1828 Elm_Object_Item *it = NULL;
1829 SContentInfo *ctxtinfo = NULL;
1830 SItemInfo *itinfo = NULL;
1832 if (strcmp(ev->keyname, KEY_MENU) &&
1833 strcmp(ev->keyname, KEY_MENU_REMOTE))
1836 it = elm_object_focused_item_get(obj);
1838 _ERR(" unable to get focused item ");
1841 m->focused_item = it;
1848 ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
1852 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
1858 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY &&
1859 itinfo == m->cs_itinfo)
1860 ctxtinfo->status = PLAY_STATUS_PLAY;
1862 ctxtinfo->status = PLAY_STATUS_PAUSE;
1864 ctxtinfo->cbdata = this;
1865 ctxtinfo->update = sm_CbCtxtUpdate;
1866 ctxtinfo->close = sm_CbCtxtClose;
1867 ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
1868 ctxtinfo->context = itinfo->sinfo;
1870 m->ctxtinfo = ctxtinfo;
1873 memset(&parcel, 0, sizeof(SParcel));
1874 parcel.ctxtInfo = ctxtinfo;
1875 if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
1876 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
1880 if (!strcmp(ev->keyname, KEY_BACK) ||
1881 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1882 _ERR("eoCtxPopup BACK key pressed ");
1883 m_DestroySettingsPopup();
1884 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1887 else if (!strcmp(ev->keyname, KEY_EXIT)) {
1888 _ERR("eoCtxPopup EXIT key pressed ");
1889 m_DestroySettingsPopup();
1890 m_RemoveTimer(TIMER_SLIDER);
1891 m->hMusicController->Stop();
1902 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
1906 m_HandleKeyUnpress(ev->keyname);
1915 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
1918 case EO_ERROR_POPUP_BUTTON:
1919 m_DestroyErrorPopup();
1920 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1924 m_DisableCheckAll(m->elInfo);
1925 m_DisableEditButtons(true);
1926 m_FromEditToPlaybackMode();
1930 m_DisableCheckAll(m->elInfo);
1931 m_DisableEditButtons(true);
1932 elm_genlist_realized_items_update(m->eoPlaylist);
1933 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1937 m_DeleteSelectedItems();
1940 case EO_BTN_SETTINGS:
1941 t_OnClickedSettings(obj);
1944 case EO_BTN_SHUFFLE:
1945 t_OnClickedShuffle(obj);
1949 t_OnClickedRepeat(obj);
1953 t_OnClickedPlay(obj);
1962 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
1969 case EO_BTN_FORWARD:
1973 case EO_BTN_SETTINGS:
1974 case EO_BTN_SHUFFLE:
1975 if (!elm_object_focus_get(obj))
1976 elm_object_focus_set(obj, EINA_TRUE);
1981 Elm_Object_Item *item;
1983 item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
1984 ev->cur.canvas.y, NULL);
1988 if (!elm_object_item_focus_get(item))
1989 elm_object_item_focus_set(item, EINA_TRUE);
1999 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2002 case EO_BTN_FORWARD:
2004 m_HandleOnPressed(obj);
2013 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2016 case EO_BTN_FORWARD:
2018 m_HandleOnUnpressed(obj);
2027 void CPlaybackView::OnChanged(int id, Evas_Object *obj)
2032 char *timestr = NULL;
2035 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2037 ecore_timer_freeze(m->etSlider);
2040 value = elm_slider_value_get(obj);
2041 m->hMusicController->SetPosition(value);
2042 timestr = CCommonUI::TimeStrFromMilSeconds(value);
2044 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
2049 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2051 ecore_timer_thaw(m->etSlider);
2062 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2067 int index = elm_genlist_item_index_get(item);
2068 if ((index & 1) == 1)
2069 elm_object_item_signal_emit(item,
2070 MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW);
2072 elm_object_item_signal_emit(item,
2073 MUSIC_SIGNAL_ODD_ROW, MUSIC_PLAYBACK_VIEW);
2075 SItemInfo *itInfo = m_FindItemInfoFromItem(m->elInfo, item);
2076 if (itInfo->select_status)
2077 elm_object_item_signal_emit(item,
2078 MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2080 elm_object_item_signal_emit(item,
2081 MUSIC_SIGNAL_UNSELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2083 if (itInfo->edit_mode) {
2084 elm_object_item_signal_emit(item,
2085 MUSIC_SIGNAL_EDITMODE_ON, MUSIC_PLAYBACK_VIEW);
2086 if (itInfo->check_status) {
2087 elm_object_item_signal_emit(item,
2088 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
2091 elm_object_item_signal_emit(item,
2092 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
2095 elm_object_item_signal_emit(item,
2096 MUSIC_SIGNAL_EDITMODE_OFF, MUSIC_PLAYBACK_VIEW);
2106 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2110 m_HandleGenlistItemActivated(obj, item);
2119 void CPlaybackView::OnComplete(void)
2121 m_UpdateCurrentSongInfo();
2125 void CPlaybackView::OnError(void)
2127 m_CreateErrorPopup();
2131 void CPlaybackView::OnUsbStatusChanged(SUsbStorageStatus status)
2136 void CPlaybackView::OnUpdateContent(void)