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"
23 #include <InputHandler.h>
24 #include "song_info.h"
25 #include "album_info.h"
26 #include "music-controller.h"
27 #include "volume-control.h"
30 #include "common-ui.h"
33 #include "playback-view.h"
34 #include "context-view.h"
35 #include "HandleVolume.h"
36 #include <app-res-defines.h>
37 #include "PlaySettingCtxPopup.h"
41 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
42 #define TITLE_FONT_SIZE 50
43 #define ARTIST_FONT_SIZE 30
44 #define TOTAL_CONTROL_BTNS 6
45 #define TOTAL_EDIT_BTNS 3
46 #define S_INTERVAL 1 /* seconds */
47 #define LP_INTERVAL 0.5 /* seconds */
48 #define WAIT_INTERVAL 0.5 /* seconds */
49 #define SLIDER_STEP 5000 /* milli seconds */
50 #define LP_CHANGE 10000 /* milli seconds */
51 #define S_INCREMENT 1000 /* milli seconds */
57 EO_ERROR_POPUP_BUTTON,
61 EO_DELETE, // TOTAL_EDIT_BTNS
68 EO_BTN_FORWARD, // TOTAL_CONTROL_BTNS
79 Elm_Object_Item *item;
86 struct SPlaybackView {
90 CPlaySettingCtxPopup *eoCtxPopup;
91 Evas_Object *eoErrPopup;
92 Evas_Object *eoPlaylist;
94 Elm_Object_Item *focused_item;
96 Evas_Object *eoBtnControl[TOTAL_CONTROL_BTNS];
97 Evas_Object *eoBtnEdit[TOTAL_EDIT_BTNS];
99 Evas_Object *eoAlbumCover;
100 Evas_Object *eoSlider;
101 Evas_Object *eoPressedObj;
104 Ecore_Timer *etSlider;
105 Ecore_Timer *etLongPress;
107 CMusicController *hMusicController; //! NOT NULL
110 SItemInfo *cs_itinfo;
111 SContentInfo *ctxtinfo;
114 CPlaybackView *parent;
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 SPlaybackView *m = (SPlaybackView *)dt;
206 m->parent->m_HandleOnRepeated();
208 return ECORE_CALLBACK_RENEW;
212 Eina_Bool CPlaybackView::sm_CbWaitTimer(void *dt)
214 SPlaybackView *m = (SPlaybackView *)dt;
216 m->press_status = PRESS_LONG;
217 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
218 /* Handle long press */
219 m->parent->m_PlaybackPause();
220 m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, m);
223 m->press_status = PRESS_LONG_PAUSE;
227 return ECORE_CALLBACK_CANCEL;
231 void CPlaybackView::sm_CbItemSelect(void *data, Evas_Object *obj, void *event_info)
236 void CPlaybackView::sm_CbGenlistItemCheckClicked(void *data, Elm_Object_Item *it, const char *emission, const char *source)
238 CPlaybackView *root = (CPlaybackView*)data;
240 root->m_OnGenlistItemCheckClicked(it, emission, source);
244 void CPlaybackView::m_OnGenlistItemCheckClicked(Elm_Object_Item *it, const char *emission, const char *source)
246 SItemInfo *itinfo = NULL;
248 if (!it || !emission)
251 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
253 _ERR(" no item info found ");
257 if (itinfo->edit_mode) {
258 m_UpdateItemCheck(itinfo);
259 m_DisableEditButtons(false);
264 void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
266 SPlaybackView *m = (SPlaybackView *)dt;
267 SItemInfo *itinfo = NULL;
272 if (!m->ctxtinfo || !m->ctxtinfo->context)
275 itinfo = m->parent->m_FindItemInfoFromSong(m->elInfo,
276 (CSongInfo *)m->ctxtinfo->context);
278 _ERR(" Unable to find song in the list ");
282 if (type == ACTION_TYPE_DELETE) {
283 itinfo->check_status = true;
284 m->parent->m_DeleteSelectedItems();
286 else if (type == ACTION_TYPE_PLAY) {
287 if (m->ctxtinfo->status == PLAY_STATUS_PLAY)
288 m->parent->m_KeyPausePress();
290 if (itinfo == m->cs_itinfo)
291 m->parent->m_KeyPlayPress();
293 m->parent->m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
297 _ERR(" Wrong ctxt add type in plaback view ");
301 if (!m->mgr->PopView()) {
302 _ERR("CViewMgr::PopView failed");
306 if (!m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL)) {
307 _ERR("CViewMgr::PushView failed");
311 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
315 void CPlaybackView::sm_CbCtxtClose(void *dt)
317 SPlaybackView *m = (SPlaybackView *)dt;
322 if (!m->mgr->PopView()) {
323 _ERR("CViewMgr::PopView failed");
327 if (!m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL)) {
328 _ERR("CViewMgr::PushView failed");
332 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
336 void CPlaybackView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text)
338 CPlaybackView *root = (CPlaybackView *)cookie;
340 root->m_CbCtxPopupBtnSelected(instance, text);
344 void CPlaybackView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text)
346 int type = CInfo::PlaybackSettingType();
350 m_FromPlaybackToEditMode();
354 m->hMusicController->Stop();
355 m->hMusicController->EmptyPlaylist();
356 eina_list_free(m->elInfo);
358 elm_genlist_clear(m->eoPlaylist);
359 m_UpdateEmptySongInfo();
368 void CPlaybackView::m_RemoveTimer(int timer_code)
370 ETimers timerCode = (ETimers)timer_code;
375 ecore_timer_del(m->etSlider);
382 ecore_timer_del(m->etWait);
387 case TIMER_LONGPRESS:
388 if (m->etLongPress) {
389 ecore_timer_del(m->etLongPress);
390 m->etLongPress = NULL;
395 m->pHandleVolume->RemoveTimer();
399 _ERR(" invalid value ");
405 void CPlaybackView::m_PlaybackPause(void)
407 m->hMusicController->Pause();
410 ecore_timer_freeze(m->etSlider);
414 void CPlaybackView::m_PlaybackResume(void)
416 m->hMusicController->Resume();
419 ecore_timer_thaw(m->etSlider);
423 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
425 SItemInfo *itinfo = NULL;
429 EINA_LIST_FOREACH(list, l, obj) {
430 itinfo = (SItemInfo *)obj;
431 itinfo->edit_mode = flag;
436 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
438 SItemInfo *itinfo = NULL;
442 EINA_LIST_FOREACH(list, l, obj) {
443 itinfo = (SItemInfo *)obj;
444 itinfo->check_status = false;
449 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
451 if (!pItemInfo || !pItemInfo->item)
454 elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
455 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
457 pItemInfo->select_status = true;
461 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
463 if (!pItemInfo || !pItemInfo->item)
466 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
467 MUSIC_PLAYBACK_VIEW);
469 pItemInfo->select_status = false;
473 void CPlaybackView::m_UpdateControlBtns(void)
477 state = m->hMusicController->PlayState();
478 if (state != PLAY_STATUS_STOP) {
479 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
480 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
484 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
485 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
486 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
489 if (state == PLAY_STATUS_PLAY) {
490 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
493 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
496 state = m->hMusicController->ShuffleState();
497 if (state == SHUFFLE_STATUS_OFF) {
498 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
501 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
504 state = m->hMusicController->RepeatState();
505 if (state == REPEAT_STATUS_NONE) {
506 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
508 else if (state == REPEAT_STATUS_ALL) {
509 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
512 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
517 void CPlaybackView::m_UpdateCurrentSongProgressbar(void)
520 char *timestr = NULL;
527 elm_slider_value_set(m->eoSlider, 0);
528 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
530 state = m->hMusicController->PlayState();
532 if (state == PLAY_STATUS_STOP) {
533 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
534 m_RemoveTimer(TIMER_SLIDER);
538 elm_object_disabled_set(m->eoSlider, EINA_FALSE);
540 duration = m->csinfo->Duration();
542 m_RemoveTimer(TIMER_SLIDER);
543 m->etSlider = ecore_timer_add(S_INTERVAL,
544 sm_CbUpdateSlider, m);
546 elm_slider_min_max_set(m->eoSlider, 0, duration);
547 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
549 elm_object_part_text_set(m->eoBase,
550 MUSIC_PART_FULLTIME, timestr);
554 step = (double)SLIDER_STEP / (double)duration;
555 elm_slider_step_set(m->eoSlider, step);
560 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
563 char buf[MAX_LENGTH];
565 if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
568 path = m->cs_itinfo->sinfo->ThumbnailPath();
570 elm_image_file_set(m->eoAlbumCover, path, NULL);
572 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
573 MUSIC_IMAGE_DEFAULT_THUMB_450);
574 elm_image_file_set(m->eoAlbumCover, buf, NULL);
579 void CPlaybackView::m_UpdateCurrentSongLabels(void)
581 char buf[MAX_LENGTH];
586 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
589 snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
592 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
596 void CPlaybackView::m_UpdateEmptySongInfo(void)
598 char buf[MAX_LENGTH];
600 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
601 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
602 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
603 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
604 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
605 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
606 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
607 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
608 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
609 elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
610 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
611 elm_slider_value_set(m->eoSlider, 0);
612 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
613 _(NO_PLAYLIST_MESSAGE));
614 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
615 _(NO_PLAYLIST_MESSAGE_SUB));
616 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
617 MUSIC_IMAGE_DEFAULT_THUMB_450);
618 elm_image_file_set(m->eoAlbumCover, buf, NULL);
619 m->hMusicController->SetPlayState(PLAY_STATUS_INITIAL);
623 void CPlaybackView::m_UpdateCtxtView(int playStatus)
625 if (!m->cs_itinfo || !m->ctxtinfo)
628 if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
631 if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
632 m->ctxtinfo->status = (EPlayStatus)playStatus;
635 parcel.ctxtInfo = NULL;
636 parcel.updateType = E_SONG_UPDATE;
637 parcel.layoutId = NULL;
638 parcel.keyEvent = NULL;
639 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
644 void CPlaybackView::m_UpdateCurrentSongItem(int index)
646 SItemInfo *pItemInfo = NULL;
649 m_UnselectItem(m->cs_itinfo);
650 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
653 pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
656 m->cs_itinfo = pItemInfo;
657 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
658 elm_genlist_item_bring_in(pItemInfo->item,
659 ELM_GENLIST_ITEM_SCROLLTO_IN);
662 m_SelectItem(pItemInfo);
663 m_UpdateCtxtView(PLAY_STATUS_PLAY);
669 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
671 elm_object_focus_next_object_set(m->eoPlaylist,
672 m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
673 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
674 m->eoPlaylist, ELM_FOCUS_RIGHT);
675 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnEdit[BTN_CANCEL],
680 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
682 elm_object_focus_next_object_set(m->eoSlider, m->eoPlaylist,
684 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnControl[BTN_PLAY],
686 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
687 elm_object_focus_next_object_set(m->eoPlaylist,
688 m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
689 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
690 m->eoPlaylist, ELM_FOCUS_RIGHT);
693 elm_object_focus_next_object_set(m->eoPlaylist,
694 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
695 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
696 m->eoPlaylist, ELM_FOCUS_RIGHT);
697 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
698 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
703 void CPlaybackView::m_UpdateCurrentSongInfo(void)
705 CSongInfo *sinfo = NULL;
708 if (eina_list_count(m->elInfo) == 0) {
709 m_UpdateEmptySongInfo();
713 if (!m->hMusicController->GetCurrentSongIndex(&index)) {
714 _ERR(" music get current song index failed ");
718 if (!m->hMusicController->GetSonginfoFromIndex(index, &sinfo)) {
719 _ERR(" music get songinfo failed ");
724 m_UpdateCurrentSongItem(index);
725 m_UpdateCurrentSongLabels();
726 m_UpdateCurrentSongThumbnail();
727 m_UpdateCurrentSongProgressbar();
728 m_UpdateControlBtns();
729 m_UpdatePlaymodeFocusSequence();
733 void CPlaybackView::m_DisableEditButtons(bool flag)
735 /* flag - 1 means disable edit buttons and 0 means enable */
737 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
739 elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
740 elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
742 m_UpdateEditmodeFocusSequence();
743 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
746 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
747 m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
748 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE],
749 m->eoPlaylist, ELM_FOCUS_RIGHT);
750 elm_object_focus_next_object_set(m->eoPlaylist,
751 m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
756 void CPlaybackView::m_CreateErrorPopup(void)
758 Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
760 popup = elm_popup_add(m->eoBase);
764 elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
765 evas_object_show(popup);
767 label = elm_label_add(popup);
769 evas_object_del(popup);
773 elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
774 elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
775 elm_object_content_set(popup, label);
777 btn = elm_button_add(popup);
779 evas_object_del(popup);
783 elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
784 elm_object_text_set(btn, MUSIC_TEXT_OK);
785 elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
787 m->eoErrPopup = popup;
789 Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
791 elm_object_focus_set(btn, EINA_TRUE);
797 void CPlaybackView::m_DestroyErrorPopup(void)
802 evas_object_del(m->eoErrPopup);
803 m->eoErrPopup = NULL;
807 void CPlaybackView::m_CreateSettingsPopup(void)
809 CPlaySettingCtxPopup *eoCtxPopup = new CPlaySettingCtxPopup;
810 CCtxPopup::SCallback cb;
812 cb.onSelected = sm_CbCtxPopupBtnSelected;
814 eoCtxPopup->Create(m->eoWin, &cb);
816 m->eoCtxPopup = eoCtxPopup;
820 void CPlaybackView::m_DestroySettingsPopup(void)
825 if (m->eoCtxPopup->FlagCreate())
826 m->eoCtxPopup->Destroy();
828 delete m->eoCtxPopup;
829 m->eoCtxPopup = NULL;
833 void CPlaybackView::m_FromEditToPlaybackMode(void)
835 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
836 elm_genlist_item_bring_in(m->cs_itinfo->item,
837 ELM_GENLIST_ITEM_SCROLLTO_IN);
840 m_SelectItem(m->cs_itinfo);
842 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
843 MUSIC_PLAYBACK_VIEW);
844 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
846 m_ChangeEditmodeAll(m->elInfo, false);
848 elm_genlist_realized_items_update(m->eoPlaylist);
850 m_UpdatePlaymodeFocusSequence();
854 void CPlaybackView::m_FromPlaybackToEditMode(void)
856 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_EDIT_MODE,
857 MUSIC_PLAYBACK_VIEW);
859 m_DisableEditButtons(true);
861 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
863 m_ChangeEditmodeAll(m->elInfo, true);
865 elm_genlist_realized_items_update(m->eoPlaylist);
867 m_UpdateEditmodeFocusSequence();
871 void CPlaybackView::m_HandleOnRepeated(void)
873 Evas_Object *obj = NULL;
876 char *timestr = NULL;
878 if (!m->eoPressedObj)
881 obj = m->eoPressedObj;
883 value = elm_slider_value_get(m->eoSlider);
884 duration = m->cs_itinfo->sinfo->Duration();
886 if (obj == m->eoBtnControl[BTN_REWIND]) {
888 m_RemoveTimer(TIMER_LONGPRESS);
891 value = value - LP_CHANGE;
896 if (value == duration) {
897 if (m->hMusicController->PlayNextSong())
898 m_UpdateCurrentSongInfo();
900 _ERR(" music play next song failed ");
902 m->press_status = PRESS_LONG_PAUSE;
903 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE,
904 MUSIC_PLAYBACK_VIEW);
906 m_RemoveTimer(TIMER_LONGPRESS);
910 value = value + LP_CHANGE;
911 if (value >= duration)
915 m->hMusicController->SetPosition(value);
916 elm_slider_value_set(m->eoSlider, value);
917 timestr = CCommonUI::TimeStrFromMilSeconds(value);
919 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
928 void CPlaybackView::m_DeleteSelectedItems(void)
930 Eina_List *l = NULL, *l_next = NULL;
931 SItemInfo *pItemInfo = NULL;
936 m_DisableEditButtons(true);
937 EINA_LIST_FOREACH_SAFE(m->elInfo, l, l_next, obj) {
938 pItemInfo = (SItemInfo *)obj;
939 if (pItemInfo->check_status) {
940 if (m->cs_itinfo == pItemInfo) {
942 m_UnselectItem(m->cs_itinfo);
943 m_RemoveTimer(TIMER_SLIDER);
945 m->hMusicController->SetPlayState(PLAY_STATUS_STOP);
946 m->hMusicController->Stop();
948 index = elm_genlist_item_index_get(pItemInfo->item);
949 m->hMusicController->RemoveSong(pItemInfo->sinfo, index);
951 m->elInfo = eina_list_remove(m->elInfo,
953 elm_object_item_del(pItemInfo->item);
957 if (eina_list_count(m->elInfo) == 0) {
958 m_UpdateEmptySongInfo();
959 elm_genlist_realized_items_update(m->eoPlaylist);
960 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
965 m_UpdateCurrentSongInfo();
967 elm_genlist_realized_items_update(m->eoPlaylist);
968 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
972 void CPlaybackView::m_KeyBackPress(void)
975 m_DestroySettingsPopup();
976 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_FALSE);
977 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
982 m->mgr->PushView(MUSIC_BASE_VIEW, NULL);
986 void CPlaybackView::m_KeyExitPress(void)
988 m_RemoveTimer(TIMER_SLIDER);
989 m->hMusicController->Stop();
994 void CPlaybackView::m_KeyPlayPress(void)
998 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1001 state = m->hMusicController->PlayState();
1002 if (state == PLAY_STATUS_PAUSE) {
1004 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1005 MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1007 else if (state != PLAY_STATUS_PLAY) {
1008 if (m->hMusicController)
1009 m->hMusicController->Start();
1011 m_UpdateCurrentSongInfo();
1016 void CPlaybackView::m_KeyPausePress(void)
1020 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1023 state = m->hMusicController->PlayState();
1024 if (state == PLAY_STATUS_PLAY) {
1025 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1026 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1032 void CPlaybackView::m_KeyNextPress(void)
1034 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1037 m_HandleOnPressed(m->eoBtnControl[BTN_FORWARD]);
1041 void CPlaybackView::m_KeyPreviousPress(void)
1043 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1046 m_HandleOnPressed(m->eoBtnControl[BTN_REWIND]);
1050 void CPlaybackView::m_KeyNextUnpress(void)
1052 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1055 m_HandleOnUnpressed(m->eoBtnControl[BTN_FORWARD]);
1059 void CPlaybackView::m_KeyPreviousUnpress(void)
1061 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1064 m_HandleOnUnpressed(m->eoBtnControl[BTN_REWIND]);
1068 void CPlaybackView::m_HandleKeyPress(char *keyname)
1070 if (!strcmp(keyname, (char *)KEY_EXIT))
1072 else if (!strcmp(keyname, (char *)KEY_BACK) ||
1073 !strcmp(keyname, (char *)KEY_BACK_REMOTE))
1075 else if (!strcmp(keyname, (char *)KEY_PLAY))
1077 else if (!strcmp(keyname, (char *)KEY_PAUSE))
1079 else if (!strcmp(keyname, (char *)KEY_NEXT))
1081 else if (!strcmp(keyname, (char *)KEY_PREVIOUS))
1082 m_KeyPreviousPress();
1083 else if (!strcmp(keyname, (char *)KEY_VOLUMEUP))
1084 m->pHandleVolume->Up();
1085 else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN))
1086 m->pHandleVolume->Down();
1087 else if (!strcmp(keyname, (char *)KEY_MUTE))
1088 m->pHandleVolume->Mute();
1092 void CPlaybackView::m_HandleKeyUnpress(char *keyname)
1094 if (!strcmp(keyname, KEY_PREVIOUS))
1095 m_KeyPreviousUnpress();
1096 else if (!strcmp(keyname, KEY_NEXT))
1101 void CPlaybackView::m_AddSlider(void)
1103 Evas_Object *eoSlider = NULL;
1105 eoSlider = elm_slider_add(m->eoBase);
1109 elm_slider_indicator_show_set(eoSlider, EINA_FALSE);
1110 elm_slider_indicator_show_on_focus_set(eoSlider, EINA_FALSE);
1111 elm_object_style_set(eoSlider, MUSIC_STYLE_SLIDER);
1112 elm_slider_horizontal_set(eoSlider, EINA_TRUE);
1113 elm_object_part_content_set(m->eoBase, MUSIC_PART_PROGRESSBAR, eoSlider);
1115 Connect(eoSlider, EO_SLIDER, TYPE_CHANGED | TYPE_MOUSE_MOVE);
1117 evas_object_show(eoSlider);
1118 m->eoSlider = eoSlider;
1122 void CPlaybackView::m_AddAlbumCover(void)
1124 Evas_Object *eoAlbumCover = NULL;
1126 eoAlbumCover = elm_image_add(m->eoBase);
1130 evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
1132 elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
1134 elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
1136 evas_object_show(eoAlbumCover);
1137 m->eoAlbumCover = eoAlbumCover;
1142 void CPlaybackView::m_AddCurrentSonginfo(void)
1149 void CPlaybackView::m_AddEditPlaylistButtons(void)
1151 Evas_Object *box = NULL;
1153 SBtnInfo btninfo[TOTAL_EDIT_BTNS];
1155 btninfo[BTN_CANCEL].txt = MUSIC_TEXT_CANCEL;
1156 btninfo[BTN_CANCEL].type = EO_CANCEL;
1158 btninfo[BTN_DESELECT].txt = MUSIC_TEXT_DESELECT;
1159 btninfo[BTN_DESELECT].type = EO_DESELECT;
1161 btninfo[BTN_DELETE].txt = MUSIC_TEXT_DELETE;
1162 btninfo[BTN_DELETE].type = EO_DELETE;
1164 box = CCommonUI::AddBox(m->eoBase);
1168 elm_box_horizontal_set(box, EINA_TRUE);
1169 elm_box_padding_set(box,
1170 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
1172 for (i = 0; i < TOTAL_EDIT_BTNS; i++) {
1173 m->eoBtnEdit[i] = elm_button_add(m->eoBase);
1174 if (!m->eoBtnEdit[i])
1177 elm_object_style_set(m->eoBtnEdit[i],
1178 MUSIC_STYLE_EDIT_BTN);
1179 evas_object_size_hint_weight_set(m->eoBtnEdit[i],
1180 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1181 elm_box_pack_end(box, m->eoBtnEdit[i]);
1182 elm_object_text_set(m->eoBtnEdit[i], _(btninfo[i].txt));
1184 Connect(m->eoBtnEdit[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1186 evas_object_show(m->eoBtnEdit[i]);
1188 elm_object_part_content_set(m->eoBase, MUSIC_PART_EDITBTNS, box);
1189 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
1190 MUSIC_PLAYBACK_VIEW);
1194 void CPlaybackView::m_AddControlButtons(void)
1196 Evas_Object *box = NULL;
1198 SBtnInfo btninfo[TOTAL_CONTROL_BTNS];
1200 btninfo[BTN_SETTINGS].txt = MUSIC_STYLE_BTN_SETTINGS;
1201 btninfo[BTN_SETTINGS].type = EO_BTN_SETTINGS;
1203 btninfo[BTN_SHUFFLE].txt = MUSIC_STYLE_BTN_SHUFFLE;
1204 btninfo[BTN_SHUFFLE].type = EO_BTN_SHUFFLE;
1206 btninfo[BTN_REPEAT].txt = MUSIC_STYLE_BTN_REPEAT;
1207 btninfo[BTN_REPEAT].type = EO_BTN_REPEAT;
1209 btninfo[BTN_REWIND].txt = MUSIC_STYLE_BTN_REWIND;
1210 btninfo[BTN_REWIND].type = EO_BTN_REWIND;
1212 btninfo[BTN_PLAY].txt = MUSIC_STYLE_BTN_PLAY;
1213 btninfo[BTN_PLAY].type = EO_BTN_PLAY;
1215 btninfo[BTN_FORWARD].txt = MUSIC_STYLE_BTN_FORWARD;
1216 btninfo[BTN_FORWARD].type = EO_BTN_FORWARD;
1218 box = elm_box_add(m->eoBase);
1222 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
1223 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
1224 elm_box_horizontal_set(box, EINA_TRUE);
1225 elm_box_padding_set(box,
1226 MUSIC_CONTROL_BTNS_PADDING * elm_config_scale_get(), 0);
1228 for (i = 0; i < TOTAL_CONTROL_BTNS; i++) {
1229 m->eoBtnControl[i] = elm_button_add(m->eoBase);
1230 if (!m->eoBtnControl[i])
1233 elm_object_style_set(m->eoBtnControl[i], btninfo[i].txt);
1234 evas_object_size_hint_weight_set(m->eoBtnControl[i],
1235 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1236 elm_box_pack_end(box, m->eoBtnControl[i]);
1238 if (i == BTN_REWIND || i == BTN_FORWARD) {
1239 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_PRESSED | TYPE_UNPRESSED | TYPE_MOUSE_MOVE);
1242 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1244 evas_object_show(m->eoBtnControl[i]);
1247 elm_object_part_content_set(m->eoBase, MUSIC_PART_CONTROLBTNS, box);
1251 SItemInfo *CPlaybackView::m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo)
1253 Eina_List *l = NULL;
1254 SItemInfo *itinfo = NULL;
1257 EINA_LIST_FOREACH(list, l, obj) {
1258 itinfo = (SItemInfo *)obj;
1259 if (itinfo->sinfo == sinfo)
1267 SItemInfo *CPlaybackView::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
1269 Eina_List *l = NULL;
1270 SItemInfo *itinfo = NULL;
1273 EINA_LIST_FOREACH(list, l, obj) {
1274 itinfo = (SItemInfo *)obj;
1275 if (itinfo->item == item)
1283 void CPlaybackView::m_UpdateItemCheck(SItemInfo *itinfo)
1286 _ERR(" No item info to Update check ");
1290 if (itinfo->check_status) {
1291 elm_object_item_signal_emit(itinfo->item,
1292 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1293 itinfo->check_status = false;
1297 elm_object_item_signal_emit(itinfo->item,
1298 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
1299 itinfo->check_status = true;
1303 class CElmGenlistItemClass {
1305 static char *sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
1307 CSongInfo *sinfo = NULL;
1308 SItemInfo *pItemInfo = (SItemInfo *)data;
1309 char buf[MAX_LENGTH];
1310 char *timestr = NULL;
1314 if (!pItemInfo || !obj)
1317 sinfo = pItemInfo->sinfo;
1319 snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY);
1321 if (!strcmp(part, "elm.text0")) {
1322 index = elm_genlist_item_index_get(pItemInfo->item);
1323 snprintf(buf, sizeof(buf), "%d", index);
1324 if ((index & 1) == 1) {
1325 elm_object_item_signal_emit(pItemInfo->item,
1326 MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW);
1329 elm_object_item_signal_emit(pItemInfo->item,
1330 MUSIC_SIGNAL_ODD_ROW, MUSIC_PLAYBACK_VIEW);
1333 else if (!strcmp(part, "elm.text1"))
1334 snprintf(buf, sizeof(buf), "%s", sinfo->Name());
1335 else if (!strcmp(part, "elm.text2"))
1336 snprintf(buf, sizeof(buf), "%s - %s",
1339 else if (!strcmp(part, "elm.text3")) {
1340 duration = sinfo->Duration();
1341 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
1343 snprintf(buf, sizeof(buf), "%s", timestr);
1348 if (strcmp(buf, MUSIC_STR_EMPTY))
1353 static Evas_Object *sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
1355 CSongInfo *sinfo = NULL;
1356 SItemInfo *pItemInfo = (SItemInfo *)data;
1357 Evas_Object *img = NULL;
1359 char buf[MAX_LENGTH];
1361 if (!pItemInfo || !obj)
1364 sinfo = pItemInfo->sinfo;
1366 img = elm_image_add(obj);
1370 elm_image_aspect_fixed_set(img, EINA_FALSE);
1372 if (!strcmp(part, "elm.swallow.icon")) {
1373 path = sinfo->ThumbnailPath();
1375 elm_image_file_set(img, path, "NULL");
1377 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
1378 MUSIC_IMAGE_DEFAULT_THUMB_126);
1379 elm_image_file_set(img, buf, "NULL");
1383 if (pItemInfo->select_status) {
1384 elm_object_item_signal_emit(pItemInfo->item,
1385 MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
1388 elm_object_item_signal_emit(pItemInfo->item,
1389 MUSIC_SIGNAL_UNSELECT_ITEM,
1390 MUSIC_PLAYBACK_VIEW);
1393 if (pItemInfo->edit_mode) {
1394 elm_object_item_signal_emit(pItemInfo->item,
1395 MUSIC_SIGNAL_EDITMODE_ON, MUSIC_PLAYBACK_VIEW);
1396 if (pItemInfo->check_status) {
1397 elm_object_item_signal_emit(pItemInfo->item,
1398 MUSIC_SIGNAL_CHECK_ON,
1399 MUSIC_PLAYBACK_VIEW);
1402 elm_object_item_signal_emit(pItemInfo->item,
1403 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1407 elm_object_item_signal_emit(pItemInfo->item,
1408 MUSIC_SIGNAL_EDITMODE_OFF, MUSIC_PLAYBACK_VIEW);
1414 static void sm_CbDel(void *data, Evas_Object *obj)
1421 Elm_Genlist_Item_Class *CPlaybackView::m_GetItemClass(void)
1423 Elm_Genlist_Item_Class *list_item = NULL;
1425 list_item = elm_genlist_item_class_new();
1427 _ERR(" elm_genlist_item_class_new failed ");
1431 list_item->item_style = MUSIC_STYLE_PLAYLIST;
1432 list_item->func.text_get = CElmGenlistItemClass::sm_CbTextGet;
1433 list_item->func.content_get = CElmGenlistItemClass::sm_CbContentGet;
1434 list_item->func.state_get = NULL;
1435 list_item->func.del = CElmGenlistItemClass::sm_CbDel;
1441 void CPlaybackView::m_AddGenlist(void)
1443 Evas_Object *genlist = NULL;
1444 Evas_Object *eoBase = NULL;
1447 genlist = elm_genlist_add(eoBase);
1451 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1452 evas_object_size_hint_weight_set(genlist,
1453 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1454 elm_object_part_content_set(eoBase, MUSIC_PART_PLAYLIST, genlist);
1455 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
1456 elm_genlist_multi_select_set(genlist, EINA_FALSE);
1458 Connect(genlist, EO_PLAYLIST, TYPE_REALIZED | TYPE_UNREALIZED | TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_ACTIVATED);
1460 evas_object_show(genlist);
1461 m->eoPlaylist = genlist;
1465 void CPlaybackView::m_AddPlaylist(void)
1467 Elm_Genlist_Item_Class *list_item = NULL;
1470 CSongInfo *sinfo = NULL;
1471 Elm_Object_Item *item = NULL;
1472 SItemInfo *pItemInfo = NULL;
1478 list_item = m_GetItemClass();
1480 evas_object_del(m->eoPlaylist);
1484 if (!m->hMusicController->GetTotalSongs(&ts)) {
1485 _ERR(" music get total songs failed ");
1489 if (!m->hMusicController->GetCurrentSongIndex(&index))
1490 _ERR(" music get current song index failed ");
1492 for (i = 0; i < ts; i++) {
1493 if (!m->hMusicController->GetSonginfoFromIndex(i, &sinfo)) {
1494 _ERR(" music get songinfo failed ");
1497 pItemInfo = (SItemInfo *)calloc(1, sizeof(*pItemInfo));
1500 pItemInfo->sinfo = sinfo;
1501 pItemInfo->edit_mode = false;
1502 pItemInfo->check_status = false;
1503 pItemInfo->select_status = false;
1505 item = elm_genlist_item_append(m->eoPlaylist, list_item,
1506 pItemInfo, NULL, ELM_GENLIST_ITEM_NONE,
1507 sm_CbItemSelect, m);
1508 pItemInfo->item = item;
1511 pItemInfo->select_status = true;
1512 m->cs_itinfo = pItemInfo;
1514 m->elInfo = eina_list_append(m->elInfo, pItemInfo);
1519 void CPlaybackView::m_RemovePlaylist(void)
1521 if (m->eoPlaylist) {
1522 elm_genlist_clear(m->eoPlaylist);
1523 m->eoPlaylist = NULL;
1527 eina_list_free(m->elInfo);
1533 void CPlaybackView::m_HandleRewindBtnClicked(Evas_Object *obj)
1535 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1536 MUSIC_PLAYBACK_VIEW);
1538 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1541 if (!m->hMusicController->PlayPreviousSong()){
1542 _ERR(" music play previous song failed ");
1546 m_UpdateCurrentSongInfo();
1550 void CPlaybackView::m_HandleForwardBtnClicked(Evas_Object *obj)
1552 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1553 MUSIC_PLAYBACK_VIEW);
1555 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1558 if (!m->hMusicController->PlayNextSong()) {
1559 _ERR(" music play next song failed ");
1563 m_UpdateCurrentSongInfo();
1567 void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
1569 m->press_status = PRESS_SHORT;
1570 m->eoPressedObj = obj;
1572 m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, m);
1576 void CPlaybackView::m_HandleOnUnpressed(Evas_Object *obj)
1578 m_RemoveTimer(TIMER_WAIT);
1579 m_RemoveTimer(TIMER_LONGPRESS);
1581 if (m->press_status == PRESS_SHORT) {
1582 /* Handle song change */
1583 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY)
1586 if (obj == m->eoBtnControl[BTN_FORWARD])
1587 m_HandleForwardBtnClicked(obj);
1589 m_HandleRewindBtnClicked(obj);
1591 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1594 else if (m->press_status == PRESS_LONG) {
1595 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1599 m->press_status = PRESS_SHORT;
1603 void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_Item *genListItem)
1606 SItemInfo *itinfo = NULL;
1608 if (!obj || !genListItem)
1611 itinfo = m_FindItemInfoFromItem(m->elInfo, genListItem);
1613 _ERR(" no item info found ");
1617 if (itinfo->edit_mode) {
1618 m_UpdateItemCheck(itinfo);
1619 m_DisableEditButtons(false);
1623 index = elm_genlist_item_index_get(genListItem);
1625 m->hMusicController->PlayIndexSong(--index);
1626 m_UpdateCurrentSongInfo();
1630 bool CPlaybackView::Create(void *data)
1635 _CHECK(m = new SPlaybackView)
1636 _CHECK(m->mgr = CViewMgr::GetInstance())
1637 _CHECK(m->eoWin = m->mgr->Window())
1638 _CHECK(m->hMusicController = CMusicController::GetInstance())
1639 _CHECK(m->eoBase = CCommonUI::AddBase(m->eoWin, MUSIC_PLAYBACK_VIEW))
1640 _CHECK(CBaseView::Create(data))
1642 _CHECK_FAIL{ CBaseView::Destroy(); }
1643 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1644 _CHECK_FAIL{ /* CMusicController::GetInstance())*/ }
1645 _CHECK_FAIL{ /* mgr->Window() */ }
1646 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1647 _CHECK_FAIL{ delete m; m = NULL; }
1648 }_CREATE_END_AND_CATCH{ return false; }
1650 m->press_status = PRESS_SHORT;
1653 evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1655 m_AddControlButtons();
1656 m_AddEditPlaylistButtons();
1657 m_AddCurrentSonginfo();
1660 m->pHandleVolume->Create(m->eoBase);
1661 m_UpdatePlaymodeFocusSequence();
1663 Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1665 m->hMusicController->AddListener(this);
1671 void CPlaybackView::Destroy(void)
1675 m->hMusicController->RemoveListener(this);
1677 m_DestroyErrorPopup();
1679 m_RemoveTimer(TIMER_SLIDER);
1680 m_RemoveTimer(TIMER_WAIT);
1681 m_RemoveTimer(TIMER_LONGPRESS);
1682 m_DestroySettingsPopup();
1684 m->pHandleVolume->Destroy();
1685 CBaseView::Destroy();
1686 evas_object_del(m->eoBase);
1694 Evas_Object* CPlaybackView::Base(void)
1702 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1704 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1706 if (eina_list_count(m->elInfo) == 0)
1709 elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1710 m_DestroySettingsPopup();
1711 m_CreateSettingsPopup();
1715 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1717 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1719 switch (m->hMusicController->ShuffleState()) {
1720 case SHUFFLE_STATUS_OFF:
1721 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_ON);
1722 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1726 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_OFF);
1727 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1733 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1735 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1737 switch (m->hMusicController->RepeatState()) {
1738 case REPEAT_STATUS_NONE:
1739 m->hMusicController->SetRepeatState(REPEAT_STATUS_ALL);
1740 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1743 case REPEAT_STATUS_ALL:
1744 m->hMusicController->SetRepeatState(REPEAT_STATUS_ONE);
1745 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1749 m->hMusicController->SetRepeatState(REPEAT_STATUS_NONE);
1750 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1756 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1758 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1760 switch (m->hMusicController->PlayState()) {
1761 case PLAY_STATUS_PAUSE:
1763 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1766 case PLAY_STATUS_PLAY:
1767 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1772 if (m->hMusicController)
1773 m->hMusicController->Start();
1774 m_UpdateCurrentSongInfo();
1780 void CPlaybackView::t_OnShow(void)
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)
1811 SParcel *parcel = (SParcel *)data;
1812 int updateType = parcel->updateType;
1813 char *key = (char *)parcel->keyEvent;
1815 switch (updateType) {
1816 case E_PLAYLIST_UPDATE:
1819 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
1820 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
1821 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
1822 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
1823 m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
1824 m_FromEditToPlaybackMode();
1828 m_HandleKeyPress(key);
1832 m_HandleKeyUnpress(key);
1841 void CPlaybackView::t_OnHide(void)
1845 evas_object_hide(m->eoBase);
1849 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
1853 m_HandleKeyPress(ev->keyname);
1856 case EO_ERROR_POPUP_BUTTON:
1857 if (!strcmp(ev->keyname, KEY_BACK) ||
1858 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1859 m_DestroyErrorPopup();
1860 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1866 Elm_Object_Item *it = NULL;
1867 SContentInfo *ctxtinfo = NULL;
1868 SItemInfo *itinfo = NULL;
1870 if (strcmp(ev->keyname, KEY_MENU) &&
1871 strcmp(ev->keyname, KEY_MENU_REMOTE))
1874 it = elm_object_focused_item_get(obj);
1876 _ERR(" unable to get focused item ");
1879 m->focused_item = it;
1886 ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
1890 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
1896 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY &&
1897 itinfo == m->cs_itinfo)
1898 ctxtinfo->status = PLAY_STATUS_PLAY;
1900 ctxtinfo->status = PLAY_STATUS_PAUSE;
1902 ctxtinfo->cbdata = m;
1903 ctxtinfo->update = sm_CbCtxtUpdate;
1904 ctxtinfo->close = sm_CbCtxtClose;
1905 ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
1906 ctxtinfo->context = itinfo->sinfo;
1908 m->ctxtinfo = ctxtinfo;
1911 parcel.ctxtInfo = ctxtinfo;
1912 if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
1913 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
1917 if (!strcmp(ev->keyname, KEY_BACK) ||
1918 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1919 _ERR("eoCtxPopup BACK key pressed ");
1920 m_DestroySettingsPopup();
1921 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1924 else if (!strcmp(ev->keyname, KEY_EXIT)) {
1925 _ERR("eoCtxPopup EXIT key pressed ");
1926 m_DestroySettingsPopup();
1927 m_RemoveTimer(TIMER_SLIDER);
1928 m->hMusicController->Stop();
1939 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
1943 m_HandleKeyUnpress(ev->keyname);
1952 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
1955 case EO_ERROR_POPUP_BUTTON:
1956 m_DestroyErrorPopup();
1957 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1961 m_DisableCheckAll(m->elInfo);
1962 m_DisableEditButtons(true);
1963 m_FromEditToPlaybackMode();
1967 m_DisableCheckAll(m->elInfo);
1968 m_DisableEditButtons(true);
1969 elm_genlist_realized_items_update(m->eoPlaylist);
1970 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1974 m_DeleteSelectedItems();
1977 case EO_BTN_SETTINGS:
1978 t_OnClickedSettings(obj);
1981 case EO_BTN_SHUFFLE:
1982 t_OnClickedShuffle(obj);
1986 t_OnClickedRepeat(obj);
1990 t_OnClickedPlay(obj);
1999 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
2006 case EO_BTN_FORWARD:
2010 case EO_BTN_SETTINGS:
2011 case EO_BTN_SHUFFLE:
2012 if (!elm_object_focus_get(obj))
2013 elm_object_focus_set(obj, EINA_TRUE);
2018 Elm_Object_Item *item;
2020 item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
2021 ev->cur.canvas.y, NULL);
2025 if (!elm_object_item_focus_get(item))
2026 elm_object_item_focus_set(item, EINA_TRUE);
2036 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2039 case EO_BTN_FORWARD:
2041 m_HandleOnPressed(obj);
2050 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2053 case EO_BTN_FORWARD:
2055 m_HandleOnUnpressed(obj);
2064 void CPlaybackView::OnChanged(int id, Evas_Object *obj)
2069 char *timestr = NULL;
2072 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2074 ecore_timer_freeze(m->etSlider);
2077 value = elm_slider_value_get(obj);
2078 m->hMusicController->SetPosition(value);
2079 timestr = CCommonUI::TimeStrFromMilSeconds(value);
2081 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
2086 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2088 ecore_timer_thaw(m->etSlider);
2099 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2103 elm_object_item_signal_callback_add(item,
2104 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2105 sm_CbGenlistItemCheckClicked, this);
2114 void CPlaybackView::OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2118 elm_object_item_signal_callback_del(item,
2119 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2120 sm_CbGenlistItemCheckClicked);
2129 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2133 m_HandleGenlistItemActivated(obj, item);
2142 void CPlaybackView::t_OnComplete(void)
2144 m_UpdateCurrentSongInfo();
2148 void CPlaybackView::t_OnError(void)
2150 m_CreateErrorPopup();
2154 void CPlaybackView::t_OnUsbConnected(void)
2159 void CPlaybackView::t_OnUpdateContent(void)