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.
20 #include <AppCommon.h>
22 #include "song_info.h"
23 #include "album_info.h"
24 #include "music-controller.h"
25 #include "volume-control.h"
27 #include "common-ui.h"
28 #include "playback-view.h"
29 #include "context-view.h"
30 #include "HandleVolume.h"
31 #include "PlaySettingCtxPopup.h"
35 #define TOTAL_CONTROL_BTNS 6
36 #define TOTAL_EDIT_BTNS 3
37 #define S_INTERVAL 1 /* seconds */
38 #define LP_INTERVAL 0.5 /* seconds */
39 #define WAIT_INTERVAL 0.5 /* seconds */
40 #define SLIDER_STEP 5000 /* milli seconds */
41 #define LP_CHANGE 10000 /* milli seconds */
42 #define S_INCREMENT 1000 /* milli seconds */
46 struct SSliderWidget {
47 Evas_Object *eoSlider;
50 Ecore_Timer *etSlider;
54 CMusicController controller;
65 Eina_Bool CSliderWidget::sm_CbUpdateSlider(void *dt)
67 CSliderWidget *root = (CSliderWidget*)dt;
68 Eina_Bool ret = ECORE_CALLBACK_CANCEL;
71 ret = root->m_OnUpdateSlider();
77 Eina_Bool CSliderWidget::m_OnUpdateSlider(void)
83 if (!m->controller.GetPosition(&value)) {
85 return ECORE_CALLBACK_CANCEL;
90 duration = m->pSongInfo->Duration();
92 value = value + S_INCREMENT;
93 if (value > duration) {
95 return ECORE_CALLBACK_CANCEL;
98 elm_slider_value_set(m->eoSlider, value);
99 timestr = CCommonUI::TimeStrFromMilSeconds(value);
101 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
106 return ECORE_CALLBACK_RENEW;
110 bool CSliderWidget::m_AddSlider(void)
112 Evas_Object *eoSlider = NULL;
114 eoSlider = elm_slider_add(m->eoBase);
118 elm_slider_indicator_show_set(eoSlider, EINA_FALSE);
119 elm_slider_indicator_show_on_focus_set(eoSlider, EINA_FALSE);
120 elm_object_style_set(eoSlider, MUSIC_STYLE_SLIDER);
121 elm_slider_horizontal_set(eoSlider, EINA_TRUE);
122 elm_object_part_content_set(m->eoBase, MUSIC_PART_PROGRESSBAR, eoSlider);
124 Connect(eoSlider, TYPE_CHANGED | TYPE_MOUSE_MOVE);
126 evas_object_show(eoSlider);
127 m->eoSlider = eoSlider;
133 void CSliderWidget::m_RemoveTimer(void)
136 ecore_timer_del(m->etSlider);
142 void CSliderWidget::m_UpdateSongInfo(void)
144 CSongInfo *sinfo = NULL;
147 if (!m->controller.GetCurrentSongIndex(&index)) {
148 _ERR(" music get current song index failed ");
152 if (!m->controller.GetSonginfoFromIndex(index, &sinfo)) {
153 _ERR(" music get songinfo failed ");
156 m->pSongInfo = sinfo;
160 bool CSliderWidget::Create(Evas_Object *eoBase)
165 _CHECK(m = new SSliderWidget)
166 _COMMAND{ m->eoBase = eoBase; }
167 _CHECK(m->controller.Create())
168 _CHECK(m->controller.AddListener(this))
169 _CHECK(m_AddSlider())
172 _CHECK_FAIL{ m->controller.RemoveListener(this); }
173 _CHECK_FAIL{ m->controller.Destroy(); }
174 _CHECK_FAIL{ delete m; m = NULL; }
175 } _CREATE_END_AND_CATCH{ return false; }
181 void CSliderWidget::Destroy(void)
185 m->controller.RemoveListener(this);
193 Evas_Object* CSliderWidget::Base(void)
201 void CSliderWidget::Init(void)
203 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
204 elm_slider_value_set(m->eoSlider, 0);
208 void CSliderWidget::OnComplete(void)
213 void CSliderWidget::OnStartPlayback(void)
216 char *timestr = NULL;
219 elm_slider_value_set(m->eoSlider, 0);
220 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
222 elm_object_disabled_set(m->eoSlider, EINA_FALSE);
225 duration = m->pSongInfo->Duration();
228 m->etSlider = ecore_timer_add(S_INTERVAL, sm_CbUpdateSlider, this);
230 elm_slider_min_max_set(m->eoSlider, 0, duration);
231 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
233 elm_object_part_text_set(m->eoBase,
234 MUSIC_PART_FULLTIME, timestr);
238 step = (double)SLIDER_STEP / (double)duration;
239 elm_slider_step_set(m->eoSlider, step);
243 void CSliderWidget::OnStopPlayback(void)
245 elm_slider_value_set(m->eoSlider, 0);
246 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
248 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
253 void CSliderWidget::OnPausePlayback(void)
256 ecore_timer_freeze(m->etSlider);
260 void CSliderWidget::OnResumePlayback(void)
263 ecore_timer_thaw(m->etSlider);
267 void CSliderWidget::OnPosition(int milsec)
269 elm_slider_value_set(m->eoSlider, milsec);
273 void CSliderWidget::OnChanged(int id, Evas_Object *obj)
275 char *timestr = NULL;
278 if (m->controller.PlayState() == PLAY_STATUS_PLAY) {
280 ecore_timer_freeze(m->etSlider);
283 value = elm_slider_value_get(obj);
284 m->controller.SetPosition(value);
285 timestr = CCommonUI::TimeStrFromMilSeconds(value);
287 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
292 if (m->controller.PlayState() == PLAY_STATUS_PLAY) {
294 ecore_timer_thaw(m->etSlider);
299 void CSliderWidget::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
301 if (!elm_object_focus_get(obj))
302 elm_object_focus_set(obj, EINA_TRUE);
311 Ecore_Timer *etTimer;
314 SCookie(CTimer *timer, int _id) {
324 Eina_Bool CTimer::sm_CbTimer(void *data)
326 STimer::SCookie *cookie = (STimer::SCookie*)data;
329 cookie->root->t_OnTimer(cookie->id);
331 cookie->root->m->elList = eina_list_remove(cookie->root->m->elList, cookie);
339 void CTimer::t_OnTimer(int id)
344 bool CTimer::Create(void)
358 void CTimer::Destroy(void)
367 bool CTimer::SetTimer(int id, int ms)
372 STimer::SCookie *cookie = new STimer::SCookie(this, id);
376 m->elList = eina_list_append(m->elList, cookie);
377 cookie->etTimer = ecore_timer_add(ms, sm_CbTimer, cookie);
382 void CTimer::KillTimer(int id)
392 EO_ERROR_POPUP_BUTTON,
396 EO_DELETE, // TOTAL_EDIT_BTNS
403 EO_BTN_FORWARD, // TOTAL_CONTROL_BTNS
443 Elm_Object_Item *item;
450 struct SPlaybackView {
454 CPlaySettingCtxPopup *eoCtxPopup;
455 Evas_Object *eoErrPopup;
456 Evas_Object *eoPlaylist;
458 Elm_Object_Item *focused_item;
460 Evas_Object *eoBtnControl[TOTAL_CONTROL_BTNS];
461 Evas_Object *eoBtnEdit[TOTAL_EDIT_BTNS];
463 Evas_Object *eoAlbumCover;
464 CSliderWidget *pSliderWidget;
465 Evas_Object *eoPressedObj;
468 Ecore_Timer *etLongPress;
470 CMusicController *pController; //! NOT NULL
473 SItemInfo *cs_itinfo;
474 SContentInfo *ctxtinfo;
475 EPressTypes press_status;
477 CHandleVolume *pHandleVolume;
480 memset(this, 0, sizeof(SPlaybackView));
491 Eina_Bool CPlaybackView::sm_CbLongpressTimer(void *dt)
493 CPlaybackView *root = (CPlaybackView *)dt;
495 root->m_OnLongpressTimer();
497 return ECORE_CALLBACK_RENEW;
501 void CPlaybackView::m_OnLongpressTimer(void)
503 m_HandleOnRepeated();
507 Eina_Bool CPlaybackView::sm_CbWaitTimer(void *dt)
509 CPlaybackView *root = (CPlaybackView *)dt;
511 root->m_OnWaitTimer();
513 return ECORE_CALLBACK_CANCEL;
517 void CPlaybackView::m_OnWaitTimer(void)
519 m->press_status = PRESS_LONG;
520 if (m->pController->PlayState() == PLAY_STATUS_PLAY) {
521 /* Handle long press */
523 m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, this);
526 m->press_status = PRESS_LONG_PAUSE;
533 void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
535 CPlaybackView *root = (CPlaybackView *)dt;
537 root->m_OnCtxtUpdate(type, lid);
541 void CPlaybackView::m_OnCtxtUpdate(EActionType type, int lid)
543 SItemInfo *itinfo = NULL;
544 Elm_Object_Item *focusedItem = NULL;
546 if (!m->ctxtinfo || !m->ctxtinfo->context)
549 itinfo = m_FindItemInfoFromSong(m->elInfo,
550 (CSongInfo *)m->ctxtinfo->context);
552 _ERR(" Unable to find song in the list ");
556 if (type == ACTION_TYPE_DELETE) {
557 itinfo->check_status = true;
558 m_DeleteSelectedItems();
560 if (!m->mgr->PopView()) {
561 _ERR("CViewMgr::PopView failed");
566 memset(&parcel, 0, sizeof(SParcel));
567 parcel.updateType = E_PLAYLIST_UPDATE;
570 focusedItem = m->cs_itinfo->item;
572 else { // ACTION_TYPE_PLAY
573 if (m->ctxtinfo->status == PLAY_STATUS_PLAY)
576 if (itinfo == m->cs_itinfo)
579 m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
582 if (!m->mgr->PopView()) {
583 _ERR("CViewMgr::PopView failed");
587 focusedItem = m->focused_item;
590 if (!CViewMgr::GetInstance()->HideView(MUSIC_BASE_VIEW))
591 _ERR("CViewMgr::HideView failed");
596 elm_genlist_item_show(focusedItem, ELM_GENLIST_ITEM_SCROLLTO_IN);
597 elm_object_item_focus_set(focusedItem, EINA_TRUE);
602 void CPlaybackView::sm_CbCtxtClose(void *dt)
604 CPlaybackView *root = (CPlaybackView *)dt;
606 root->m_OnCtxtClose();
610 void CPlaybackView::m_OnCtxtClose(void)
612 if (!m->mgr->PopView()) {
613 _ERR("CViewMgr::PopView failed");
617 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
621 void CPlaybackView::sm_CbCtxPopupBtnSelected(void* cookie, CContextPopup* instance, const char* text)
623 CPlaybackView *root = (CPlaybackView *)cookie;
625 root->m_CbCtxPopupBtnSelected(instance, text);
629 void CPlaybackView::m_CbCtxPopupBtnSelected(CContextPopup* instance, const char* text)
631 int type = CInfo::PlaybackSettingType();
635 m_FromPlaybackToEditMode();
639 m->pController->Stop();
640 m->pController->EmptyPlaylist();
641 eina_list_free(m->elInfo);
643 elm_genlist_clear(m->eoPlaylist);
644 m_UpdateEmptySongInfo();
653 void CPlaybackView::m_RemoveTimer(int timer_code)
655 ETimers timerCode = (ETimers)timer_code;
660 ecore_timer_del(m->etWait);
665 case TIMER_LONGPRESS:
666 if (m->etLongPress) {
667 ecore_timer_del(m->etLongPress);
668 m->etLongPress = NULL;
673 m->pHandleVolume->RemoveTimer();
677 _ERR(" invalid value ");
683 void CPlaybackView::m_PlaybackPause(void)
685 m->pController->Pause();
689 void CPlaybackView::m_PlaybackResume(void)
691 m->pController->Resume();
695 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
697 SItemInfo *itinfo = NULL;
701 EINA_LIST_FOREACH(list, l, obj) {
702 itinfo = (SItemInfo *)obj;
703 itinfo->edit_mode = flag;
708 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
710 SItemInfo *itinfo = NULL;
714 EINA_LIST_FOREACH(list, l, obj) {
715 itinfo = (SItemInfo *)obj;
716 itinfo->check_status = false;
721 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
723 if (!pItemInfo || !pItemInfo->item)
726 elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
727 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
729 pItemInfo->select_status = true;
733 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
735 if (!pItemInfo || !pItemInfo->item)
738 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
739 MUSIC_PLAYBACK_VIEW);
741 pItemInfo->select_status = false;
745 void CPlaybackView::m_UpdateControlBtns(void)
749 state = m->pController->PlayState();
751 case PLAY_STATUS_INITIAL:
752 // Initial State, Do nothing
755 case PLAY_STATUS_STOP:
757 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
758 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
759 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
762 case PLAY_STATUS_PLAY:
763 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
764 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
765 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
766 MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
769 case PLAY_STATUS_PAUSE:
770 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
771 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
772 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
773 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
777 ASSERT(!"Invalid State");
781 state = m->pController->ShuffleState();
783 case SHUFFLE_STATUS_OFF:
784 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE],
785 MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
788 case SHUFFLE_STATUS_ON:
789 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE],
790 MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
794 ASSERT(!"Invalid State");
798 state = m->pController->RepeatState();
800 case REPEAT_STATUS_NONE:
801 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT],
802 MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
805 case REPEAT_STATUS_ALL:
806 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT],
807 MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
810 case REPEAT_STATUS_ONE:
811 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT],
812 MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
816 ASSERT(!"Invalid State");
822 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
825 char buf[MAX_LENGTH];
827 if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
830 path = m->cs_itinfo->sinfo->ThumbnailPath();
832 elm_image_file_set(m->eoAlbumCover, path, NULL);
834 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
835 MUSIC_IMAGE_DEFAULT_THUMB_450);
836 elm_image_file_set(m->eoAlbumCover, buf, NULL);
841 void CPlaybackView::m_UpdateCurrentSongLabels(void)
843 char buf[MAX_LENGTH];
848 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
851 snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
854 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
858 void CPlaybackView::m_UpdateEmptySongInfo(void)
860 char buf[MAX_LENGTH];
862 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
863 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
864 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
865 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
866 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
867 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
868 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
869 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
870 elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
871 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
873 m->pSliderWidget->Init();
875 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
876 _(NO_PLAYLIST_MESSAGE));
877 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
878 _(NO_PLAYLIST_MESSAGE_SUB));
879 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
880 MUSIC_IMAGE_DEFAULT_THUMB_450);
881 elm_image_file_set(m->eoAlbumCover, buf, NULL);
882 m->pController->SetPlayState(PLAY_STATUS_INITIAL);
886 void CPlaybackView::m_UpdateCtxtView(int playStatus)
888 if (!m->cs_itinfo || !m->ctxtinfo)
891 if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
894 if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
895 m->ctxtinfo->status = (EPlayStatus)playStatus;
898 memset(&parcel, 0, sizeof(SParcel));
899 parcel.updateType = E_SONG_UPDATE;
900 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
905 void CPlaybackView::m_UpdateCurrentSongItem(int index)
907 SItemInfo *pItemInfo = NULL;
910 m_UnselectItem(m->cs_itinfo);
911 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
914 pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
917 m->cs_itinfo = pItemInfo;
918 if (m->pController->PlayState() == PLAY_STATUS_STOP) {
919 elm_genlist_item_bring_in(pItemInfo->item,
920 ELM_GENLIST_ITEM_SCROLLTO_IN);
923 m_SelectItem(pItemInfo);
924 m_UpdateCtxtView(PLAY_STATUS_PLAY);
930 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
932 elm_object_focus_next_object_set(m->eoPlaylist, m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
933 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL], m->eoPlaylist, ELM_FOCUS_RIGHT);
934 elm_object_focus_next_object_set(m->pSliderWidget->Base(), m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_DOWN);
938 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
940 elm_object_focus_next_object_set(m->pSliderWidget->Base(), m->eoPlaylist, ELM_FOCUS_UP);
941 elm_object_focus_next_object_set(m->pSliderWidget->Base(), m->eoBtnControl[BTN_PLAY], ELM_FOCUS_DOWN);
942 switch (m->pController->PlayState()) {
943 case PLAY_STATUS_INITIAL:
947 case PLAY_STATUS_STOP:
948 elm_object_focus_next_object_set(m->eoPlaylist, m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
949 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY], m->eoPlaylist, ELM_FOCUS_RIGHT);
950 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY], m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_LEFT);
951 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT], m->eoBtnControl[BTN_PLAY], ELM_FOCUS_RIGHT);
952 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
955 case PLAY_STATUS_PLAY:
956 case PLAY_STATUS_PAUSE:
957 elm_object_focus_next_object_set(m->eoPlaylist,
958 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
959 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
960 m->eoPlaylist, ELM_FOCUS_RIGHT);
961 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
962 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
966 ASSERT(!"Invalid State");
972 void CPlaybackView::m_UpdateCurrentSongInfo(void)
974 CSongInfo *sinfo = NULL;
977 if (eina_list_count(m->elInfo) == 0) {
978 m_UpdateEmptySongInfo();
982 if (!m->pController->GetCurrentSongIndex(&index)) {
983 _ERR(" music get current song index failed ");
987 if (!m->pController->GetSonginfoFromIndex(index, &sinfo)) {
988 _ERR(" music get songinfo failed ");
993 m_UpdateCurrentSongItem(index);
994 m_UpdateCurrentSongLabels();
995 m_UpdateCurrentSongThumbnail();
996 m_UpdateControlBtns();
997 m_UpdatePlaymodeFocusSequence();
1001 void CPlaybackView::m_DisableEditButtons(bool flag)
1003 /* flag - 1 means disable edit buttons and 0 means enable */
1005 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1007 elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
1008 elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
1010 m_UpdateEditmodeFocusSequence();
1011 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1014 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL], m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
1015 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE], m->eoPlaylist, ELM_FOCUS_RIGHT);
1016 elm_object_focus_next_object_set(m->eoPlaylist, m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
1021 void CPlaybackView::m_CreateErrorPopup(void)
1023 Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
1025 popup = elm_popup_add(m->eoBase);
1029 elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
1030 evas_object_show(popup);
1032 label = elm_label_add(popup);
1034 evas_object_del(popup);
1038 elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
1039 elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
1040 elm_object_content_set(popup, label);
1042 btn = elm_button_add(popup);
1044 evas_object_del(popup);
1048 elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
1049 elm_object_text_set(btn, MUSIC_TEXT_OK);
1050 elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
1052 m->eoErrPopup = popup;
1054 Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
1056 elm_object_focus_set(btn, EINA_TRUE);
1062 void CPlaybackView::m_DestroyErrorPopup(void)
1067 evas_object_del(m->eoErrPopup);
1068 m->eoErrPopup = NULL;
1072 void CPlaybackView::m_CreateSettingsPopup(void)
1074 CContextPopup::SCallback cb;
1076 cb.onSelected = sm_CbCtxPopupBtnSelected;
1078 m->eoCtxPopup = new CPlaySettingCtxPopup;
1079 m->eoCtxPopup->Create(m->eoWin, &cb);
1083 void CPlaybackView::m_DestroySettingsPopup(void)
1088 if (m->eoCtxPopup->FlagCreate())
1089 m->eoCtxPopup->Destroy();
1091 delete m->eoCtxPopup;
1092 m->eoCtxPopup = NULL;
1096 void CPlaybackView::m_FromEditToPlaybackMode(void)
1098 if (m->pController->PlayState() == PLAY_STATUS_STOP) {
1099 elm_genlist_item_bring_in(m->cs_itinfo->item,
1100 ELM_GENLIST_ITEM_SCROLLTO_IN);
1103 m_SelectItem(m->cs_itinfo);
1105 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
1106 MUSIC_PLAYBACK_VIEW);
1107 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1109 m_ChangeEditmodeAll(m->elInfo, false);
1111 elm_genlist_realized_items_update(m->eoPlaylist);
1113 m_UpdatePlaymodeFocusSequence();
1117 void CPlaybackView::m_FromPlaybackToEditMode(void)
1119 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_EDIT_MODE,
1120 MUSIC_PLAYBACK_VIEW);
1122 m_DisableEditButtons(true);
1124 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1126 m_ChangeEditmodeAll(m->elInfo, true);
1128 elm_genlist_realized_items_update(m->eoPlaylist);
1130 m_UpdateEditmodeFocusSequence();
1134 void CPlaybackView::m_HandleOnRepeated(void)
1136 Evas_Object *obj = NULL;
1139 char *timestr = NULL;
1141 if (!m->eoPressedObj)
1144 obj = m->eoPressedObj;
1147 m->pController->GetPosition(&value);
1148 duration = m->cs_itinfo->sinfo->Duration();
1150 if (obj == m->eoBtnControl[BTN_REWIND]) {
1152 m_RemoveTimer(TIMER_LONGPRESS);
1155 value = value - LP_CHANGE;
1160 if (value == duration) {
1161 m->pController->PlayNextSong();
1163 m->press_status = PRESS_LONG_PAUSE;
1164 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE,
1165 MUSIC_PLAYBACK_VIEW);
1167 m_RemoveTimer(TIMER_LONGPRESS);
1171 value = value + LP_CHANGE;
1172 if (value >= duration)
1176 m->pController->SetPosition(value);
1177 timestr = CCommonUI::TimeStrFromMilSeconds(value);
1179 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
1188 void CPlaybackView::m_DeleteSelectedItems(void)
1190 Eina_List *l = NULL, *l_next = NULL;
1191 SItemInfo *pItemInfo = NULL;
1193 bool updateFlag = false;
1196 m_DisableEditButtons(true);
1197 EINA_LIST_FOREACH_SAFE(m->elInfo, l, l_next, obj) {
1198 pItemInfo = (SItemInfo *)obj;
1199 if (pItemInfo->check_status) {
1200 if (m->cs_itinfo == pItemInfo) {
1202 m_UnselectItem(m->cs_itinfo);
1203 m->cs_itinfo = NULL;
1204 m->pController->SetPlayState(PLAY_STATUS_STOP);
1205 m->pController->Stop();
1207 index = elm_genlist_item_index_get(pItemInfo->item);
1208 m->pController->RemoveSong(pItemInfo->sinfo, index);
1210 m->elInfo = eina_list_remove(m->elInfo, pItemInfo);
1211 elm_object_item_del(pItemInfo->item);
1215 if (eina_list_count(m->elInfo) == 0) {
1216 m_UpdateEmptySongInfo();
1217 elm_genlist_realized_items_update(m->eoPlaylist);
1218 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1223 m_UpdateCurrentSongInfo();
1225 elm_genlist_realized_items_update(m->eoPlaylist);
1226 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1230 void CPlaybackView::m_KeyBackPress(void)
1232 if (m->eoCtxPopup) {
1233 m_DestroySettingsPopup();
1234 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1240 if (!CViewMgr::GetInstance()->ShowView(MUSIC_BASE_VIEW))
1241 _ERR("CViewMgr::ShowView failed");
1243 if (CViewMgr::GetInstance()->CheckTop(MUSIC_CONTEXT_VIEW)) {
1244 if (!CViewMgr::GetInstance()->UpdateView(MUSIC_CONTEXT_VIEW, NULL))
1245 _ERR("CViewMgr::UpdateView failed");
1247 if (!CViewMgr::GetInstance()->ShowView(MUSIC_CONTEXT_VIEW))
1248 _ERR("CViewMgr::ShowView failed");
1253 void CPlaybackView::m_KeyExitPress(void)
1255 m->pController->Stop();
1260 void CPlaybackView::m_KeyPlayPress(void)
1264 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1267 state = m->pController->PlayState();
1268 if (state == PLAY_STATUS_PAUSE) {
1270 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1271 MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1273 else if (state != PLAY_STATUS_PLAY) {
1274 m->pController->Start();
1279 void CPlaybackView::m_KeyPausePress(void)
1283 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1286 state = m->pController->PlayState();
1287 if (state == PLAY_STATUS_PLAY) {
1288 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1289 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1295 void CPlaybackView::m_KeyNextPress(void)
1297 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1300 m_HandleOnPressed(m->eoBtnControl[BTN_FORWARD]);
1304 void CPlaybackView::m_KeyPreviousPress(void)
1306 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1309 m_HandleOnPressed(m->eoBtnControl[BTN_REWIND]);
1313 void CPlaybackView::m_KeyNextUnpress(void)
1315 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1318 m_HandleOnUnpressed(m->eoBtnControl[BTN_FORWARD]);
1322 void CPlaybackView::m_KeyPreviousUnpress(void)
1324 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1327 m_HandleOnUnpressed(m->eoBtnControl[BTN_REWIND]);
1331 void CPlaybackView::m_HandleKeyPress(char *keyname)
1333 if (!strcmp(keyname, (char *)KEY_EXIT))
1335 else if (!strcmp(keyname, (char *)KEY_BACK) ||
1336 !strcmp(keyname, (char *)KEY_BACK_REMOTE))
1338 else if (!strcmp(keyname, (char *)KEY_PLAY))
1340 else if (!strcmp(keyname, (char *)KEY_PAUSE))
1342 else if (!strcmp(keyname, (char *)KEY_NEXT))
1344 else if (!strcmp(keyname, (char *)KEY_PREVIOUS))
1345 m_KeyPreviousPress();
1346 else if (!strcmp(keyname, (char *)KEY_VOLUMEUP))
1347 m->pHandleVolume->Up();
1348 else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN))
1349 m->pHandleVolume->Down();
1350 else if (!strcmp(keyname, (char *)KEY_MUTE))
1351 m->pHandleVolume->Mute();
1355 void CPlaybackView::m_HandleKeyUnpress(char *keyname)
1357 if (!strcmp(keyname, KEY_PREVIOUS))
1358 m_KeyPreviousUnpress();
1359 else if (!strcmp(keyname, KEY_NEXT))
1364 void CPlaybackView::m_AddAlbumCover(void)
1366 Evas_Object *eoAlbumCover = NULL;
1368 eoAlbumCover = elm_image_add(m->eoBase);
1372 evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
1374 elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
1376 elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
1378 evas_object_show(eoAlbumCover);
1379 m->eoAlbumCover = eoAlbumCover;
1384 void CPlaybackView::m_AddCurrentSonginfo(void)
1388 m->pSliderWidget = new CSliderWidget;
1389 m->pSliderWidget->Create(m->eoBase);
1393 void CPlaybackView::m_AddEditPlaylistButtons(void)
1395 Evas_Object *box = NULL;
1397 SBtnInfo btninfo[TOTAL_EDIT_BTNS];
1399 btninfo[BTN_CANCEL].txt = MUSIC_TEXT_CANCEL;
1400 btninfo[BTN_CANCEL].type = EO_CANCEL;
1402 btninfo[BTN_DESELECT].txt = MUSIC_TEXT_DESELECT;
1403 btninfo[BTN_DESELECT].type = EO_DESELECT;
1405 btninfo[BTN_DELETE].txt = MUSIC_TEXT_DELETE;
1406 btninfo[BTN_DELETE].type = EO_DELETE;
1408 box = CCommonUI::AddBox(m->eoBase);
1412 elm_box_horizontal_set(box, EINA_TRUE);
1413 elm_box_padding_set(box, MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
1415 for (i = 0; i < TOTAL_EDIT_BTNS; i++) {
1416 m->eoBtnEdit[i] = elm_button_add(m->eoBase);
1417 if (!m->eoBtnEdit[i])
1420 elm_object_style_set(m->eoBtnEdit[i], MUSIC_STYLE_EDIT_BTN);
1421 evas_object_size_hint_weight_set(m->eoBtnEdit[i], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1422 elm_box_pack_end(box, m->eoBtnEdit[i]);
1423 elm_object_text_set(m->eoBtnEdit[i], _(btninfo[i].txt));
1425 Connect(m->eoBtnEdit[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1427 evas_object_show(m->eoBtnEdit[i]);
1429 elm_object_part_content_set(m->eoBase, MUSIC_PART_EDITBTNS, box);
1430 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE, MUSIC_PLAYBACK_VIEW);
1434 void CPlaybackView::m_AddControlButtons(void)
1436 Evas_Object *box = NULL;
1438 SBtnInfo btninfo[TOTAL_CONTROL_BTNS];
1440 btninfo[BTN_SETTINGS].txt = MUSIC_STYLE_BTN_SETTINGS;
1441 btninfo[BTN_SETTINGS].type = EO_BTN_SETTINGS;
1443 btninfo[BTN_SHUFFLE].txt = MUSIC_STYLE_BTN_SHUFFLE;
1444 btninfo[BTN_SHUFFLE].type = EO_BTN_SHUFFLE;
1446 btninfo[BTN_REPEAT].txt = MUSIC_STYLE_BTN_REPEAT;
1447 btninfo[BTN_REPEAT].type = EO_BTN_REPEAT;
1449 btninfo[BTN_REWIND].txt = MUSIC_STYLE_BTN_REWIND;
1450 btninfo[BTN_REWIND].type = EO_BTN_REWIND;
1452 btninfo[BTN_PLAY].txt = MUSIC_STYLE_BTN_PLAY;
1453 btninfo[BTN_PLAY].type = EO_BTN_PLAY;
1455 btninfo[BTN_FORWARD].txt = MUSIC_STYLE_BTN_FORWARD;
1456 btninfo[BTN_FORWARD].type = EO_BTN_FORWARD;
1458 box = elm_box_add(m->eoBase);
1462 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
1463 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
1464 elm_box_horizontal_set(box, EINA_TRUE);
1465 elm_box_padding_set(box,
1466 MUSIC_CONTROL_BTNS_PADDING * elm_config_scale_get(), 0);
1468 for (i = 0; i < TOTAL_CONTROL_BTNS; i++) {
1469 m->eoBtnControl[i] = elm_button_add(m->eoBase);
1470 if (!m->eoBtnControl[i])
1473 elm_object_style_set(m->eoBtnControl[i], btninfo[i].txt);
1474 evas_object_size_hint_weight_set(m->eoBtnControl[i],
1475 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1476 elm_box_pack_end(box, m->eoBtnControl[i]);
1478 if (i == BTN_REWIND || i == BTN_FORWARD) {
1479 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_PRESSED | TYPE_UNPRESSED | TYPE_MOUSE_MOVE);
1482 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1484 evas_object_show(m->eoBtnControl[i]);
1487 elm_object_part_content_set(m->eoBase, MUSIC_PART_CONTROLBTNS, box);
1491 SItemInfo *CPlaybackView::m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo)
1493 Eina_List *l = NULL;
1494 SItemInfo *itinfo = NULL;
1497 EINA_LIST_FOREACH(list, l, obj) {
1498 itinfo = (SItemInfo *)obj;
1499 if (itinfo->sinfo == sinfo)
1507 SItemInfo *CPlaybackView::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
1509 Eina_List *l = NULL;
1510 SItemInfo *itinfo = NULL;
1513 EINA_LIST_FOREACH(list, l, obj) {
1514 itinfo = (SItemInfo *)obj;
1515 if (itinfo->item == item)
1523 void CPlaybackView::m_UpdateItemCheck(SItemInfo *itinfo)
1526 _ERR(" No item info to Update check ");
1530 if (itinfo->check_status) {
1531 elm_object_item_signal_emit(itinfo->item,
1532 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1533 itinfo->check_status = false;
1537 elm_object_item_signal_emit(itinfo->item,
1538 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
1539 itinfo->check_status = true;
1543 class CElmGenlistItemClass {
1545 static char *sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
1547 CSongInfo *sinfo = NULL;
1548 SItemInfo *pItemInfo = (SItemInfo *)data;
1549 char buf[MAX_LENGTH];
1550 char *timestr = NULL;
1554 if (!pItemInfo || !obj)
1557 sinfo = pItemInfo->sinfo;
1559 snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY);
1561 if (!strcmp(part, "elm.text0")) {
1562 index = elm_genlist_item_index_get(pItemInfo->item);
1563 snprintf(buf, sizeof(buf), "%d", index);
1565 else if (!strcmp(part, "elm.text1"))
1566 snprintf(buf, sizeof(buf), "%s", sinfo->Name());
1567 else if (!strcmp(part, "elm.text2"))
1568 snprintf(buf, sizeof(buf), "%s - %s",
1571 else if (!strcmp(part, "elm.text3")) {
1572 duration = sinfo->Duration();
1573 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
1575 snprintf(buf, sizeof(buf), "%s", timestr);
1580 if (strcmp(buf, MUSIC_STR_EMPTY))
1585 static Evas_Object *sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
1587 CSongInfo *sinfo = NULL;
1588 SItemInfo *pItemInfo = (SItemInfo *)data;
1589 Evas_Object *img = NULL;
1591 char buf[MAX_LENGTH];
1593 if (!pItemInfo || !obj)
1596 sinfo = pItemInfo->sinfo;
1598 img = elm_image_add(obj);
1602 elm_image_aspect_fixed_set(img, EINA_FALSE);
1604 if (!strcmp(part, "elm.swallow.icon")) {
1605 path = sinfo->ThumbnailPath();
1607 elm_image_file_set(img, path, "NULL");
1609 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
1610 MUSIC_IMAGE_DEFAULT_THUMB_126);
1611 elm_image_file_set(img, buf, "NULL");
1618 static void sm_CbDel(void *data, Evas_Object *obj)
1625 Elm_Genlist_Item_Class *CPlaybackView::m_GetItemClass(void)
1627 Elm_Genlist_Item_Class *list_item = NULL;
1629 list_item = elm_genlist_item_class_new();
1631 _ERR(" elm_genlist_item_class_new failed ");
1635 list_item->item_style = MUSIC_STYLE_PLAYLIST;
1636 list_item->func.text_get = CElmGenlistItemClass::sm_CbTextGet;
1637 list_item->func.content_get = CElmGenlistItemClass::sm_CbContentGet;
1638 list_item->func.state_get = NULL;
1639 list_item->func.del = CElmGenlistItemClass::sm_CbDel;
1645 void CPlaybackView::m_AddGenlist(void)
1647 Evas_Object *genlist = NULL;
1648 Evas_Object *eoBase = NULL;
1651 genlist = elm_genlist_add(eoBase);
1655 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1656 evas_object_size_hint_weight_set(genlist,
1657 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1658 elm_object_part_content_set(eoBase, MUSIC_PART_PLAYLIST, genlist);
1659 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
1660 elm_genlist_multi_select_set(genlist, EINA_FALSE);
1662 Connect(genlist, EO_PLAYLIST, TYPE_REALIZED | TYPE_MOUSE_MOVE |
1663 TYPE_KEY_DOWN | TYPE_ACTIVATED);
1665 evas_object_show(genlist);
1666 m->eoPlaylist = genlist;
1670 void CPlaybackView::m_AddPlaylist(void)
1672 Elm_Genlist_Item_Class *list_item = NULL;
1675 CSongInfo *sinfo = NULL;
1676 Elm_Object_Item *item = NULL;
1677 SItemInfo *pItemInfo = NULL;
1683 list_item = m_GetItemClass();
1685 evas_object_del(m->eoPlaylist);
1689 if (!m->pController->GetTotalSongs(&ts)) {
1690 _ERR(" music get total songs failed ");
1694 if (!m->pController->GetCurrentSongIndex(&index))
1695 _ERR(" music get current song index failed ");
1697 for (i = 0; i < ts; i++) {
1698 if (!m->pController->GetSonginfoFromIndex(i, &sinfo)) {
1699 _ERR(" music get songinfo failed ");
1702 pItemInfo = (SItemInfo *)calloc(1, sizeof(*pItemInfo));
1705 pItemInfo->sinfo = sinfo;
1706 pItemInfo->edit_mode = false;
1707 pItemInfo->check_status = false;
1708 pItemInfo->select_status = false;
1710 // event handling will be done in OnActivated function
1711 item = elm_genlist_item_append(m->eoPlaylist, list_item,
1712 pItemInfo, NULL, ELM_GENLIST_ITEM_NONE,
1714 pItemInfo->item = item;
1717 pItemInfo->select_status = true;
1718 m->cs_itinfo = pItemInfo;
1720 m->elInfo = eina_list_append(m->elInfo, pItemInfo);
1725 void CPlaybackView::m_RemovePlaylist(void)
1727 if (m->eoPlaylist) {
1728 elm_genlist_clear(m->eoPlaylist);
1729 m->eoPlaylist = NULL;
1733 eina_list_free(m->elInfo);
1739 void CPlaybackView::m_HandleRewindBtnClicked(Evas_Object *obj)
1741 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1742 MUSIC_PLAYBACK_VIEW);
1744 if (m->pController->PlayState() == PLAY_STATUS_STOP)
1747 if (!m->pController->PlayPreviousSong()){
1748 _ERR(" music play previous song failed ");
1754 void CPlaybackView::m_HandleForwardBtnClicked(Evas_Object *obj)
1756 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1757 MUSIC_PLAYBACK_VIEW);
1759 if (m->pController->PlayState() == PLAY_STATUS_STOP)
1762 if (!m->pController->PlayNextSong()) {
1763 _ERR(" music play next song failed ");
1769 void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
1771 m->press_status = PRESS_SHORT;
1772 m->eoPressedObj = obj;
1774 m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, this);
1778 void CPlaybackView::m_HandleOnUnpressed(Evas_Object *obj)
1780 m_RemoveTimer(TIMER_WAIT);
1781 m_RemoveTimer(TIMER_LONGPRESS);
1783 if (m->press_status == PRESS_SHORT) {
1784 /* Handle song change */
1785 if (m->pController->PlayState() == PLAY_STATUS_PLAY)
1788 if (obj == m->eoBtnControl[BTN_FORWARD])
1789 m_HandleForwardBtnClicked(obj);
1791 m_HandleRewindBtnClicked(obj);
1793 if (m->pController->PlayState() != PLAY_STATUS_PLAY)
1796 else if (m->press_status == PRESS_LONG) {
1797 if (m->pController->PlayState() != PLAY_STATUS_PLAY)
1801 m->press_status = PRESS_SHORT;
1805 void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_Item *genListItem)
1808 SItemInfo *itinfo = NULL;
1810 if (!obj || !genListItem)
1813 itinfo = m_FindItemInfoFromItem(m->elInfo, genListItem);
1815 _ERR(" no item info found ");
1819 if (itinfo->edit_mode) {
1820 m_UpdateItemCheck(itinfo);
1821 m_DisableEditButtons(false);
1825 index = elm_genlist_item_index_get(genListItem);
1827 m->pController->PlayIndexSong(--index);
1831 bool CPlaybackView::Create(void *data)
1836 _CHECK(m = new SPlaybackView)
1837 _CHECK(m->mgr = CViewMgr::GetInstance())
1838 _CHECK(m->eoWin = m->mgr->Window())
1839 _CHECK(m->pController = new CMusicController)
1840 _CHECK(m->pController->Create())
1841 _CHECK(m->eoBase = CCommonUI::AddBase(m->eoWin, MUSIC_PLAYBACK_VIEW))
1842 _CHECK(CBaseView::Create(data))
1843 _CHECK(CTimer::Create());
1844 _CHECK(m->pController->AddListener(this))
1847 m->press_status = PRESS_SHORT;
1848 evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1850 m_AddControlButtons();
1851 m_AddEditPlaylistButtons();
1852 m_AddCurrentSonginfo();
1855 m->pHandleVolume = new CHandleVolume;
1856 m->pHandleVolume->Create(m->eoBase);
1857 m_UpdatePlaymodeFocusSequence();
1859 Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1862 _CHECK_FAIL{ m->pController->RemoveListener(this); }
1863 _CHECK_FAIL{ CTimer::Destroy(); }
1864 _CHECK_FAIL{ CBaseView::Destroy(); }
1865 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1866 _CHECK_FAIL{ m->pController->Destroy(); }
1867 _CHECK_FAIL{ delete m->pController; }
1868 _CHECK_FAIL{ /* mgr->Window() */ }
1869 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1870 _CHECK_FAIL{ delete m; m = NULL; }
1871 }_CREATE_END_AND_CATCH{ return false; }
1877 void CPlaybackView::Destroy(void)
1881 Disconnect(m->eoBase);
1882 m->pController->RemoveListener(this);
1884 m_DestroyErrorPopup();
1886 m->pSliderWidget->Destroy();
1888 m_RemoveTimer(TIMER_WAIT);
1889 m_RemoveTimer(TIMER_LONGPRESS);
1890 m_DestroySettingsPopup();
1892 m->pHandleVolume->Destroy();
1893 delete m->pHandleVolume;
1894 CBaseView::Destroy();
1895 evas_object_del(m->eoBase);
1903 Evas_Object* CPlaybackView::Base(void)
1911 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1913 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1915 if (eina_list_count(m->elInfo) == 0)
1918 elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1919 m_DestroySettingsPopup();
1920 m_CreateSettingsPopup();
1924 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1926 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1928 switch (m->pController->ShuffleState()) {
1929 case SHUFFLE_STATUS_OFF:
1930 m->pController->SetShuffleState(SHUFFLE_STATUS_ON);
1931 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1935 m->pController->SetShuffleState(SHUFFLE_STATUS_OFF);
1936 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1942 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1944 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1946 switch (m->pController->RepeatState()) {
1947 case REPEAT_STATUS_NONE:
1948 m->pController->SetRepeatState(REPEAT_STATUS_ALL);
1949 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1952 case REPEAT_STATUS_ALL:
1953 m->pController->SetRepeatState(REPEAT_STATUS_ONE);
1954 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1958 m->pController->SetRepeatState(REPEAT_STATUS_NONE);
1959 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1965 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1967 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1969 switch (m->pController->PlayState()) {
1970 case PLAY_STATUS_PAUSE:
1972 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1975 case PLAY_STATUS_PLAY:
1976 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1982 m->pController->Start();
1988 void CPlaybackView::t_OnShow(void)
1994 m_UpdateCurrentSongInfo();
1996 state = m->pController->PlayState();
1997 if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
2000 m->pController->Start();
2004 elm_genlist_item_show(m->cs_itinfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
2005 elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
2008 evas_object_show(m->eoBase);
2012 void CPlaybackView::t_OnUpdate(void *data)
2016 SParcel *parcel = (SParcel *)data;
2018 char *keyEvent = NULL;
2021 updateType = E_PLAYLIST_UPDATE;
2023 updateType = parcel->updateType;
2024 keyEvent = (char *)parcel->keyEvent;
2027 switch (updateType) {
2028 case E_PLAYLIST_UPDATE:
2031 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
2032 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
2033 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
2034 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
2035 m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
2036 m_FromEditToPlaybackMode();
2040 m_HandleKeyPress(keyEvent);
2044 m_HandleKeyUnpress(keyEvent);
2053 void CPlaybackView::t_OnHide(void)
2057 evas_object_hide(m->eoBase);
2061 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
2065 m_HandleKeyPress(ev->keyname);
2068 case EO_ERROR_POPUP_BUTTON:
2069 if (!strcmp(ev->keyname, KEY_BACK) ||
2070 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
2071 m_DestroyErrorPopup();
2072 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
2078 Elm_Object_Item *it = NULL;
2079 SContentInfo *ctxtinfo = NULL;
2080 SItemInfo *itinfo = NULL;
2083 if (!strcmp(ev->keyname, KEY_MENU) ||
2084 !strcmp(ev->keyname, KEY_MENU_REMOTE)) {
2085 it = elm_object_focused_item_get(obj);
2087 _ERR(" unable to get focused item ");
2090 m->focused_item = it;
2097 ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
2101 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
2107 if (m->pController->PlayState() == PLAY_STATUS_PLAY &&
2108 itinfo == m->cs_itinfo)
2109 ctxtinfo->status = PLAY_STATUS_PLAY;
2111 ctxtinfo->status = PLAY_STATUS_PAUSE;
2113 ctxtinfo->cbdata = this;
2114 ctxtinfo->update = sm_CbCtxtUpdate;
2115 ctxtinfo->close = sm_CbCtxtClose;
2116 ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
2117 ctxtinfo->context = itinfo->sinfo;
2119 m->ctxtinfo = ctxtinfo;
2121 memset(&parcel, 0, sizeof(SParcel));
2122 parcel.ctxtInfo = ctxtinfo;
2123 if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
2124 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
2134 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
2138 m_HandleKeyUnpress(ev->keyname);
2147 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
2150 case EO_ERROR_POPUP_BUTTON:
2151 m_DestroyErrorPopup();
2152 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
2156 m_DisableCheckAll(m->elInfo);
2157 m_DisableEditButtons(true);
2158 m_FromEditToPlaybackMode();
2162 m_DisableCheckAll(m->elInfo);
2163 m_DisableEditButtons(true);
2164 elm_genlist_realized_items_update(m->eoPlaylist);
2165 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
2169 m_DeleteSelectedItems();
2172 case EO_BTN_SETTINGS:
2173 t_OnClickedSettings(obj);
2176 case EO_BTN_SHUFFLE:
2177 t_OnClickedShuffle(obj);
2181 t_OnClickedRepeat(obj);
2185 t_OnClickedPlay(obj);
2194 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
2200 case EO_BTN_FORWARD:
2204 case EO_BTN_SETTINGS:
2205 case EO_BTN_SHUFFLE:
2206 if (!elm_object_focus_get(obj))
2207 elm_object_focus_set(obj, EINA_TRUE);
2212 Elm_Object_Item *item;
2214 item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
2215 ev->cur.canvas.y, NULL);
2219 if (!elm_object_item_focus_get(item))
2220 elm_object_item_focus_set(item, EINA_TRUE);
2230 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2233 case EO_BTN_FORWARD:
2235 m_HandleOnPressed(obj);
2244 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2247 case EO_BTN_FORWARD:
2249 m_HandleOnUnpressed(obj);
2258 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2263 int index = elm_genlist_item_index_get(item);
2264 if ((index & 1) == 1)
2265 elm_object_item_signal_emit(item,
2266 MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW);
2268 elm_object_item_signal_emit(item,
2269 MUSIC_SIGNAL_ODD_ROW, MUSIC_PLAYBACK_VIEW);
2271 SItemInfo *itInfo = m_FindItemInfoFromItem(m->elInfo, item);
2272 if (itInfo->select_status)
2273 elm_object_item_signal_emit(item,
2274 MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2276 elm_object_item_signal_emit(item,
2277 MUSIC_SIGNAL_UNSELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2279 if (itInfo->edit_mode) {
2280 elm_object_item_signal_emit(item,
2281 MUSIC_SIGNAL_EDITMODE_ON, MUSIC_PLAYBACK_VIEW);
2282 if (itInfo->check_status) {
2283 elm_object_item_signal_emit(item,
2284 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
2287 elm_object_item_signal_emit(item,
2288 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
2291 elm_object_item_signal_emit(item,
2292 MUSIC_SIGNAL_EDITMODE_OFF, MUSIC_PLAYBACK_VIEW);
2302 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2306 m_HandleGenlistItemActivated(obj, item);
2315 void CPlaybackView::OnComplete(void)
2317 m_UpdateCurrentSongInfo();
2321 void CPlaybackView::OnError(void)
2323 m_CreateErrorPopup();
2327 void CPlaybackView::OnUsbStatusChanged(SUsbStorageStatus status)
2332 void CPlaybackView::OnUpdateContent(void)
2337 void CPlaybackView::OnStartPlayback(void)
2339 m_UpdateCurrentSongInfo();
2343 void CPlaybackView::OnStopPlayback(void)