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;
301 if (!CViewMgr::GetInstance()->HideView(MUSIC_BASE_VIEW))
302 _ERR("CViewMgr::HideView failed");
307 elm_genlist_item_show(focusedItem, ELM_GENLIST_ITEM_SCROLLTO_IN);
308 elm_object_item_focus_set(focusedItem, EINA_TRUE);
313 void CPlaybackView::sm_CbCtxtClose(void *dt)
315 CPlaybackView *root = (CPlaybackView *)dt;
317 root->m_OnCtxtClose();
321 void CPlaybackView::m_OnCtxtClose(void)
323 if (!m->mgr->PopView()) {
324 _ERR("CViewMgr::PopView failed");
328 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
332 void CPlaybackView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text)
334 CPlaybackView *root = (CPlaybackView *)cookie;
336 root->m_CbCtxPopupBtnSelected(instance, text);
340 void CPlaybackView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text)
342 int type = CInfo::PlaybackSettingType();
346 m_FromPlaybackToEditMode();
350 m->hMusicController->Stop();
351 m->hMusicController->EmptyPlaylist();
352 eina_list_free(m->elInfo);
354 elm_genlist_clear(m->eoPlaylist);
355 m_UpdateEmptySongInfo();
364 void CPlaybackView::m_RemoveTimer(int timer_code)
366 ETimers timerCode = (ETimers)timer_code;
371 ecore_timer_del(m->etSlider);
378 ecore_timer_del(m->etWait);
383 case TIMER_LONGPRESS:
384 if (m->etLongPress) {
385 ecore_timer_del(m->etLongPress);
386 m->etLongPress = NULL;
391 m->pHandleVolume->RemoveTimer();
395 _ERR(" invalid value ");
401 void CPlaybackView::m_PlaybackPause(void)
403 m->hMusicController->Pause();
406 ecore_timer_freeze(m->etSlider);
410 void CPlaybackView::m_PlaybackResume(void)
412 m->hMusicController->Resume();
415 ecore_timer_thaw(m->etSlider);
419 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
421 SItemInfo *itinfo = NULL;
425 EINA_LIST_FOREACH(list, l, obj) {
426 itinfo = (SItemInfo *)obj;
427 itinfo->edit_mode = flag;
432 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
434 SItemInfo *itinfo = NULL;
438 EINA_LIST_FOREACH(list, l, obj) {
439 itinfo = (SItemInfo *)obj;
440 itinfo->check_status = false;
445 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
447 if (!pItemInfo || !pItemInfo->item)
450 elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
451 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
453 pItemInfo->select_status = true;
457 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
459 if (!pItemInfo || !pItemInfo->item)
462 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
463 MUSIC_PLAYBACK_VIEW);
465 pItemInfo->select_status = false;
469 void CPlaybackView::m_UpdateControlBtns(void)
473 state = m->hMusicController->PlayState();
474 if (state != PLAY_STATUS_STOP) {
475 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
476 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
480 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
481 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
482 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
485 if (state == PLAY_STATUS_PLAY) {
486 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
489 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
492 state = m->hMusicController->ShuffleState();
493 if (state == SHUFFLE_STATUS_OFF) {
494 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
497 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
500 state = m->hMusicController->RepeatState();
501 if (state == REPEAT_STATUS_NONE) {
502 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
504 else if (state == REPEAT_STATUS_ALL) {
505 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
508 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
513 void CPlaybackView::m_UpdateCurrentSongProgressbar(void)
516 char *timestr = NULL;
523 elm_slider_value_set(m->eoSlider, 0);
524 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
526 state = m->hMusicController->PlayState();
528 if (state == PLAY_STATUS_STOP) {
529 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
530 m_RemoveTimer(TIMER_SLIDER);
534 elm_object_disabled_set(m->eoSlider, EINA_FALSE);
536 duration = m->csinfo->Duration();
538 m_RemoveTimer(TIMER_SLIDER);
539 m->etSlider = ecore_timer_add(S_INTERVAL,
540 sm_CbUpdateSlider, m);
542 elm_slider_min_max_set(m->eoSlider, 0, duration);
543 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
545 elm_object_part_text_set(m->eoBase,
546 MUSIC_PART_FULLTIME, timestr);
550 step = (double)SLIDER_STEP / (double)duration;
551 elm_slider_step_set(m->eoSlider, step);
556 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
559 char buf[MAX_LENGTH];
561 if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
564 path = m->cs_itinfo->sinfo->ThumbnailPath();
566 elm_image_file_set(m->eoAlbumCover, path, NULL);
568 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
569 MUSIC_IMAGE_DEFAULT_THUMB_450);
570 elm_image_file_set(m->eoAlbumCover, buf, NULL);
575 void CPlaybackView::m_UpdateCurrentSongLabels(void)
577 char buf[MAX_LENGTH];
582 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
585 snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
588 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
592 void CPlaybackView::m_UpdateEmptySongInfo(void)
594 char buf[MAX_LENGTH];
596 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
597 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
598 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
599 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
600 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
601 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
602 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
603 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
604 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
605 elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
606 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
607 elm_slider_value_set(m->eoSlider, 0);
608 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
609 _(NO_PLAYLIST_MESSAGE));
610 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
611 _(NO_PLAYLIST_MESSAGE_SUB));
612 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
613 MUSIC_IMAGE_DEFAULT_THUMB_450);
614 elm_image_file_set(m->eoAlbumCover, buf, NULL);
615 m->hMusicController->SetPlayState(PLAY_STATUS_INITIAL);
619 void CPlaybackView::m_UpdateCtxtView(int playStatus)
621 if (!m->cs_itinfo || !m->ctxtinfo)
624 if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
627 if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
628 m->ctxtinfo->status = (EPlayStatus)playStatus;
631 memset(&parcel, 0, sizeof(SParcel));
632 parcel.updateType = E_SONG_UPDATE;
633 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
638 void CPlaybackView::m_UpdateCurrentSongItem(int index)
640 SItemInfo *pItemInfo = NULL;
643 m_UnselectItem(m->cs_itinfo);
644 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
647 pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
650 m->cs_itinfo = pItemInfo;
651 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
652 elm_genlist_item_bring_in(pItemInfo->item,
653 ELM_GENLIST_ITEM_SCROLLTO_IN);
656 m_SelectItem(pItemInfo);
657 m_UpdateCtxtView(PLAY_STATUS_PLAY);
663 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
665 elm_object_focus_next_object_set(m->eoPlaylist,
666 m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
667 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
668 m->eoPlaylist, ELM_FOCUS_RIGHT);
669 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnEdit[BTN_CANCEL],
674 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
676 elm_object_focus_next_object_set(m->eoSlider, m->eoPlaylist,
678 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnControl[BTN_PLAY],
680 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
681 elm_object_focus_next_object_set(m->eoPlaylist,
682 m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
683 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
684 m->eoPlaylist, ELM_FOCUS_RIGHT);
687 elm_object_focus_next_object_set(m->eoPlaylist,
688 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
689 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
690 m->eoPlaylist, ELM_FOCUS_RIGHT);
691 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
692 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
697 void CPlaybackView::m_UpdateCurrentSongInfo(void)
699 CSongInfo *sinfo = NULL;
702 if (eina_list_count(m->elInfo) == 0) {
703 m_UpdateEmptySongInfo();
707 if (!m->hMusicController->GetCurrentSongIndex(&index)) {
708 _ERR(" music get current song index failed ");
712 if (!m->hMusicController->GetSonginfoFromIndex(index, &sinfo)) {
713 _ERR(" music get songinfo failed ");
718 m_UpdateCurrentSongItem(index);
719 m_UpdateCurrentSongLabels();
720 m_UpdateCurrentSongThumbnail();
721 m_UpdateCurrentSongProgressbar();
722 m_UpdateControlBtns();
723 m_UpdatePlaymodeFocusSequence();
727 void CPlaybackView::m_DisableEditButtons(bool flag)
729 /* flag - 1 means disable edit buttons and 0 means enable */
731 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
733 elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
734 elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
736 m_UpdateEditmodeFocusSequence();
737 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
740 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
741 m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
742 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE],
743 m->eoPlaylist, ELM_FOCUS_RIGHT);
744 elm_object_focus_next_object_set(m->eoPlaylist,
745 m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
750 void CPlaybackView::m_CreateErrorPopup(void)
752 Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
754 popup = elm_popup_add(m->eoBase);
758 elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
759 evas_object_show(popup);
761 label = elm_label_add(popup);
763 evas_object_del(popup);
767 elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
768 elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
769 elm_object_content_set(popup, label);
771 btn = elm_button_add(popup);
773 evas_object_del(popup);
777 elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
778 elm_object_text_set(btn, MUSIC_TEXT_OK);
779 elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
781 m->eoErrPopup = popup;
783 Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
785 elm_object_focus_set(btn, EINA_TRUE);
791 void CPlaybackView::m_DestroyErrorPopup(void)
796 evas_object_del(m->eoErrPopup);
797 m->eoErrPopup = NULL;
801 void CPlaybackView::m_CreateSettingsPopup(void)
803 CPlaySettingCtxPopup *eoCtxPopup = new CPlaySettingCtxPopup;
804 CCtxPopup::SCallback cb;
806 cb.onSelected = sm_CbCtxPopupBtnSelected;
808 eoCtxPopup->Create(m->eoWin, &cb);
810 m->eoCtxPopup = eoCtxPopup;
814 void CPlaybackView::m_DestroySettingsPopup(void)
819 if (m->eoCtxPopup->FlagCreate())
820 m->eoCtxPopup->Destroy();
822 delete m->eoCtxPopup;
823 m->eoCtxPopup = NULL;
827 void CPlaybackView::m_FromEditToPlaybackMode(void)
829 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
830 elm_genlist_item_bring_in(m->cs_itinfo->item,
831 ELM_GENLIST_ITEM_SCROLLTO_IN);
834 m_SelectItem(m->cs_itinfo);
836 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
837 MUSIC_PLAYBACK_VIEW);
838 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
840 m_ChangeEditmodeAll(m->elInfo, false);
842 elm_genlist_realized_items_update(m->eoPlaylist);
844 m_UpdatePlaymodeFocusSequence();
848 void CPlaybackView::m_FromPlaybackToEditMode(void)
850 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_EDIT_MODE,
851 MUSIC_PLAYBACK_VIEW);
853 m_DisableEditButtons(true);
855 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
857 m_ChangeEditmodeAll(m->elInfo, true);
859 elm_genlist_realized_items_update(m->eoPlaylist);
861 m_UpdateEditmodeFocusSequence();
865 void CPlaybackView::m_HandleOnRepeated(void)
867 Evas_Object *obj = NULL;
870 char *timestr = NULL;
872 if (!m->eoPressedObj)
875 obj = m->eoPressedObj;
877 value = elm_slider_value_get(m->eoSlider);
878 duration = m->cs_itinfo->sinfo->Duration();
880 if (obj == m->eoBtnControl[BTN_REWIND]) {
882 m_RemoveTimer(TIMER_LONGPRESS);
885 value = value - LP_CHANGE;
890 if (value == duration) {
891 if (m->hMusicController->PlayNextSong())
892 m_UpdateCurrentSongInfo();
894 _ERR(" music play next song failed ");
896 m->press_status = PRESS_LONG_PAUSE;
897 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE,
898 MUSIC_PLAYBACK_VIEW);
900 m_RemoveTimer(TIMER_LONGPRESS);
904 value = value + LP_CHANGE;
905 if (value >= duration)
909 m->hMusicController->SetPosition(value);
910 elm_slider_value_set(m->eoSlider, value);
911 timestr = CCommonUI::TimeStrFromMilSeconds(value);
913 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
922 void CPlaybackView::m_DeleteSelectedItems(void)
924 Eina_List *l = NULL, *l_next = NULL;
925 SItemInfo *pItemInfo = NULL;
930 m_DisableEditButtons(true);
931 EINA_LIST_FOREACH_SAFE(m->elInfo, l, l_next, obj) {
932 pItemInfo = (SItemInfo *)obj;
933 if (pItemInfo->check_status) {
934 if (m->cs_itinfo == pItemInfo) {
936 m_UnselectItem(m->cs_itinfo);
937 m_RemoveTimer(TIMER_SLIDER);
939 m->hMusicController->SetPlayState(PLAY_STATUS_STOP);
940 m->hMusicController->Stop();
942 index = elm_genlist_item_index_get(pItemInfo->item);
943 m->hMusicController->RemoveSong(pItemInfo->sinfo, index);
945 m->elInfo = eina_list_remove(m->elInfo,
947 elm_object_item_del(pItemInfo->item);
951 if (eina_list_count(m->elInfo) == 0) {
952 m_UpdateEmptySongInfo();
953 elm_genlist_realized_items_update(m->eoPlaylist);
954 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
959 m_UpdateCurrentSongInfo();
961 elm_genlist_realized_items_update(m->eoPlaylist);
962 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
966 void CPlaybackView::m_KeyBackPress(void)
969 m_DestroySettingsPopup();
970 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_FALSE);
971 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
977 if (!CViewMgr::GetInstance()->ShowView(MUSIC_BASE_VIEW))
978 _ERR("CViewMgr::ShowView failed");
980 if (CViewMgr::GetInstance()->CheckTop(MUSIC_CONTEXT_VIEW)) {
981 if (!CViewMgr::GetInstance()->UpdateView(MUSIC_CONTEXT_VIEW, NULL))
982 _ERR("CViewMgr::UpdateView failed");
984 if (!CViewMgr::GetInstance()->ShowView(MUSIC_CONTEXT_VIEW))
985 _ERR("CViewMgr::ShowView failed");
990 void CPlaybackView::m_KeyExitPress(void)
992 m_RemoveTimer(TIMER_SLIDER);
993 m->hMusicController->Stop();
998 void CPlaybackView::m_KeyPlayPress(void)
1002 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1005 state = m->hMusicController->PlayState();
1006 if (state == PLAY_STATUS_PAUSE) {
1008 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1009 MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1011 else if (state != PLAY_STATUS_PLAY) {
1012 if (m->hMusicController)
1013 m->hMusicController->Start();
1015 m_UpdateCurrentSongInfo();
1020 void CPlaybackView::m_KeyPausePress(void)
1024 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1027 state = m->hMusicController->PlayState();
1028 if (state == PLAY_STATUS_PLAY) {
1029 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1030 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1036 void CPlaybackView::m_KeyNextPress(void)
1038 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1041 m_HandleOnPressed(m->eoBtnControl[BTN_FORWARD]);
1045 void CPlaybackView::m_KeyPreviousPress(void)
1047 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1050 m_HandleOnPressed(m->eoBtnControl[BTN_REWIND]);
1054 void CPlaybackView::m_KeyNextUnpress(void)
1056 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1059 m_HandleOnUnpressed(m->eoBtnControl[BTN_FORWARD]);
1063 void CPlaybackView::m_KeyPreviousUnpress(void)
1065 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1068 m_HandleOnUnpressed(m->eoBtnControl[BTN_REWIND]);
1072 void CPlaybackView::m_HandleKeyPress(char *keyname)
1074 if (!strcmp(keyname, (char *)KEY_EXIT))
1076 else if (!strcmp(keyname, (char *)KEY_BACK) ||
1077 !strcmp(keyname, (char *)KEY_BACK_REMOTE))
1079 else if (!strcmp(keyname, (char *)KEY_PLAY))
1081 else if (!strcmp(keyname, (char *)KEY_PAUSE))
1083 else if (!strcmp(keyname, (char *)KEY_NEXT))
1085 else if (!strcmp(keyname, (char *)KEY_PREVIOUS))
1086 m_KeyPreviousPress();
1087 else if (!strcmp(keyname, (char *)KEY_VOLUMEUP))
1088 m->pHandleVolume->Up();
1089 else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN))
1090 m->pHandleVolume->Down();
1091 else if (!strcmp(keyname, (char *)KEY_MUTE))
1092 m->pHandleVolume->Mute();
1096 void CPlaybackView::m_HandleKeyUnpress(char *keyname)
1098 if (!strcmp(keyname, KEY_PREVIOUS))
1099 m_KeyPreviousUnpress();
1100 else if (!strcmp(keyname, KEY_NEXT))
1105 void CPlaybackView::m_AddSlider(void)
1107 Evas_Object *eoSlider = NULL;
1109 eoSlider = elm_slider_add(m->eoBase);
1113 elm_slider_indicator_show_set(eoSlider, EINA_FALSE);
1114 elm_slider_indicator_show_on_focus_set(eoSlider, EINA_FALSE);
1115 elm_object_style_set(eoSlider, MUSIC_STYLE_SLIDER);
1116 elm_slider_horizontal_set(eoSlider, EINA_TRUE);
1117 elm_object_part_content_set(m->eoBase, MUSIC_PART_PROGRESSBAR, eoSlider);
1119 Connect(eoSlider, EO_SLIDER, TYPE_CHANGED | TYPE_MOUSE_MOVE);
1121 evas_object_show(eoSlider);
1122 m->eoSlider = eoSlider;
1126 void CPlaybackView::m_AddAlbumCover(void)
1128 Evas_Object *eoAlbumCover = NULL;
1130 eoAlbumCover = elm_image_add(m->eoBase);
1134 evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
1136 elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
1138 elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
1140 evas_object_show(eoAlbumCover);
1141 m->eoAlbumCover = eoAlbumCover;
1146 void CPlaybackView::m_AddCurrentSonginfo(void)
1153 void CPlaybackView::m_AddEditPlaylistButtons(void)
1155 Evas_Object *box = NULL;
1157 SBtnInfo btninfo[TOTAL_EDIT_BTNS];
1159 btninfo[BTN_CANCEL].txt = MUSIC_TEXT_CANCEL;
1160 btninfo[BTN_CANCEL].type = EO_CANCEL;
1162 btninfo[BTN_DESELECT].txt = MUSIC_TEXT_DESELECT;
1163 btninfo[BTN_DESELECT].type = EO_DESELECT;
1165 btninfo[BTN_DELETE].txt = MUSIC_TEXT_DELETE;
1166 btninfo[BTN_DELETE].type = EO_DELETE;
1168 box = CCommonUI::AddBox(m->eoBase);
1172 elm_box_horizontal_set(box, EINA_TRUE);
1173 elm_box_padding_set(box,
1174 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
1176 for (i = 0; i < TOTAL_EDIT_BTNS; i++) {
1177 m->eoBtnEdit[i] = elm_button_add(m->eoBase);
1178 if (!m->eoBtnEdit[i])
1181 elm_object_style_set(m->eoBtnEdit[i],
1182 MUSIC_STYLE_EDIT_BTN);
1183 evas_object_size_hint_weight_set(m->eoBtnEdit[i],
1184 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1185 elm_box_pack_end(box, m->eoBtnEdit[i]);
1186 elm_object_text_set(m->eoBtnEdit[i], _(btninfo[i].txt));
1188 Connect(m->eoBtnEdit[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1190 evas_object_show(m->eoBtnEdit[i]);
1192 elm_object_part_content_set(m->eoBase, MUSIC_PART_EDITBTNS, box);
1193 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
1194 MUSIC_PLAYBACK_VIEW);
1198 void CPlaybackView::m_AddControlButtons(void)
1200 Evas_Object *box = NULL;
1202 SBtnInfo btninfo[TOTAL_CONTROL_BTNS];
1204 btninfo[BTN_SETTINGS].txt = MUSIC_STYLE_BTN_SETTINGS;
1205 btninfo[BTN_SETTINGS].type = EO_BTN_SETTINGS;
1207 btninfo[BTN_SHUFFLE].txt = MUSIC_STYLE_BTN_SHUFFLE;
1208 btninfo[BTN_SHUFFLE].type = EO_BTN_SHUFFLE;
1210 btninfo[BTN_REPEAT].txt = MUSIC_STYLE_BTN_REPEAT;
1211 btninfo[BTN_REPEAT].type = EO_BTN_REPEAT;
1213 btninfo[BTN_REWIND].txt = MUSIC_STYLE_BTN_REWIND;
1214 btninfo[BTN_REWIND].type = EO_BTN_REWIND;
1216 btninfo[BTN_PLAY].txt = MUSIC_STYLE_BTN_PLAY;
1217 btninfo[BTN_PLAY].type = EO_BTN_PLAY;
1219 btninfo[BTN_FORWARD].txt = MUSIC_STYLE_BTN_FORWARD;
1220 btninfo[BTN_FORWARD].type = EO_BTN_FORWARD;
1222 box = elm_box_add(m->eoBase);
1226 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
1227 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
1228 elm_box_horizontal_set(box, EINA_TRUE);
1229 elm_box_padding_set(box,
1230 MUSIC_CONTROL_BTNS_PADDING * elm_config_scale_get(), 0);
1232 for (i = 0; i < TOTAL_CONTROL_BTNS; i++) {
1233 m->eoBtnControl[i] = elm_button_add(m->eoBase);
1234 if (!m->eoBtnControl[i])
1237 elm_object_style_set(m->eoBtnControl[i], btninfo[i].txt);
1238 evas_object_size_hint_weight_set(m->eoBtnControl[i],
1239 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1240 elm_box_pack_end(box, m->eoBtnControl[i]);
1242 if (i == BTN_REWIND || i == BTN_FORWARD) {
1243 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_PRESSED | TYPE_UNPRESSED | TYPE_MOUSE_MOVE);
1246 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1248 evas_object_show(m->eoBtnControl[i]);
1251 elm_object_part_content_set(m->eoBase, MUSIC_PART_CONTROLBTNS, box);
1255 SItemInfo *CPlaybackView::m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo)
1257 Eina_List *l = NULL;
1258 SItemInfo *itinfo = NULL;
1261 EINA_LIST_FOREACH(list, l, obj) {
1262 itinfo = (SItemInfo *)obj;
1263 if (itinfo->sinfo == sinfo)
1271 SItemInfo *CPlaybackView::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
1273 Eina_List *l = NULL;
1274 SItemInfo *itinfo = NULL;
1277 EINA_LIST_FOREACH(list, l, obj) {
1278 itinfo = (SItemInfo *)obj;
1279 if (itinfo->item == item)
1287 void CPlaybackView::m_UpdateItemCheck(SItemInfo *itinfo)
1290 _ERR(" No item info to Update check ");
1294 if (itinfo->check_status) {
1295 elm_object_item_signal_emit(itinfo->item,
1296 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1297 itinfo->check_status = false;
1301 elm_object_item_signal_emit(itinfo->item,
1302 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
1303 itinfo->check_status = true;
1307 class CElmGenlistItemClass {
1309 static char *sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
1311 CSongInfo *sinfo = NULL;
1312 SItemInfo *pItemInfo = (SItemInfo *)data;
1313 char buf[MAX_LENGTH];
1314 char *timestr = NULL;
1318 if (!pItemInfo || !obj)
1321 sinfo = pItemInfo->sinfo;
1323 snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY);
1325 if (!strcmp(part, "elm.text0")) {
1326 index = elm_genlist_item_index_get(pItemInfo->item);
1327 snprintf(buf, sizeof(buf), "%d", index);
1329 else if (!strcmp(part, "elm.text1"))
1330 snprintf(buf, sizeof(buf), "%s", sinfo->Name());
1331 else if (!strcmp(part, "elm.text2"))
1332 snprintf(buf, sizeof(buf), "%s - %s",
1335 else if (!strcmp(part, "elm.text3")) {
1336 duration = sinfo->Duration();
1337 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
1339 snprintf(buf, sizeof(buf), "%s", timestr);
1344 if (strcmp(buf, MUSIC_STR_EMPTY))
1349 static Evas_Object *sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
1351 CSongInfo *sinfo = NULL;
1352 SItemInfo *pItemInfo = (SItemInfo *)data;
1353 Evas_Object *img = NULL;
1355 char buf[MAX_LENGTH];
1357 if (!pItemInfo || !obj)
1360 sinfo = pItemInfo->sinfo;
1362 img = elm_image_add(obj);
1366 elm_image_aspect_fixed_set(img, EINA_FALSE);
1368 if (!strcmp(part, "elm.swallow.icon")) {
1369 path = sinfo->ThumbnailPath();
1371 elm_image_file_set(img, path, "NULL");
1373 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
1374 MUSIC_IMAGE_DEFAULT_THUMB_126);
1375 elm_image_file_set(img, buf, "NULL");
1382 static void sm_CbDel(void *data, Evas_Object *obj)
1389 Elm_Genlist_Item_Class *CPlaybackView::m_GetItemClass(void)
1391 Elm_Genlist_Item_Class *list_item = NULL;
1393 list_item = elm_genlist_item_class_new();
1395 _ERR(" elm_genlist_item_class_new failed ");
1399 list_item->item_style = MUSIC_STYLE_PLAYLIST;
1400 list_item->func.text_get = CElmGenlistItemClass::sm_CbTextGet;
1401 list_item->func.content_get = CElmGenlistItemClass::sm_CbContentGet;
1402 list_item->func.state_get = NULL;
1403 list_item->func.del = CElmGenlistItemClass::sm_CbDel;
1409 void CPlaybackView::m_AddGenlist(void)
1411 Evas_Object *genlist = NULL;
1412 Evas_Object *eoBase = NULL;
1415 genlist = elm_genlist_add(eoBase);
1419 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1420 evas_object_size_hint_weight_set(genlist,
1421 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1422 elm_object_part_content_set(eoBase, MUSIC_PART_PLAYLIST, genlist);
1423 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
1424 elm_genlist_multi_select_set(genlist, EINA_FALSE);
1426 Connect(genlist, EO_PLAYLIST, TYPE_REALIZED | TYPE_MOUSE_MOVE |
1427 TYPE_KEY_DOWN | TYPE_ACTIVATED);
1429 evas_object_show(genlist);
1430 m->eoPlaylist = genlist;
1434 void CPlaybackView::m_AddPlaylist(void)
1436 Elm_Genlist_Item_Class *list_item = NULL;
1439 CSongInfo *sinfo = NULL;
1440 Elm_Object_Item *item = NULL;
1441 SItemInfo *pItemInfo = NULL;
1447 list_item = m_GetItemClass();
1449 evas_object_del(m->eoPlaylist);
1453 if (!m->hMusicController->GetTotalSongs(&ts)) {
1454 _ERR(" music get total songs failed ");
1458 if (!m->hMusicController->GetCurrentSongIndex(&index))
1459 _ERR(" music get current song index failed ");
1461 for (i = 0; i < ts; i++) {
1462 if (!m->hMusicController->GetSonginfoFromIndex(i, &sinfo)) {
1463 _ERR(" music get songinfo failed ");
1466 pItemInfo = (SItemInfo *)calloc(1, sizeof(*pItemInfo));
1469 pItemInfo->sinfo = sinfo;
1470 pItemInfo->edit_mode = false;
1471 pItemInfo->check_status = false;
1472 pItemInfo->select_status = false;
1474 // event handling will be done in OnActivated function
1475 item = elm_genlist_item_append(m->eoPlaylist, list_item,
1476 pItemInfo, NULL, ELM_GENLIST_ITEM_NONE,
1478 pItemInfo->item = item;
1481 pItemInfo->select_status = true;
1482 m->cs_itinfo = pItemInfo;
1484 m->elInfo = eina_list_append(m->elInfo, pItemInfo);
1489 void CPlaybackView::m_RemovePlaylist(void)
1491 if (m->eoPlaylist) {
1492 elm_genlist_clear(m->eoPlaylist);
1493 m->eoPlaylist = NULL;
1497 eina_list_free(m->elInfo);
1503 void CPlaybackView::m_HandleRewindBtnClicked(Evas_Object *obj)
1505 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1506 MUSIC_PLAYBACK_VIEW);
1508 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1511 if (!m->hMusicController->PlayPreviousSong()){
1512 _ERR(" music play previous song failed ");
1516 m_UpdateCurrentSongInfo();
1520 void CPlaybackView::m_HandleForwardBtnClicked(Evas_Object *obj)
1522 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1523 MUSIC_PLAYBACK_VIEW);
1525 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1528 if (!m->hMusicController->PlayNextSong()) {
1529 _ERR(" music play next song failed ");
1533 m_UpdateCurrentSongInfo();
1537 void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
1539 m->press_status = PRESS_SHORT;
1540 m->eoPressedObj = obj;
1542 m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, this);
1546 void CPlaybackView::m_HandleOnUnpressed(Evas_Object *obj)
1548 m_RemoveTimer(TIMER_WAIT);
1549 m_RemoveTimer(TIMER_LONGPRESS);
1551 if (m->press_status == PRESS_SHORT) {
1552 /* Handle song change */
1553 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY)
1556 if (obj == m->eoBtnControl[BTN_FORWARD])
1557 m_HandleForwardBtnClicked(obj);
1559 m_HandleRewindBtnClicked(obj);
1561 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1564 else if (m->press_status == PRESS_LONG) {
1565 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1569 m->press_status = PRESS_SHORT;
1573 void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_Item *genListItem)
1576 SItemInfo *itinfo = NULL;
1578 if (!obj || !genListItem)
1581 itinfo = m_FindItemInfoFromItem(m->elInfo, genListItem);
1583 _ERR(" no item info found ");
1587 if (itinfo->edit_mode) {
1588 m_UpdateItemCheck(itinfo);
1589 m_DisableEditButtons(false);
1593 index = elm_genlist_item_index_get(genListItem);
1595 m->hMusicController->PlayIndexSong(--index);
1596 m_UpdateCurrentSongInfo();
1600 bool CPlaybackView::Create(void *data)
1605 _CHECK(m = new SPlaybackView)
1606 _CHECK(m->mgr = CViewMgr::GetInstance())
1607 _CHECK(m->eoWin = m->mgr->Window())
1608 _CHECK(m->hMusicController = CMusicController::GetInstance())
1609 _CHECK(m->eoBase = CCommonUI::AddBase(m->eoWin, MUSIC_PLAYBACK_VIEW))
1610 _CHECK(CBaseView::Create(data))
1611 _CHECK(m->hMusicController->AddListener(this))
1614 m->press_status = PRESS_SHORT;
1615 evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1617 m_AddControlButtons();
1618 m_AddEditPlaylistButtons();
1619 m_AddCurrentSonginfo();
1622 m->pHandleVolume->Create(m->eoBase);
1623 m_UpdatePlaymodeFocusSequence();
1625 Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1628 _CHECK_FAIL{ m->hMusicController->RemoveListener(this); }
1629 _CHECK_FAIL{ CBaseView::Destroy(); }
1630 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1631 _CHECK_FAIL{ /* CMusicController::GetInstance())*/ }
1632 _CHECK_FAIL{ /* mgr->Window() */ }
1633 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1634 _CHECK_FAIL{ delete m; m = NULL; }
1635 }_CREATE_END_AND_CATCH{ return false; }
1641 void CPlaybackView::Destroy(void)
1645 Disconnect(m->eoBase);
1646 m->hMusicController->RemoveListener(this);
1648 m_DestroyErrorPopup();
1650 m_RemoveTimer(TIMER_SLIDER);
1651 m_RemoveTimer(TIMER_WAIT);
1652 m_RemoveTimer(TIMER_LONGPRESS);
1653 m_DestroySettingsPopup();
1655 m->pHandleVolume->Destroy();
1656 CBaseView::Destroy();
1657 evas_object_del(m->eoBase);
1665 Evas_Object* CPlaybackView::Base(void)
1673 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1675 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1677 if (eina_list_count(m->elInfo) == 0)
1680 elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1681 m_DestroySettingsPopup();
1682 m_CreateSettingsPopup();
1686 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1688 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1690 switch (m->hMusicController->ShuffleState()) {
1691 case SHUFFLE_STATUS_OFF:
1692 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_ON);
1693 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1697 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_OFF);
1698 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1704 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1706 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1708 switch (m->hMusicController->RepeatState()) {
1709 case REPEAT_STATUS_NONE:
1710 m->hMusicController->SetRepeatState(REPEAT_STATUS_ALL);
1711 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1714 case REPEAT_STATUS_ALL:
1715 m->hMusicController->SetRepeatState(REPEAT_STATUS_ONE);
1716 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1720 m->hMusicController->SetRepeatState(REPEAT_STATUS_NONE);
1721 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1727 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1729 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1731 switch (m->hMusicController->PlayState()) {
1732 case PLAY_STATUS_PAUSE:
1734 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1737 case PLAY_STATUS_PLAY:
1738 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1743 if (m->hMusicController)
1744 m->hMusicController->Start();
1745 m_UpdateCurrentSongInfo();
1751 void CPlaybackView::t_OnShow(void)
1757 m_UpdateCurrentSongInfo();
1759 state = m->hMusicController->PlayState();
1760 if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
1763 m->hMusicController->Start();
1764 m_UpdateCurrentSongInfo();
1768 elm_genlist_item_show(m->cs_itinfo->item,
1769 ELM_GENLIST_ITEM_SCROLLTO_IN);
1770 elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
1773 evas_object_show(m->eoBase);
1777 void CPlaybackView::t_OnUpdate(void *data)
1781 SParcel *parcel = (SParcel *)data;
1783 char *keyEvent = NULL;
1786 updateType = E_PLAYLIST_UPDATE;
1788 updateType = parcel->updateType;
1789 keyEvent = (char *)parcel->keyEvent;
1792 switch (updateType) {
1793 case E_PLAYLIST_UPDATE:
1796 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
1797 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
1798 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
1799 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
1800 m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
1801 m_FromEditToPlaybackMode();
1805 m_HandleKeyPress(keyEvent);
1809 m_HandleKeyUnpress(keyEvent);
1818 void CPlaybackView::t_OnHide(void)
1822 evas_object_hide(m->eoBase);
1826 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
1830 m_HandleKeyPress(ev->keyname);
1833 case EO_ERROR_POPUP_BUTTON:
1834 if (!strcmp(ev->keyname, KEY_BACK) ||
1835 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1836 m_DestroyErrorPopup();
1837 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1843 Elm_Object_Item *it = NULL;
1844 SContentInfo *ctxtinfo = NULL;
1845 SItemInfo *itinfo = NULL;
1847 if (strcmp(ev->keyname, KEY_MENU) &&
1848 strcmp(ev->keyname, KEY_MENU_REMOTE))
1851 it = elm_object_focused_item_get(obj);
1853 _ERR(" unable to get focused item ");
1856 m->focused_item = it;
1863 ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
1867 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
1873 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY &&
1874 itinfo == m->cs_itinfo)
1875 ctxtinfo->status = PLAY_STATUS_PLAY;
1877 ctxtinfo->status = PLAY_STATUS_PAUSE;
1879 ctxtinfo->cbdata = this;
1880 ctxtinfo->update = sm_CbCtxtUpdate;
1881 ctxtinfo->close = sm_CbCtxtClose;
1882 ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
1883 ctxtinfo->context = itinfo->sinfo;
1885 m->ctxtinfo = ctxtinfo;
1888 memset(&parcel, 0, sizeof(SParcel));
1889 parcel.ctxtInfo = ctxtinfo;
1890 if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
1891 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
1895 if (!strcmp(ev->keyname, KEY_BACK) ||
1896 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1897 _ERR("eoCtxPopup BACK key pressed ");
1898 m_DestroySettingsPopup();
1899 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1902 else if (!strcmp(ev->keyname, KEY_EXIT)) {
1903 _ERR("eoCtxPopup EXIT key pressed ");
1904 m_DestroySettingsPopup();
1905 m_RemoveTimer(TIMER_SLIDER);
1906 m->hMusicController->Stop();
1917 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
1921 m_HandleKeyUnpress(ev->keyname);
1930 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
1933 case EO_ERROR_POPUP_BUTTON:
1934 m_DestroyErrorPopup();
1935 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1939 m_DisableCheckAll(m->elInfo);
1940 m_DisableEditButtons(true);
1941 m_FromEditToPlaybackMode();
1945 m_DisableCheckAll(m->elInfo);
1946 m_DisableEditButtons(true);
1947 elm_genlist_realized_items_update(m->eoPlaylist);
1948 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1952 m_DeleteSelectedItems();
1955 case EO_BTN_SETTINGS:
1956 t_OnClickedSettings(obj);
1959 case EO_BTN_SHUFFLE:
1960 t_OnClickedShuffle(obj);
1964 t_OnClickedRepeat(obj);
1968 t_OnClickedPlay(obj);
1977 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
1984 case EO_BTN_FORWARD:
1988 case EO_BTN_SETTINGS:
1989 case EO_BTN_SHUFFLE:
1990 if (!elm_object_focus_get(obj))
1991 elm_object_focus_set(obj, EINA_TRUE);
1996 Elm_Object_Item *item;
1998 item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
1999 ev->cur.canvas.y, NULL);
2003 if (!elm_object_item_focus_get(item))
2004 elm_object_item_focus_set(item, EINA_TRUE);
2014 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2017 case EO_BTN_FORWARD:
2019 m_HandleOnPressed(obj);
2028 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2031 case EO_BTN_FORWARD:
2033 m_HandleOnUnpressed(obj);
2042 void CPlaybackView::OnChanged(int id, Evas_Object *obj)
2047 char *timestr = NULL;
2050 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2052 ecore_timer_freeze(m->etSlider);
2055 value = elm_slider_value_get(obj);
2056 m->hMusicController->SetPosition(value);
2057 timestr = CCommonUI::TimeStrFromMilSeconds(value);
2059 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
2064 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2066 ecore_timer_thaw(m->etSlider);
2077 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2082 int index = elm_genlist_item_index_get(item);
2083 if ((index & 1) == 1)
2084 elm_object_item_signal_emit(item,
2085 MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW);
2087 elm_object_item_signal_emit(item,
2088 MUSIC_SIGNAL_ODD_ROW, MUSIC_PLAYBACK_VIEW);
2090 SItemInfo *itInfo = m_FindItemInfoFromItem(m->elInfo, item);
2091 if (itInfo->select_status)
2092 elm_object_item_signal_emit(item,
2093 MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2095 elm_object_item_signal_emit(item,
2096 MUSIC_SIGNAL_UNSELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2098 if (itInfo->edit_mode) {
2099 elm_object_item_signal_emit(item,
2100 MUSIC_SIGNAL_EDITMODE_ON, MUSIC_PLAYBACK_VIEW);
2101 if (itInfo->check_status) {
2102 elm_object_item_signal_emit(item,
2103 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
2106 elm_object_item_signal_emit(item,
2107 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
2110 elm_object_item_signal_emit(item,
2111 MUSIC_SIGNAL_EDITMODE_OFF, MUSIC_PLAYBACK_VIEW);
2121 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2125 m_HandleGenlistItemActivated(obj, item);
2134 void CPlaybackView::OnComplete(void)
2136 m_UpdateCurrentSongInfo();
2140 void CPlaybackView::OnError(void)
2142 m_CreateErrorPopup();
2146 void CPlaybackView::OnUsbStatusChanged(SUsbStorageStatus status)
2151 void CPlaybackView::OnUpdateContent(void)