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 CPlaybackView *parent;
116 CHandleVolume *pHandleVolume;
119 memset(this, 0, sizeof(SPlaybackView));
120 pHandleVolume = new CHandleVolume;
123 delete pHandleVolume;
168 Eina_Bool CPlaybackView::sm_CbUpdateSlider(void *dt)
170 SPlaybackView *m = (SPlaybackView *)dt;
171 char *timestr = NULL;
176 return ECORE_CALLBACK_CANCEL;
178 if (!m->hMusicController->GetPosition(&value)) {
180 return ECORE_CALLBACK_CANCEL;
183 duration = m->csinfo->Duration();
185 value = value + S_INCREMENT;
186 if (value > duration) {
188 return ECORE_CALLBACK_CANCEL;
191 elm_slider_value_set(m->eoSlider, value);
192 timestr = CCommonUI::TimeStrFromMilSeconds(value);
194 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
199 return ECORE_CALLBACK_RENEW;
203 Eina_Bool CPlaybackView::sm_CbLongpressTimer(void *dt)
205 SPlaybackView *m = (SPlaybackView *)dt;
207 m->parent->m_HandleOnRepeated();
209 return ECORE_CALLBACK_RENEW;
213 Eina_Bool CPlaybackView::sm_CbWaitTimer(void *dt)
215 SPlaybackView *m = (SPlaybackView *)dt;
217 m->press_status = PRESS_LONG;
218 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
219 /* Handle long press */
220 m->parent->m_PlaybackPause();
221 m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, m);
224 m->press_status = PRESS_LONG_PAUSE;
228 return ECORE_CALLBACK_CANCEL;
232 void CPlaybackView::sm_CbItemSelect(void *data, Evas_Object *obj, void *event_info)
237 void CPlaybackView::sm_CbGenlistItemCheckClicked(void *data, Elm_Object_Item *it, const char *emission, const char *source)
239 CPlaybackView *root = (CPlaybackView*)data;
241 root->m_OnGenlistItemCheckClicked(it, emission, source);
245 void CPlaybackView::m_OnGenlistItemCheckClicked(Elm_Object_Item *it, const char *emission, const char *source)
247 SItemInfo *itinfo = NULL;
249 if (!it || !emission)
252 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
254 _ERR(" no item info found ");
258 if (itinfo->edit_mode) {
259 m_UpdateItemCheck(itinfo);
260 m_DisableEditButtons(false);
265 void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
267 SPlaybackView *m = (SPlaybackView *)dt;
268 SItemInfo *itinfo = NULL;
269 Elm_Object_Item *focucedItem = NULL;
274 if (!m->ctxtinfo || !m->ctxtinfo->context)
277 itinfo = m->parent->m_FindItemInfoFromSong(m->elInfo,
278 (CSongInfo *)m->ctxtinfo->context);
280 _ERR(" Unable to find song in the list ");
284 if (type == ACTION_TYPE_DELETE) {
285 itinfo->check_status = true;
286 m->parent->m_DeleteSelectedItems();
288 if (!m->mgr->PopView()) {
289 _ERR("CViewMgr::PopView failed");
293 focucedItem = m->cs_itinfo->item;
295 else { // ACTION_TYPE_PLAY
296 if (m->ctxtinfo->status == PLAY_STATUS_PLAY)
297 m->parent->m_KeyPausePress();
299 if (itinfo == m->cs_itinfo)
300 m->parent->m_KeyPlayPress();
302 m->parent->m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
305 if (!m->mgr->PopView()) {
306 _ERR("CViewMgr::PopView failed");
310 focucedItem = m->focused_item;
313 elm_object_item_focus_set(focucedItem, EINA_TRUE);
317 void CPlaybackView::sm_CbCtxtClose(void *dt)
319 SPlaybackView *m = (SPlaybackView *)dt;
324 if (!m->mgr->PopView()) {
325 _ERR("CViewMgr::PopView failed");
329 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
333 void CPlaybackView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text)
335 CPlaybackView *root = (CPlaybackView *)cookie;
337 root->m_CbCtxPopupBtnSelected(instance, text);
341 void CPlaybackView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text)
343 int type = CInfo::PlaybackSettingType();
347 m_FromPlaybackToEditMode();
351 m->hMusicController->Stop();
352 m->hMusicController->EmptyPlaylist();
353 eina_list_free(m->elInfo);
355 elm_genlist_clear(m->eoPlaylist);
356 m_UpdateEmptySongInfo();
365 void CPlaybackView::m_RemoveTimer(int timer_code)
367 ETimers timerCode = (ETimers)timer_code;
372 ecore_timer_del(m->etSlider);
379 ecore_timer_del(m->etWait);
384 case TIMER_LONGPRESS:
385 if (m->etLongPress) {
386 ecore_timer_del(m->etLongPress);
387 m->etLongPress = NULL;
392 m->pHandleVolume->RemoveTimer();
396 _ERR(" invalid value ");
402 void CPlaybackView::m_PlaybackPause(void)
404 m->hMusicController->Pause();
407 ecore_timer_freeze(m->etSlider);
411 void CPlaybackView::m_PlaybackResume(void)
413 m->hMusicController->Resume();
416 ecore_timer_thaw(m->etSlider);
420 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
422 SItemInfo *itinfo = NULL;
426 EINA_LIST_FOREACH(list, l, obj) {
427 itinfo = (SItemInfo *)obj;
428 itinfo->edit_mode = flag;
433 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
435 SItemInfo *itinfo = NULL;
439 EINA_LIST_FOREACH(list, l, obj) {
440 itinfo = (SItemInfo *)obj;
441 itinfo->check_status = false;
446 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
448 if (!pItemInfo || !pItemInfo->item)
451 elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
452 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
454 pItemInfo->select_status = true;
458 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
460 if (!pItemInfo || !pItemInfo->item)
463 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
464 MUSIC_PLAYBACK_VIEW);
466 pItemInfo->select_status = false;
470 void CPlaybackView::m_UpdateControlBtns(void)
474 state = m->hMusicController->PlayState();
475 if (state != PLAY_STATUS_STOP) {
476 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
477 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
481 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
482 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
483 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
486 if (state == PLAY_STATUS_PLAY) {
487 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
490 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
493 state = m->hMusicController->ShuffleState();
494 if (state == SHUFFLE_STATUS_OFF) {
495 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
498 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
501 state = m->hMusicController->RepeatState();
502 if (state == REPEAT_STATUS_NONE) {
503 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
505 else if (state == REPEAT_STATUS_ALL) {
506 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
509 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
514 void CPlaybackView::m_UpdateCurrentSongProgressbar(void)
517 char *timestr = NULL;
524 elm_slider_value_set(m->eoSlider, 0);
525 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
527 state = m->hMusicController->PlayState();
529 if (state == PLAY_STATUS_STOP) {
530 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
531 m_RemoveTimer(TIMER_SLIDER);
535 elm_object_disabled_set(m->eoSlider, EINA_FALSE);
537 duration = m->csinfo->Duration();
539 m_RemoveTimer(TIMER_SLIDER);
540 m->etSlider = ecore_timer_add(S_INTERVAL,
541 sm_CbUpdateSlider, m);
543 elm_slider_min_max_set(m->eoSlider, 0, duration);
544 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
546 elm_object_part_text_set(m->eoBase,
547 MUSIC_PART_FULLTIME, timestr);
551 step = (double)SLIDER_STEP / (double)duration;
552 elm_slider_step_set(m->eoSlider, step);
557 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
560 char buf[MAX_LENGTH];
562 if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
565 path = m->cs_itinfo->sinfo->ThumbnailPath();
567 elm_image_file_set(m->eoAlbumCover, path, NULL);
569 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
570 MUSIC_IMAGE_DEFAULT_THUMB_450);
571 elm_image_file_set(m->eoAlbumCover, buf, NULL);
576 void CPlaybackView::m_UpdateCurrentSongLabels(void)
578 char buf[MAX_LENGTH];
583 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
586 snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
589 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
593 void CPlaybackView::m_UpdateEmptySongInfo(void)
595 char buf[MAX_LENGTH];
597 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
598 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
599 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
600 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
601 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
602 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
603 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
604 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
605 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
606 elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
607 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
608 elm_slider_value_set(m->eoSlider, 0);
609 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
610 _(NO_PLAYLIST_MESSAGE));
611 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
612 _(NO_PLAYLIST_MESSAGE_SUB));
613 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
614 MUSIC_IMAGE_DEFAULT_THUMB_450);
615 elm_image_file_set(m->eoAlbumCover, buf, NULL);
616 m->hMusicController->SetPlayState(PLAY_STATUS_INITIAL);
620 void CPlaybackView::m_UpdateCtxtView(int playStatus)
622 if (!m->cs_itinfo || !m->ctxtinfo)
625 if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
628 if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
629 m->ctxtinfo->status = (EPlayStatus)playStatus;
632 memset(&parcel, 0, sizeof(SParcel));
633 parcel.updateType = E_SONG_UPDATE;
634 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
639 void CPlaybackView::m_UpdateCurrentSongItem(int index)
641 SItemInfo *pItemInfo = NULL;
644 m_UnselectItem(m->cs_itinfo);
645 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
648 pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
651 m->cs_itinfo = pItemInfo;
652 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
653 elm_genlist_item_bring_in(pItemInfo->item,
654 ELM_GENLIST_ITEM_SCROLLTO_IN);
657 m_SelectItem(pItemInfo);
658 m_UpdateCtxtView(PLAY_STATUS_PLAY);
664 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
666 elm_object_focus_next_object_set(m->eoPlaylist,
667 m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
668 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
669 m->eoPlaylist, ELM_FOCUS_RIGHT);
670 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnEdit[BTN_CANCEL],
675 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
677 elm_object_focus_next_object_set(m->eoSlider, m->eoPlaylist,
679 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnControl[BTN_PLAY],
681 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
682 elm_object_focus_next_object_set(m->eoPlaylist,
683 m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
684 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
685 m->eoPlaylist, ELM_FOCUS_RIGHT);
688 elm_object_focus_next_object_set(m->eoPlaylist,
689 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
690 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
691 m->eoPlaylist, ELM_FOCUS_RIGHT);
692 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
693 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
698 void CPlaybackView::m_UpdateCurrentSongInfo(void)
700 CSongInfo *sinfo = NULL;
703 if (eina_list_count(m->elInfo) == 0) {
704 m_UpdateEmptySongInfo();
708 if (!m->hMusicController->GetCurrentSongIndex(&index)) {
709 _ERR(" music get current song index failed ");
713 if (!m->hMusicController->GetSonginfoFromIndex(index, &sinfo)) {
714 _ERR(" music get songinfo failed ");
719 m_UpdateCurrentSongItem(index);
720 m_UpdateCurrentSongLabels();
721 m_UpdateCurrentSongThumbnail();
722 m_UpdateCurrentSongProgressbar();
723 m_UpdateControlBtns();
724 m_UpdatePlaymodeFocusSequence();
728 void CPlaybackView::m_DisableEditButtons(bool flag)
730 /* flag - 1 means disable edit buttons and 0 means enable */
732 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
734 elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
735 elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
737 m_UpdateEditmodeFocusSequence();
738 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
741 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
742 m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
743 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE],
744 m->eoPlaylist, ELM_FOCUS_RIGHT);
745 elm_object_focus_next_object_set(m->eoPlaylist,
746 m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
751 void CPlaybackView::m_CreateErrorPopup(void)
753 Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
755 popup = elm_popup_add(m->eoBase);
759 elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
760 evas_object_show(popup);
762 label = elm_label_add(popup);
764 evas_object_del(popup);
768 elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
769 elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
770 elm_object_content_set(popup, label);
772 btn = elm_button_add(popup);
774 evas_object_del(popup);
778 elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
779 elm_object_text_set(btn, MUSIC_TEXT_OK);
780 elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
782 m->eoErrPopup = popup;
784 Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
786 elm_object_focus_set(btn, EINA_TRUE);
792 void CPlaybackView::m_DestroyErrorPopup(void)
797 evas_object_del(m->eoErrPopup);
798 m->eoErrPopup = NULL;
802 void CPlaybackView::m_CreateSettingsPopup(void)
804 CPlaySettingCtxPopup *eoCtxPopup = new CPlaySettingCtxPopup;
805 CCtxPopup::SCallback cb;
807 cb.onSelected = sm_CbCtxPopupBtnSelected;
809 eoCtxPopup->Create(m->eoWin, &cb);
811 m->eoCtxPopup = eoCtxPopup;
815 void CPlaybackView::m_DestroySettingsPopup(void)
820 if (m->eoCtxPopup->FlagCreate())
821 m->eoCtxPopup->Destroy();
823 delete m->eoCtxPopup;
824 m->eoCtxPopup = NULL;
828 void CPlaybackView::m_FromEditToPlaybackMode(void)
830 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
831 elm_genlist_item_bring_in(m->cs_itinfo->item,
832 ELM_GENLIST_ITEM_SCROLLTO_IN);
835 m_SelectItem(m->cs_itinfo);
837 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
838 MUSIC_PLAYBACK_VIEW);
839 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
841 m_ChangeEditmodeAll(m->elInfo, false);
843 elm_genlist_realized_items_update(m->eoPlaylist);
845 m_UpdatePlaymodeFocusSequence();
849 void CPlaybackView::m_FromPlaybackToEditMode(void)
851 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_EDIT_MODE,
852 MUSIC_PLAYBACK_VIEW);
854 m_DisableEditButtons(true);
856 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
858 m_ChangeEditmodeAll(m->elInfo, true);
860 elm_genlist_realized_items_update(m->eoPlaylist);
862 m_UpdateEditmodeFocusSequence();
866 void CPlaybackView::m_HandleOnRepeated(void)
868 Evas_Object *obj = NULL;
871 char *timestr = NULL;
873 if (!m->eoPressedObj)
876 obj = m->eoPressedObj;
878 value = elm_slider_value_get(m->eoSlider);
879 duration = m->cs_itinfo->sinfo->Duration();
881 if (obj == m->eoBtnControl[BTN_REWIND]) {
883 m_RemoveTimer(TIMER_LONGPRESS);
886 value = value - LP_CHANGE;
891 if (value == duration) {
892 if (m->hMusicController->PlayNextSong())
893 m_UpdateCurrentSongInfo();
895 _ERR(" music play next song failed ");
897 m->press_status = PRESS_LONG_PAUSE;
898 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE,
899 MUSIC_PLAYBACK_VIEW);
901 m_RemoveTimer(TIMER_LONGPRESS);
905 value = value + LP_CHANGE;
906 if (value >= duration)
910 m->hMusicController->SetPosition(value);
911 elm_slider_value_set(m->eoSlider, value);
912 timestr = CCommonUI::TimeStrFromMilSeconds(value);
914 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
923 void CPlaybackView::m_DeleteSelectedItems(void)
925 Eina_List *l = NULL, *l_next = NULL;
926 SItemInfo *pItemInfo = NULL;
931 m_DisableEditButtons(true);
932 EINA_LIST_FOREACH_SAFE(m->elInfo, l, l_next, obj) {
933 pItemInfo = (SItemInfo *)obj;
934 if (pItemInfo->check_status) {
935 if (m->cs_itinfo == pItemInfo) {
937 m_UnselectItem(m->cs_itinfo);
938 m_RemoveTimer(TIMER_SLIDER);
940 m->hMusicController->SetPlayState(PLAY_STATUS_STOP);
941 m->hMusicController->Stop();
943 index = elm_genlist_item_index_get(pItemInfo->item);
944 m->hMusicController->RemoveSong(pItemInfo->sinfo, index);
946 m->elInfo = eina_list_remove(m->elInfo,
948 elm_object_item_del(pItemInfo->item);
952 if (eina_list_count(m->elInfo) == 0) {
953 m_UpdateEmptySongInfo();
954 elm_genlist_realized_items_update(m->eoPlaylist);
955 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
960 m_UpdateCurrentSongInfo();
962 elm_genlist_realized_items_update(m->eoPlaylist);
963 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
967 void CPlaybackView::m_KeyBackPress(void)
970 m_DestroySettingsPopup();
971 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_FALSE);
972 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
981 void CPlaybackView::m_KeyExitPress(void)
983 m_RemoveTimer(TIMER_SLIDER);
984 m->hMusicController->Stop();
989 void CPlaybackView::m_KeyPlayPress(void)
993 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
996 state = m->hMusicController->PlayState();
997 if (state == PLAY_STATUS_PAUSE) {
999 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1000 MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1002 else if (state != PLAY_STATUS_PLAY) {
1003 if (m->hMusicController)
1004 m->hMusicController->Start();
1006 m_UpdateCurrentSongInfo();
1011 void CPlaybackView::m_KeyPausePress(void)
1015 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1018 state = m->hMusicController->PlayState();
1019 if (state == PLAY_STATUS_PLAY) {
1020 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1021 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1027 void CPlaybackView::m_KeyNextPress(void)
1029 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1032 m_HandleOnPressed(m->eoBtnControl[BTN_FORWARD]);
1036 void CPlaybackView::m_KeyPreviousPress(void)
1038 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1041 m_HandleOnPressed(m->eoBtnControl[BTN_REWIND]);
1045 void CPlaybackView::m_KeyNextUnpress(void)
1047 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1050 m_HandleOnUnpressed(m->eoBtnControl[BTN_FORWARD]);
1054 void CPlaybackView::m_KeyPreviousUnpress(void)
1056 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1059 m_HandleOnUnpressed(m->eoBtnControl[BTN_REWIND]);
1063 void CPlaybackView::m_HandleKeyPress(char *keyname)
1065 if (!strcmp(keyname, (char *)KEY_EXIT))
1067 else if (!strcmp(keyname, (char *)KEY_BACK) ||
1068 !strcmp(keyname, (char *)KEY_BACK_REMOTE))
1070 else if (!strcmp(keyname, (char *)KEY_PLAY))
1072 else if (!strcmp(keyname, (char *)KEY_PAUSE))
1074 else if (!strcmp(keyname, (char *)KEY_NEXT))
1076 else if (!strcmp(keyname, (char *)KEY_PREVIOUS))
1077 m_KeyPreviousPress();
1078 else if (!strcmp(keyname, (char *)KEY_VOLUMEUP))
1079 m->pHandleVolume->Up();
1080 else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN))
1081 m->pHandleVolume->Down();
1082 else if (!strcmp(keyname, (char *)KEY_MUTE))
1083 m->pHandleVolume->Mute();
1087 void CPlaybackView::m_HandleKeyUnpress(char *keyname)
1089 if (!strcmp(keyname, KEY_PREVIOUS))
1090 m_KeyPreviousUnpress();
1091 else if (!strcmp(keyname, KEY_NEXT))
1096 void CPlaybackView::m_AddSlider(void)
1098 Evas_Object *eoSlider = NULL;
1100 eoSlider = elm_slider_add(m->eoBase);
1104 elm_slider_indicator_show_set(eoSlider, EINA_FALSE);
1105 elm_slider_indicator_show_on_focus_set(eoSlider, EINA_FALSE);
1106 elm_object_style_set(eoSlider, MUSIC_STYLE_SLIDER);
1107 elm_slider_horizontal_set(eoSlider, EINA_TRUE);
1108 elm_object_part_content_set(m->eoBase, MUSIC_PART_PROGRESSBAR, eoSlider);
1110 Connect(eoSlider, EO_SLIDER, TYPE_CHANGED | TYPE_MOUSE_MOVE);
1112 evas_object_show(eoSlider);
1113 m->eoSlider = eoSlider;
1117 void CPlaybackView::m_AddAlbumCover(void)
1119 Evas_Object *eoAlbumCover = NULL;
1121 eoAlbumCover = elm_image_add(m->eoBase);
1125 evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
1127 elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
1129 elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
1131 evas_object_show(eoAlbumCover);
1132 m->eoAlbumCover = eoAlbumCover;
1137 void CPlaybackView::m_AddCurrentSonginfo(void)
1144 void CPlaybackView::m_AddEditPlaylistButtons(void)
1146 Evas_Object *box = NULL;
1148 SBtnInfo btninfo[TOTAL_EDIT_BTNS];
1150 btninfo[BTN_CANCEL].txt = MUSIC_TEXT_CANCEL;
1151 btninfo[BTN_CANCEL].type = EO_CANCEL;
1153 btninfo[BTN_DESELECT].txt = MUSIC_TEXT_DESELECT;
1154 btninfo[BTN_DESELECT].type = EO_DESELECT;
1156 btninfo[BTN_DELETE].txt = MUSIC_TEXT_DELETE;
1157 btninfo[BTN_DELETE].type = EO_DELETE;
1159 box = CCommonUI::AddBox(m->eoBase);
1163 elm_box_horizontal_set(box, EINA_TRUE);
1164 elm_box_padding_set(box,
1165 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
1167 for (i = 0; i < TOTAL_EDIT_BTNS; i++) {
1168 m->eoBtnEdit[i] = elm_button_add(m->eoBase);
1169 if (!m->eoBtnEdit[i])
1172 elm_object_style_set(m->eoBtnEdit[i],
1173 MUSIC_STYLE_EDIT_BTN);
1174 evas_object_size_hint_weight_set(m->eoBtnEdit[i],
1175 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1176 elm_box_pack_end(box, m->eoBtnEdit[i]);
1177 elm_object_text_set(m->eoBtnEdit[i], _(btninfo[i].txt));
1179 Connect(m->eoBtnEdit[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1181 evas_object_show(m->eoBtnEdit[i]);
1183 elm_object_part_content_set(m->eoBase, MUSIC_PART_EDITBTNS, box);
1184 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
1185 MUSIC_PLAYBACK_VIEW);
1189 void CPlaybackView::m_AddControlButtons(void)
1191 Evas_Object *box = NULL;
1193 SBtnInfo btninfo[TOTAL_CONTROL_BTNS];
1195 btninfo[BTN_SETTINGS].txt = MUSIC_STYLE_BTN_SETTINGS;
1196 btninfo[BTN_SETTINGS].type = EO_BTN_SETTINGS;
1198 btninfo[BTN_SHUFFLE].txt = MUSIC_STYLE_BTN_SHUFFLE;
1199 btninfo[BTN_SHUFFLE].type = EO_BTN_SHUFFLE;
1201 btninfo[BTN_REPEAT].txt = MUSIC_STYLE_BTN_REPEAT;
1202 btninfo[BTN_REPEAT].type = EO_BTN_REPEAT;
1204 btninfo[BTN_REWIND].txt = MUSIC_STYLE_BTN_REWIND;
1205 btninfo[BTN_REWIND].type = EO_BTN_REWIND;
1207 btninfo[BTN_PLAY].txt = MUSIC_STYLE_BTN_PLAY;
1208 btninfo[BTN_PLAY].type = EO_BTN_PLAY;
1210 btninfo[BTN_FORWARD].txt = MUSIC_STYLE_BTN_FORWARD;
1211 btninfo[BTN_FORWARD].type = EO_BTN_FORWARD;
1213 box = elm_box_add(m->eoBase);
1217 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
1218 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
1219 elm_box_horizontal_set(box, EINA_TRUE);
1220 elm_box_padding_set(box,
1221 MUSIC_CONTROL_BTNS_PADDING * elm_config_scale_get(), 0);
1223 for (i = 0; i < TOTAL_CONTROL_BTNS; i++) {
1224 m->eoBtnControl[i] = elm_button_add(m->eoBase);
1225 if (!m->eoBtnControl[i])
1228 elm_object_style_set(m->eoBtnControl[i], btninfo[i].txt);
1229 evas_object_size_hint_weight_set(m->eoBtnControl[i],
1230 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1231 elm_box_pack_end(box, m->eoBtnControl[i]);
1233 if (i == BTN_REWIND || i == BTN_FORWARD) {
1234 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_PRESSED | TYPE_UNPRESSED | TYPE_MOUSE_MOVE);
1237 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1239 evas_object_show(m->eoBtnControl[i]);
1242 elm_object_part_content_set(m->eoBase, MUSIC_PART_CONTROLBTNS, box);
1246 SItemInfo *CPlaybackView::m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo)
1248 Eina_List *l = NULL;
1249 SItemInfo *itinfo = NULL;
1252 EINA_LIST_FOREACH(list, l, obj) {
1253 itinfo = (SItemInfo *)obj;
1254 if (itinfo->sinfo == sinfo)
1262 SItemInfo *CPlaybackView::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
1264 Eina_List *l = NULL;
1265 SItemInfo *itinfo = NULL;
1268 EINA_LIST_FOREACH(list, l, obj) {
1269 itinfo = (SItemInfo *)obj;
1270 if (itinfo->item == item)
1278 void CPlaybackView::m_UpdateItemCheck(SItemInfo *itinfo)
1281 _ERR(" No item info to Update check ");
1285 if (itinfo->check_status) {
1286 elm_object_item_signal_emit(itinfo->item,
1287 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1288 itinfo->check_status = false;
1292 elm_object_item_signal_emit(itinfo->item,
1293 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
1294 itinfo->check_status = true;
1298 class CElmGenlistItemClass {
1300 static char *sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
1302 CSongInfo *sinfo = NULL;
1303 SItemInfo *pItemInfo = (SItemInfo *)data;
1304 char buf[MAX_LENGTH];
1305 char *timestr = NULL;
1309 if (!pItemInfo || !obj)
1312 sinfo = pItemInfo->sinfo;
1314 snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY);
1316 if (!strcmp(part, "elm.text0")) {
1317 index = elm_genlist_item_index_get(pItemInfo->item);
1318 snprintf(buf, sizeof(buf), "%d", index);
1319 if ((index & 1) == 1) {
1320 elm_object_item_signal_emit(pItemInfo->item,
1321 MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW);
1324 elm_object_item_signal_emit(pItemInfo->item,
1325 MUSIC_SIGNAL_ODD_ROW, MUSIC_PLAYBACK_VIEW);
1328 else if (!strcmp(part, "elm.text1"))
1329 snprintf(buf, sizeof(buf), "%s", sinfo->Name());
1330 else if (!strcmp(part, "elm.text2"))
1331 snprintf(buf, sizeof(buf), "%s - %s",
1334 else if (!strcmp(part, "elm.text3")) {
1335 duration = sinfo->Duration();
1336 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
1338 snprintf(buf, sizeof(buf), "%s", timestr);
1343 if (strcmp(buf, MUSIC_STR_EMPTY))
1348 static Evas_Object *sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
1350 CSongInfo *sinfo = NULL;
1351 SItemInfo *pItemInfo = (SItemInfo *)data;
1352 Evas_Object *img = NULL;
1354 char buf[MAX_LENGTH];
1356 if (!pItemInfo || !obj)
1359 sinfo = pItemInfo->sinfo;
1361 img = elm_image_add(obj);
1365 elm_image_aspect_fixed_set(img, EINA_FALSE);
1367 if (!strcmp(part, "elm.swallow.icon")) {
1368 path = sinfo->ThumbnailPath();
1370 elm_image_file_set(img, path, "NULL");
1372 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
1373 MUSIC_IMAGE_DEFAULT_THUMB_126);
1374 elm_image_file_set(img, buf, "NULL");
1378 if (pItemInfo->select_status) {
1379 elm_object_item_signal_emit(pItemInfo->item,
1380 MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
1383 elm_object_item_signal_emit(pItemInfo->item,
1384 MUSIC_SIGNAL_UNSELECT_ITEM,
1385 MUSIC_PLAYBACK_VIEW);
1388 if (pItemInfo->edit_mode) {
1389 elm_object_item_signal_emit(pItemInfo->item,
1390 MUSIC_SIGNAL_EDITMODE_ON, MUSIC_PLAYBACK_VIEW);
1391 if (pItemInfo->check_status) {
1392 elm_object_item_signal_emit(pItemInfo->item,
1393 MUSIC_SIGNAL_CHECK_ON,
1394 MUSIC_PLAYBACK_VIEW);
1397 elm_object_item_signal_emit(pItemInfo->item,
1398 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1402 elm_object_item_signal_emit(pItemInfo->item,
1403 MUSIC_SIGNAL_EDITMODE_OFF, MUSIC_PLAYBACK_VIEW);
1409 static void sm_CbDel(void *data, Evas_Object *obj)
1416 Elm_Genlist_Item_Class *CPlaybackView::m_GetItemClass(void)
1418 Elm_Genlist_Item_Class *list_item = NULL;
1420 list_item = elm_genlist_item_class_new();
1422 _ERR(" elm_genlist_item_class_new failed ");
1426 list_item->item_style = MUSIC_STYLE_PLAYLIST;
1427 list_item->func.text_get = CElmGenlistItemClass::sm_CbTextGet;
1428 list_item->func.content_get = CElmGenlistItemClass::sm_CbContentGet;
1429 list_item->func.state_get = NULL;
1430 list_item->func.del = CElmGenlistItemClass::sm_CbDel;
1436 void CPlaybackView::m_AddGenlist(void)
1438 Evas_Object *genlist = NULL;
1439 Evas_Object *eoBase = NULL;
1442 genlist = elm_genlist_add(eoBase);
1446 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1447 evas_object_size_hint_weight_set(genlist,
1448 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1449 elm_object_part_content_set(eoBase, MUSIC_PART_PLAYLIST, genlist);
1450 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
1451 elm_genlist_multi_select_set(genlist, EINA_FALSE);
1453 Connect(genlist, EO_PLAYLIST, TYPE_REALIZED | TYPE_UNREALIZED | TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_ACTIVATED);
1455 evas_object_show(genlist);
1456 m->eoPlaylist = genlist;
1460 void CPlaybackView::m_AddPlaylist(void)
1462 Elm_Genlist_Item_Class *list_item = NULL;
1465 CSongInfo *sinfo = NULL;
1466 Elm_Object_Item *item = NULL;
1467 SItemInfo *pItemInfo = NULL;
1473 list_item = m_GetItemClass();
1475 evas_object_del(m->eoPlaylist);
1479 if (!m->hMusicController->GetTotalSongs(&ts)) {
1480 _ERR(" music get total songs failed ");
1484 if (!m->hMusicController->GetCurrentSongIndex(&index))
1485 _ERR(" music get current song index failed ");
1487 for (i = 0; i < ts; i++) {
1488 if (!m->hMusicController->GetSonginfoFromIndex(i, &sinfo)) {
1489 _ERR(" music get songinfo failed ");
1492 pItemInfo = (SItemInfo *)calloc(1, sizeof(*pItemInfo));
1495 pItemInfo->sinfo = sinfo;
1496 pItemInfo->edit_mode = false;
1497 pItemInfo->check_status = false;
1498 pItemInfo->select_status = false;
1500 item = elm_genlist_item_append(m->eoPlaylist, list_item,
1501 pItemInfo, NULL, ELM_GENLIST_ITEM_NONE,
1502 sm_CbItemSelect, m);
1503 pItemInfo->item = item;
1506 pItemInfo->select_status = true;
1507 m->cs_itinfo = pItemInfo;
1509 m->elInfo = eina_list_append(m->elInfo, pItemInfo);
1514 void CPlaybackView::m_RemovePlaylist(void)
1516 if (m->eoPlaylist) {
1517 elm_genlist_clear(m->eoPlaylist);
1518 m->eoPlaylist = NULL;
1522 eina_list_free(m->elInfo);
1528 void CPlaybackView::m_HandleRewindBtnClicked(Evas_Object *obj)
1530 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1531 MUSIC_PLAYBACK_VIEW);
1533 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1536 if (!m->hMusicController->PlayPreviousSong()){
1537 _ERR(" music play previous song failed ");
1541 m_UpdateCurrentSongInfo();
1545 void CPlaybackView::m_HandleForwardBtnClicked(Evas_Object *obj)
1547 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1548 MUSIC_PLAYBACK_VIEW);
1550 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1553 if (!m->hMusicController->PlayNextSong()) {
1554 _ERR(" music play next song failed ");
1558 m_UpdateCurrentSongInfo();
1562 void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
1564 m->press_status = PRESS_SHORT;
1565 m->eoPressedObj = obj;
1567 m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, m);
1571 void CPlaybackView::m_HandleOnUnpressed(Evas_Object *obj)
1573 m_RemoveTimer(TIMER_WAIT);
1574 m_RemoveTimer(TIMER_LONGPRESS);
1576 if (m->press_status == PRESS_SHORT) {
1577 /* Handle song change */
1578 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY)
1581 if (obj == m->eoBtnControl[BTN_FORWARD])
1582 m_HandleForwardBtnClicked(obj);
1584 m_HandleRewindBtnClicked(obj);
1586 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1589 else if (m->press_status == PRESS_LONG) {
1590 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1594 m->press_status = PRESS_SHORT;
1598 void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_Item *genListItem)
1601 SItemInfo *itinfo = NULL;
1603 if (!obj || !genListItem)
1606 itinfo = m_FindItemInfoFromItem(m->elInfo, genListItem);
1608 _ERR(" no item info found ");
1612 if (itinfo->edit_mode) {
1613 m_UpdateItemCheck(itinfo);
1614 m_DisableEditButtons(false);
1618 index = elm_genlist_item_index_get(genListItem);
1620 m->hMusicController->PlayIndexSong(--index);
1621 m_UpdateCurrentSongInfo();
1625 bool CPlaybackView::Create(void *data)
1630 _CHECK(m = new SPlaybackView)
1631 _CHECK(m->mgr = CViewMgr::GetInstance())
1632 _CHECK(m->eoWin = m->mgr->Window())
1633 _CHECK(m->hMusicController = CMusicController::GetInstance())
1634 _CHECK(m->eoBase = CCommonUI::AddBase(m->eoWin, MUSIC_PLAYBACK_VIEW))
1635 _CHECK(CBaseView::Create(data))
1636 _CHECK(m->hMusicController->AddListener(this))
1639 m->press_status = PRESS_SHORT;
1642 evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1644 m_AddControlButtons();
1645 m_AddEditPlaylistButtons();
1646 m_AddCurrentSonginfo();
1649 m->pHandleVolume->Create(m->eoBase);
1650 m_UpdatePlaymodeFocusSequence();
1652 Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1655 _CHECK_FAIL{ m->hMusicController->RemoveListener(this); }
1656 _CHECK_FAIL{ CBaseView::Destroy(); }
1657 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1658 _CHECK_FAIL{ /* CMusicController::GetInstance())*/ }
1659 _CHECK_FAIL{ /* mgr->Window() */ }
1660 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1661 _CHECK_FAIL{ delete m; m = NULL; }
1662 }_CREATE_END_AND_CATCH{ return false; }
1668 void CPlaybackView::Destroy(void)
1672 Disconnect(m->eoBase);
1673 m->hMusicController->RemoveListener(this);
1675 m_DestroyErrorPopup();
1677 m_RemoveTimer(TIMER_SLIDER);
1678 m_RemoveTimer(TIMER_WAIT);
1679 m_RemoveTimer(TIMER_LONGPRESS);
1680 m_DestroySettingsPopup();
1682 m->pHandleVolume->Destroy();
1683 CBaseView::Destroy();
1684 evas_object_del(m->eoBase);
1692 Evas_Object* CPlaybackView::Base(void)
1700 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1702 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1704 if (eina_list_count(m->elInfo) == 0)
1707 elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1708 m_DestroySettingsPopup();
1709 m_CreateSettingsPopup();
1713 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1715 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1717 switch (m->hMusicController->ShuffleState()) {
1718 case SHUFFLE_STATUS_OFF:
1719 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_ON);
1720 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1724 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_OFF);
1725 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1731 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1733 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1735 switch (m->hMusicController->RepeatState()) {
1736 case REPEAT_STATUS_NONE:
1737 m->hMusicController->SetRepeatState(REPEAT_STATUS_ALL);
1738 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1741 case REPEAT_STATUS_ALL:
1742 m->hMusicController->SetRepeatState(REPEAT_STATUS_ONE);
1743 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1747 m->hMusicController->SetRepeatState(REPEAT_STATUS_NONE);
1748 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1754 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1756 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1758 switch (m->hMusicController->PlayState()) {
1759 case PLAY_STATUS_PAUSE:
1761 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1764 case PLAY_STATUS_PLAY:
1765 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1770 if (m->hMusicController)
1771 m->hMusicController->Start();
1772 m_UpdateCurrentSongInfo();
1778 void CPlaybackView::t_OnShow(void)
1784 m_UpdateCurrentSongInfo();
1787 elm_genlist_item_show(m->cs_itinfo->item,
1788 ELM_GENLIST_ITEM_SCROLLTO_IN);
1789 elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
1792 state = m->hMusicController->PlayState();
1793 if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
1796 m->hMusicController->Start();
1797 m_UpdateCurrentSongInfo();
1800 evas_object_show(m->eoBase);
1804 void CPlaybackView::t_OnUpdate(void *data)
1808 SParcel *parcel = (SParcel *)data;
1810 char *keyEvent = NULL;
1813 updateType = E_PLAYLIST_UPDATE;
1815 updateType = parcel->updateType;
1816 keyEvent = (char *)parcel->keyEvent;
1819 switch (updateType) {
1820 case E_PLAYLIST_UPDATE:
1823 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
1824 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
1825 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
1826 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
1827 m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
1828 m_FromEditToPlaybackMode();
1832 m_HandleKeyPress(keyEvent);
1836 m_HandleKeyUnpress(keyEvent);
1845 void CPlaybackView::t_OnHide(void)
1849 evas_object_hide(m->eoBase);
1853 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
1857 m_HandleKeyPress(ev->keyname);
1860 case EO_ERROR_POPUP_BUTTON:
1861 if (!strcmp(ev->keyname, KEY_BACK) ||
1862 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1863 m_DestroyErrorPopup();
1864 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1870 Elm_Object_Item *it = NULL;
1871 SContentInfo *ctxtinfo = NULL;
1872 SItemInfo *itinfo = NULL;
1874 if (strcmp(ev->keyname, KEY_MENU) &&
1875 strcmp(ev->keyname, KEY_MENU_REMOTE))
1878 it = elm_object_focused_item_get(obj);
1880 _ERR(" unable to get focused item ");
1883 m->focused_item = it;
1890 ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
1894 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
1900 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY &&
1901 itinfo == m->cs_itinfo)
1902 ctxtinfo->status = PLAY_STATUS_PLAY;
1904 ctxtinfo->status = PLAY_STATUS_PAUSE;
1906 ctxtinfo->cbdata = m;
1907 ctxtinfo->update = sm_CbCtxtUpdate;
1908 ctxtinfo->close = sm_CbCtxtClose;
1909 ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
1910 ctxtinfo->context = itinfo->sinfo;
1912 m->ctxtinfo = ctxtinfo;
1915 memset(&parcel, 0, sizeof(SParcel));
1916 parcel.ctxtInfo = ctxtinfo;
1917 if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
1918 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
1922 if (!strcmp(ev->keyname, KEY_BACK) ||
1923 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1924 _ERR("eoCtxPopup BACK key pressed ");
1925 m_DestroySettingsPopup();
1926 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1929 else if (!strcmp(ev->keyname, KEY_EXIT)) {
1930 _ERR("eoCtxPopup EXIT key pressed ");
1931 m_DestroySettingsPopup();
1932 m_RemoveTimer(TIMER_SLIDER);
1933 m->hMusicController->Stop();
1944 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
1948 m_HandleKeyUnpress(ev->keyname);
1957 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
1960 case EO_ERROR_POPUP_BUTTON:
1961 m_DestroyErrorPopup();
1962 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1966 m_DisableCheckAll(m->elInfo);
1967 m_DisableEditButtons(true);
1968 m_FromEditToPlaybackMode();
1972 m_DisableCheckAll(m->elInfo);
1973 m_DisableEditButtons(true);
1974 elm_genlist_realized_items_update(m->eoPlaylist);
1975 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1979 m_DeleteSelectedItems();
1982 case EO_BTN_SETTINGS:
1983 t_OnClickedSettings(obj);
1986 case EO_BTN_SHUFFLE:
1987 t_OnClickedShuffle(obj);
1991 t_OnClickedRepeat(obj);
1995 t_OnClickedPlay(obj);
2004 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
2011 case EO_BTN_FORWARD:
2015 case EO_BTN_SETTINGS:
2016 case EO_BTN_SHUFFLE:
2017 if (!elm_object_focus_get(obj))
2018 elm_object_focus_set(obj, EINA_TRUE);
2023 Elm_Object_Item *item;
2025 item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
2026 ev->cur.canvas.y, NULL);
2030 if (!elm_object_item_focus_get(item))
2031 elm_object_item_focus_set(item, EINA_TRUE);
2041 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2044 case EO_BTN_FORWARD:
2046 m_HandleOnPressed(obj);
2055 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2058 case EO_BTN_FORWARD:
2060 m_HandleOnUnpressed(obj);
2069 void CPlaybackView::OnChanged(int id, Evas_Object *obj)
2074 char *timestr = NULL;
2077 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2079 ecore_timer_freeze(m->etSlider);
2082 value = elm_slider_value_get(obj);
2083 m->hMusicController->SetPosition(value);
2084 timestr = CCommonUI::TimeStrFromMilSeconds(value);
2086 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
2091 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2093 ecore_timer_thaw(m->etSlider);
2104 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2108 elm_object_item_signal_callback_add(item,
2109 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2110 sm_CbGenlistItemCheckClicked, this);
2119 void CPlaybackView::OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2123 elm_object_item_signal_callback_del(item,
2124 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2125 sm_CbGenlistItemCheckClicked);
2134 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2138 m_HandleGenlistItemActivated(obj, item);
2147 void CPlaybackView::OnComplete(void)
2149 m_UpdateCurrentSongInfo();
2153 void CPlaybackView::OnError(void)
2155 m_CreateErrorPopup();
2159 void CPlaybackView::OnUsbConnected(void)
2164 void CPlaybackView::OnUpdateContent(void)