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;
273 if (!m->ctxtinfo || !m->ctxtinfo->context)
276 itinfo = m->parent->m_FindItemInfoFromSong(m->elInfo,
277 (CSongInfo *)m->ctxtinfo->context);
279 _ERR(" Unable to find song in the list ");
283 if (type == ACTION_TYPE_DELETE) {
284 itinfo->check_status = true;
285 m->parent->m_DeleteSelectedItems();
287 else if (type == ACTION_TYPE_PLAY) {
288 if (m->ctxtinfo->status == PLAY_STATUS_PLAY)
289 m->parent->m_KeyPausePress();
291 if (itinfo == m->cs_itinfo)
292 m->parent->m_KeyPlayPress();
294 m->parent->m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
298 _ERR(" Wrong ctxt add type in plaback view ");
302 if (!m->mgr->PopView()) {
303 _ERR("CViewMgr::PopView failed");
307 if (!m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL)) {
308 _ERR("CViewMgr::PushView failed");
312 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
316 void CPlaybackView::sm_CbCtxtClose(void *dt)
318 SPlaybackView *m = (SPlaybackView *)dt;
323 if (!m->mgr->PopView()) {
324 _ERR("CViewMgr::PopView failed");
328 if (!m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL)) {
329 _ERR("CViewMgr::PushView failed");
333 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
337 void CPlaybackView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text)
339 CPlaybackView *root = (CPlaybackView *)cookie;
341 root->m_CbCtxPopupBtnSelected(instance, text);
345 void CPlaybackView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text)
347 int type = CInfo::PlaybackSettingType();
351 m_FromPlaybackToEditMode();
355 m->hMusicController->Stop();
356 m->hMusicController->EmptyPlaylist();
357 eina_list_free(m->elInfo);
359 elm_genlist_clear(m->eoPlaylist);
360 m_UpdateEmptySongInfo();
369 void CPlaybackView::m_RemoveTimer(int timer_code)
371 ETimers timerCode = (ETimers)timer_code;
376 ecore_timer_del(m->etSlider);
383 ecore_timer_del(m->etWait);
388 case TIMER_LONGPRESS:
389 if (m->etLongPress) {
390 ecore_timer_del(m->etLongPress);
391 m->etLongPress = NULL;
396 m->pHandleVolume->RemoveTimer();
400 _ERR(" invalid value ");
406 void CPlaybackView::m_PlaybackPause(void)
408 m->hMusicController->Pause();
411 ecore_timer_freeze(m->etSlider);
415 void CPlaybackView::m_PlaybackResume(void)
417 m->hMusicController->Resume();
420 ecore_timer_thaw(m->etSlider);
424 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
426 SItemInfo *itinfo = NULL;
430 EINA_LIST_FOREACH(list, l, obj) {
431 itinfo = (SItemInfo *)obj;
432 itinfo->edit_mode = flag;
437 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
439 SItemInfo *itinfo = NULL;
443 EINA_LIST_FOREACH(list, l, obj) {
444 itinfo = (SItemInfo *)obj;
445 itinfo->check_status = false;
450 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
452 if (!pItemInfo || !pItemInfo->item)
455 elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
456 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
458 pItemInfo->select_status = true;
462 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
464 if (!pItemInfo || !pItemInfo->item)
467 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
468 MUSIC_PLAYBACK_VIEW);
470 pItemInfo->select_status = false;
474 void CPlaybackView::m_UpdateControlBtns(void)
478 state = m->hMusicController->PlayState();
479 if (state != PLAY_STATUS_STOP) {
480 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
481 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
485 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
486 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
487 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
490 if (state == PLAY_STATUS_PLAY) {
491 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
494 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
497 state = m->hMusicController->ShuffleState();
498 if (state == SHUFFLE_STATUS_OFF) {
499 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
502 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
505 state = m->hMusicController->RepeatState();
506 if (state == REPEAT_STATUS_NONE) {
507 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
509 else if (state == REPEAT_STATUS_ALL) {
510 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
513 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
518 void CPlaybackView::m_UpdateCurrentSongProgressbar(void)
521 char *timestr = NULL;
528 elm_slider_value_set(m->eoSlider, 0);
529 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
531 state = m->hMusicController->PlayState();
533 if (state == PLAY_STATUS_STOP) {
534 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
535 m_RemoveTimer(TIMER_SLIDER);
539 elm_object_disabled_set(m->eoSlider, EINA_FALSE);
541 duration = m->csinfo->Duration();
543 m_RemoveTimer(TIMER_SLIDER);
544 m->etSlider = ecore_timer_add(S_INTERVAL,
545 sm_CbUpdateSlider, m);
547 elm_slider_min_max_set(m->eoSlider, 0, duration);
548 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
550 elm_object_part_text_set(m->eoBase,
551 MUSIC_PART_FULLTIME, timestr);
555 step = (double)SLIDER_STEP / (double)duration;
556 elm_slider_step_set(m->eoSlider, step);
561 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
564 char buf[MAX_LENGTH];
566 if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
569 path = m->cs_itinfo->sinfo->ThumbnailPath();
571 elm_image_file_set(m->eoAlbumCover, path, NULL);
573 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
574 MUSIC_IMAGE_DEFAULT_THUMB_450);
575 elm_image_file_set(m->eoAlbumCover, buf, NULL);
580 void CPlaybackView::m_UpdateCurrentSongLabels(void)
582 char buf[MAX_LENGTH];
587 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
590 snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
593 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
597 void CPlaybackView::m_UpdateEmptySongInfo(void)
599 char buf[MAX_LENGTH];
601 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
602 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
603 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
604 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
605 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
606 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
607 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
608 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
609 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
610 elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
611 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
612 elm_slider_value_set(m->eoSlider, 0);
613 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
614 _(NO_PLAYLIST_MESSAGE));
615 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
616 _(NO_PLAYLIST_MESSAGE_SUB));
617 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
618 MUSIC_IMAGE_DEFAULT_THUMB_450);
619 elm_image_file_set(m->eoAlbumCover, buf, NULL);
620 m->hMusicController->SetPlayState(PLAY_STATUS_INITIAL);
624 void CPlaybackView::m_UpdateCtxtView(int playStatus)
626 if (!m->cs_itinfo || !m->ctxtinfo)
629 if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
632 if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
633 m->ctxtinfo->status = (EPlayStatus)playStatus;
636 parcel.ctxtInfo = NULL;
637 parcel.updateType = E_SONG_UPDATE;
638 parcel.layoutId = NULL;
639 parcel.keyEvent = NULL;
640 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
645 void CPlaybackView::m_UpdateCurrentSongItem(int index)
647 SItemInfo *pItemInfo = NULL;
650 m_UnselectItem(m->cs_itinfo);
651 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
654 pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
657 m->cs_itinfo = pItemInfo;
658 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
659 elm_genlist_item_bring_in(pItemInfo->item,
660 ELM_GENLIST_ITEM_SCROLLTO_IN);
663 m_SelectItem(pItemInfo);
664 m_UpdateCtxtView(PLAY_STATUS_PLAY);
670 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
672 elm_object_focus_next_object_set(m->eoPlaylist,
673 m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
674 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
675 m->eoPlaylist, ELM_FOCUS_RIGHT);
676 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnEdit[BTN_CANCEL],
681 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
683 elm_object_focus_next_object_set(m->eoSlider, m->eoPlaylist,
685 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnControl[BTN_PLAY],
687 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
688 elm_object_focus_next_object_set(m->eoPlaylist,
689 m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
690 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
691 m->eoPlaylist, ELM_FOCUS_RIGHT);
694 elm_object_focus_next_object_set(m->eoPlaylist,
695 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
696 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
697 m->eoPlaylist, ELM_FOCUS_RIGHT);
698 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
699 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
704 void CPlaybackView::m_UpdateCurrentSongInfo(void)
706 CSongInfo *sinfo = NULL;
709 if (eina_list_count(m->elInfo) == 0) {
710 m_UpdateEmptySongInfo();
714 if (!m->hMusicController->GetCurrentSongIndex(&index)) {
715 _ERR(" music get current song index failed ");
719 if (!m->hMusicController->GetSonginfoFromIndex(index, &sinfo)) {
720 _ERR(" music get songinfo failed ");
725 m_UpdateCurrentSongItem(index);
726 m_UpdateCurrentSongLabels();
727 m_UpdateCurrentSongThumbnail();
728 m_UpdateCurrentSongProgressbar();
729 m_UpdateControlBtns();
730 m_UpdatePlaymodeFocusSequence();
734 void CPlaybackView::m_DisableEditButtons(bool flag)
736 /* flag - 1 means disable edit buttons and 0 means enable */
738 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
740 elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
741 elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
743 m_UpdateEditmodeFocusSequence();
744 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
747 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
748 m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
749 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE],
750 m->eoPlaylist, ELM_FOCUS_RIGHT);
751 elm_object_focus_next_object_set(m->eoPlaylist,
752 m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
757 void CPlaybackView::m_CreateErrorPopup(void)
759 Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
761 popup = elm_popup_add(m->eoBase);
765 elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
766 evas_object_show(popup);
768 label = elm_label_add(popup);
770 evas_object_del(popup);
774 elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
775 elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
776 elm_object_content_set(popup, label);
778 btn = elm_button_add(popup);
780 evas_object_del(popup);
784 elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
785 elm_object_text_set(btn, MUSIC_TEXT_OK);
786 elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
788 m->eoErrPopup = popup;
790 Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
792 elm_object_focus_set(btn, EINA_TRUE);
798 void CPlaybackView::m_DestroyErrorPopup(void)
803 evas_object_del(m->eoErrPopup);
804 m->eoErrPopup = NULL;
808 void CPlaybackView::m_CreateSettingsPopup(void)
810 CPlaySettingCtxPopup *eoCtxPopup = new CPlaySettingCtxPopup;
811 CCtxPopup::SCallback cb;
813 cb.onSelected = sm_CbCtxPopupBtnSelected;
815 eoCtxPopup->Create(m->eoWin, &cb);
817 m->eoCtxPopup = eoCtxPopup;
821 void CPlaybackView::m_DestroySettingsPopup(void)
826 if (m->eoCtxPopup->FlagCreate())
827 m->eoCtxPopup->Destroy();
829 delete m->eoCtxPopup;
830 m->eoCtxPopup = NULL;
834 void CPlaybackView::m_FromEditToPlaybackMode(void)
836 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
837 elm_genlist_item_bring_in(m->cs_itinfo->item,
838 ELM_GENLIST_ITEM_SCROLLTO_IN);
841 m_SelectItem(m->cs_itinfo);
843 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
844 MUSIC_PLAYBACK_VIEW);
845 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
847 m_ChangeEditmodeAll(m->elInfo, false);
849 elm_genlist_realized_items_update(m->eoPlaylist);
851 m_UpdatePlaymodeFocusSequence();
855 void CPlaybackView::m_FromPlaybackToEditMode(void)
857 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_EDIT_MODE,
858 MUSIC_PLAYBACK_VIEW);
860 m_DisableEditButtons(true);
862 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
864 m_ChangeEditmodeAll(m->elInfo, true);
866 elm_genlist_realized_items_update(m->eoPlaylist);
868 m_UpdateEditmodeFocusSequence();
872 void CPlaybackView::m_HandleOnRepeated(void)
874 Evas_Object *obj = NULL;
877 char *timestr = NULL;
879 if (!m->eoPressedObj)
882 obj = m->eoPressedObj;
884 value = elm_slider_value_get(m->eoSlider);
885 duration = m->cs_itinfo->sinfo->Duration();
887 if (obj == m->eoBtnControl[BTN_REWIND]) {
889 m_RemoveTimer(TIMER_LONGPRESS);
892 value = value - LP_CHANGE;
897 if (value == duration) {
898 if (m->hMusicController->PlayNextSong())
899 m_UpdateCurrentSongInfo();
901 _ERR(" music play next song failed ");
903 m->press_status = PRESS_LONG_PAUSE;
904 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE,
905 MUSIC_PLAYBACK_VIEW);
907 m_RemoveTimer(TIMER_LONGPRESS);
911 value = value + LP_CHANGE;
912 if (value >= duration)
916 m->hMusicController->SetPosition(value);
917 elm_slider_value_set(m->eoSlider, value);
918 timestr = CCommonUI::TimeStrFromMilSeconds(value);
920 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
929 void CPlaybackView::m_DeleteSelectedItems(void)
931 Eina_List *l = NULL, *l_next = NULL;
932 SItemInfo *pItemInfo = NULL;
937 m_DisableEditButtons(true);
938 EINA_LIST_FOREACH_SAFE(m->elInfo, l, l_next, obj) {
939 pItemInfo = (SItemInfo *)obj;
940 if (pItemInfo->check_status) {
941 if (m->cs_itinfo == pItemInfo) {
943 m_UnselectItem(m->cs_itinfo);
944 m_RemoveTimer(TIMER_SLIDER);
946 m->hMusicController->SetPlayState(PLAY_STATUS_STOP);
947 m->hMusicController->Stop();
949 index = elm_genlist_item_index_get(pItemInfo->item);
950 m->hMusicController->RemoveSong(pItemInfo->sinfo, index);
952 m->elInfo = eina_list_remove(m->elInfo,
954 elm_object_item_del(pItemInfo->item);
958 if (eina_list_count(m->elInfo) == 0) {
959 m_UpdateEmptySongInfo();
960 elm_genlist_realized_items_update(m->eoPlaylist);
961 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
966 m_UpdateCurrentSongInfo();
968 elm_genlist_realized_items_update(m->eoPlaylist);
969 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
973 void CPlaybackView::m_KeyBackPress(void)
976 m_DestroySettingsPopup();
977 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_FALSE);
978 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
983 m->mgr->PushView(MUSIC_BASE_VIEW, NULL);
987 void CPlaybackView::m_KeyExitPress(void)
989 m_RemoveTimer(TIMER_SLIDER);
990 m->hMusicController->Stop();
995 void CPlaybackView::m_KeyPlayPress(void)
999 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1002 state = m->hMusicController->PlayState();
1003 if (state == PLAY_STATUS_PAUSE) {
1005 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1006 MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1008 else if (state != PLAY_STATUS_PLAY) {
1009 if (m->hMusicController)
1010 m->hMusicController->Start();
1012 m_UpdateCurrentSongInfo();
1017 void CPlaybackView::m_KeyPausePress(void)
1021 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1024 state = m->hMusicController->PlayState();
1025 if (state == PLAY_STATUS_PLAY) {
1026 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1027 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1033 void CPlaybackView::m_KeyNextPress(void)
1035 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1038 m_HandleOnPressed(m->eoBtnControl[BTN_FORWARD]);
1042 void CPlaybackView::m_KeyPreviousPress(void)
1044 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1047 m_HandleOnPressed(m->eoBtnControl[BTN_REWIND]);
1051 void CPlaybackView::m_KeyNextUnpress(void)
1053 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1056 m_HandleOnUnpressed(m->eoBtnControl[BTN_FORWARD]);
1060 void CPlaybackView::m_KeyPreviousUnpress(void)
1062 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1065 m_HandleOnUnpressed(m->eoBtnControl[BTN_REWIND]);
1069 void CPlaybackView::m_HandleKeyPress(char *keyname)
1071 if (!strcmp(keyname, (char *)KEY_EXIT))
1073 else if (!strcmp(keyname, (char *)KEY_BACK) ||
1074 !strcmp(keyname, (char *)KEY_BACK_REMOTE))
1076 else if (!strcmp(keyname, (char *)KEY_PLAY))
1078 else if (!strcmp(keyname, (char *)KEY_PAUSE))
1080 else if (!strcmp(keyname, (char *)KEY_NEXT))
1082 else if (!strcmp(keyname, (char *)KEY_PREVIOUS))
1083 m_KeyPreviousPress();
1084 else if (!strcmp(keyname, (char *)KEY_VOLUMEUP))
1085 m->pHandleVolume->Up();
1086 else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN))
1087 m->pHandleVolume->Down();
1088 else if (!strcmp(keyname, (char *)KEY_MUTE))
1089 m->pHandleVolume->Mute();
1093 void CPlaybackView::m_HandleKeyUnpress(char *keyname)
1095 if (!strcmp(keyname, KEY_PREVIOUS))
1096 m_KeyPreviousUnpress();
1097 else if (!strcmp(keyname, KEY_NEXT))
1102 void CPlaybackView::m_AddSlider(void)
1104 Evas_Object *eoSlider = NULL;
1106 eoSlider = elm_slider_add(m->eoBase);
1110 elm_slider_indicator_show_set(eoSlider, EINA_FALSE);
1111 elm_slider_indicator_show_on_focus_set(eoSlider, EINA_FALSE);
1112 elm_object_style_set(eoSlider, MUSIC_STYLE_SLIDER);
1113 elm_slider_horizontal_set(eoSlider, EINA_TRUE);
1114 elm_object_part_content_set(m->eoBase, MUSIC_PART_PROGRESSBAR, eoSlider);
1116 Connect(eoSlider, EO_SLIDER, TYPE_CHANGED | TYPE_MOUSE_MOVE);
1118 evas_object_show(eoSlider);
1119 m->eoSlider = eoSlider;
1123 void CPlaybackView::m_AddAlbumCover(void)
1125 Evas_Object *eoAlbumCover = NULL;
1127 eoAlbumCover = elm_image_add(m->eoBase);
1131 evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
1133 elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
1135 elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
1137 evas_object_show(eoAlbumCover);
1138 m->eoAlbumCover = eoAlbumCover;
1143 void CPlaybackView::m_AddCurrentSonginfo(void)
1150 void CPlaybackView::m_AddEditPlaylistButtons(void)
1152 Evas_Object *box = NULL;
1154 SBtnInfo btninfo[TOTAL_EDIT_BTNS];
1156 btninfo[BTN_CANCEL].txt = MUSIC_TEXT_CANCEL;
1157 btninfo[BTN_CANCEL].type = EO_CANCEL;
1159 btninfo[BTN_DESELECT].txt = MUSIC_TEXT_DESELECT;
1160 btninfo[BTN_DESELECT].type = EO_DESELECT;
1162 btninfo[BTN_DELETE].txt = MUSIC_TEXT_DELETE;
1163 btninfo[BTN_DELETE].type = EO_DELETE;
1165 box = CCommonUI::AddBox(m->eoBase);
1169 elm_box_horizontal_set(box, EINA_TRUE);
1170 elm_box_padding_set(box,
1171 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
1173 for (i = 0; i < TOTAL_EDIT_BTNS; i++) {
1174 m->eoBtnEdit[i] = elm_button_add(m->eoBase);
1175 if (!m->eoBtnEdit[i])
1178 elm_object_style_set(m->eoBtnEdit[i],
1179 MUSIC_STYLE_EDIT_BTN);
1180 evas_object_size_hint_weight_set(m->eoBtnEdit[i],
1181 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1182 elm_box_pack_end(box, m->eoBtnEdit[i]);
1183 elm_object_text_set(m->eoBtnEdit[i], _(btninfo[i].txt));
1185 Connect(m->eoBtnEdit[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1187 evas_object_show(m->eoBtnEdit[i]);
1189 elm_object_part_content_set(m->eoBase, MUSIC_PART_EDITBTNS, box);
1190 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
1191 MUSIC_PLAYBACK_VIEW);
1195 void CPlaybackView::m_AddControlButtons(void)
1197 Evas_Object *box = NULL;
1199 SBtnInfo btninfo[TOTAL_CONTROL_BTNS];
1201 btninfo[BTN_SETTINGS].txt = MUSIC_STYLE_BTN_SETTINGS;
1202 btninfo[BTN_SETTINGS].type = EO_BTN_SETTINGS;
1204 btninfo[BTN_SHUFFLE].txt = MUSIC_STYLE_BTN_SHUFFLE;
1205 btninfo[BTN_SHUFFLE].type = EO_BTN_SHUFFLE;
1207 btninfo[BTN_REPEAT].txt = MUSIC_STYLE_BTN_REPEAT;
1208 btninfo[BTN_REPEAT].type = EO_BTN_REPEAT;
1210 btninfo[BTN_REWIND].txt = MUSIC_STYLE_BTN_REWIND;
1211 btninfo[BTN_REWIND].type = EO_BTN_REWIND;
1213 btninfo[BTN_PLAY].txt = MUSIC_STYLE_BTN_PLAY;
1214 btninfo[BTN_PLAY].type = EO_BTN_PLAY;
1216 btninfo[BTN_FORWARD].txt = MUSIC_STYLE_BTN_FORWARD;
1217 btninfo[BTN_FORWARD].type = EO_BTN_FORWARD;
1219 box = elm_box_add(m->eoBase);
1223 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
1224 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
1225 elm_box_horizontal_set(box, EINA_TRUE);
1226 elm_box_padding_set(box,
1227 MUSIC_CONTROL_BTNS_PADDING * elm_config_scale_get(), 0);
1229 for (i = 0; i < TOTAL_CONTROL_BTNS; i++) {
1230 m->eoBtnControl[i] = elm_button_add(m->eoBase);
1231 if (!m->eoBtnControl[i])
1234 elm_object_style_set(m->eoBtnControl[i], btninfo[i].txt);
1235 evas_object_size_hint_weight_set(m->eoBtnControl[i],
1236 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1237 elm_box_pack_end(box, m->eoBtnControl[i]);
1239 if (i == BTN_REWIND || i == BTN_FORWARD) {
1240 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_PRESSED | TYPE_UNPRESSED | TYPE_MOUSE_MOVE);
1243 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1245 evas_object_show(m->eoBtnControl[i]);
1248 elm_object_part_content_set(m->eoBase, MUSIC_PART_CONTROLBTNS, box);
1252 SItemInfo *CPlaybackView::m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo)
1254 Eina_List *l = NULL;
1255 SItemInfo *itinfo = NULL;
1258 EINA_LIST_FOREACH(list, l, obj) {
1259 itinfo = (SItemInfo *)obj;
1260 if (itinfo->sinfo == sinfo)
1268 SItemInfo *CPlaybackView::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
1270 Eina_List *l = NULL;
1271 SItemInfo *itinfo = NULL;
1274 EINA_LIST_FOREACH(list, l, obj) {
1275 itinfo = (SItemInfo *)obj;
1276 if (itinfo->item == item)
1284 void CPlaybackView::m_UpdateItemCheck(SItemInfo *itinfo)
1287 _ERR(" No item info to Update check ");
1291 if (itinfo->check_status) {
1292 elm_object_item_signal_emit(itinfo->item,
1293 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1294 itinfo->check_status = false;
1298 elm_object_item_signal_emit(itinfo->item,
1299 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
1300 itinfo->check_status = true;
1304 class CElmGenlistItemClass {
1306 static char *sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
1308 CSongInfo *sinfo = NULL;
1309 SItemInfo *pItemInfo = (SItemInfo *)data;
1310 char buf[MAX_LENGTH];
1311 char *timestr = NULL;
1315 if (!pItemInfo || !obj)
1318 sinfo = pItemInfo->sinfo;
1320 snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY);
1322 if (!strcmp(part, "elm.text0")) {
1323 index = elm_genlist_item_index_get(pItemInfo->item);
1324 snprintf(buf, sizeof(buf), "%d", index);
1325 if ((index & 1) == 1) {
1326 elm_object_item_signal_emit(pItemInfo->item,
1327 MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW);
1330 elm_object_item_signal_emit(pItemInfo->item,
1331 MUSIC_SIGNAL_ODD_ROW, MUSIC_PLAYBACK_VIEW);
1334 else if (!strcmp(part, "elm.text1"))
1335 snprintf(buf, sizeof(buf), "%s", sinfo->Name());
1336 else if (!strcmp(part, "elm.text2"))
1337 snprintf(buf, sizeof(buf), "%s - %s",
1340 else if (!strcmp(part, "elm.text3")) {
1341 duration = sinfo->Duration();
1342 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
1344 snprintf(buf, sizeof(buf), "%s", timestr);
1349 if (strcmp(buf, MUSIC_STR_EMPTY))
1354 static Evas_Object *sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
1356 CSongInfo *sinfo = NULL;
1357 SItemInfo *pItemInfo = (SItemInfo *)data;
1358 Evas_Object *img = NULL;
1360 char buf[MAX_LENGTH];
1362 if (!pItemInfo || !obj)
1365 sinfo = pItemInfo->sinfo;
1367 img = elm_image_add(obj);
1371 elm_image_aspect_fixed_set(img, EINA_FALSE);
1373 if (!strcmp(part, "elm.swallow.icon")) {
1374 path = sinfo->ThumbnailPath();
1376 elm_image_file_set(img, path, "NULL");
1378 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
1379 MUSIC_IMAGE_DEFAULT_THUMB_126);
1380 elm_image_file_set(img, buf, "NULL");
1384 if (pItemInfo->select_status) {
1385 elm_object_item_signal_emit(pItemInfo->item,
1386 MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
1389 elm_object_item_signal_emit(pItemInfo->item,
1390 MUSIC_SIGNAL_UNSELECT_ITEM,
1391 MUSIC_PLAYBACK_VIEW);
1394 if (pItemInfo->edit_mode) {
1395 elm_object_item_signal_emit(pItemInfo->item,
1396 MUSIC_SIGNAL_EDITMODE_ON, MUSIC_PLAYBACK_VIEW);
1397 if (pItemInfo->check_status) {
1398 elm_object_item_signal_emit(pItemInfo->item,
1399 MUSIC_SIGNAL_CHECK_ON,
1400 MUSIC_PLAYBACK_VIEW);
1403 elm_object_item_signal_emit(pItemInfo->item,
1404 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1408 elm_object_item_signal_emit(pItemInfo->item,
1409 MUSIC_SIGNAL_EDITMODE_OFF, MUSIC_PLAYBACK_VIEW);
1415 static void sm_CbDel(void *data, Evas_Object *obj)
1422 Elm_Genlist_Item_Class *CPlaybackView::m_GetItemClass(void)
1424 Elm_Genlist_Item_Class *list_item = NULL;
1426 list_item = elm_genlist_item_class_new();
1428 _ERR(" elm_genlist_item_class_new failed ");
1432 list_item->item_style = MUSIC_STYLE_PLAYLIST;
1433 list_item->func.text_get = CElmGenlistItemClass::sm_CbTextGet;
1434 list_item->func.content_get = CElmGenlistItemClass::sm_CbContentGet;
1435 list_item->func.state_get = NULL;
1436 list_item->func.del = CElmGenlistItemClass::sm_CbDel;
1442 void CPlaybackView::m_AddGenlist(void)
1444 Evas_Object *genlist = NULL;
1445 Evas_Object *eoBase = NULL;
1448 genlist = elm_genlist_add(eoBase);
1452 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1453 evas_object_size_hint_weight_set(genlist,
1454 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1455 elm_object_part_content_set(eoBase, MUSIC_PART_PLAYLIST, genlist);
1456 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
1457 elm_genlist_multi_select_set(genlist, EINA_FALSE);
1459 Connect(genlist, EO_PLAYLIST, TYPE_REALIZED | TYPE_UNREALIZED | TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_ACTIVATED);
1461 evas_object_show(genlist);
1462 m->eoPlaylist = genlist;
1466 void CPlaybackView::m_AddPlaylist(void)
1468 Elm_Genlist_Item_Class *list_item = NULL;
1471 CSongInfo *sinfo = NULL;
1472 Elm_Object_Item *item = NULL;
1473 SItemInfo *pItemInfo = NULL;
1479 list_item = m_GetItemClass();
1481 evas_object_del(m->eoPlaylist);
1485 if (!m->hMusicController->GetTotalSongs(&ts)) {
1486 _ERR(" music get total songs failed ");
1490 if (!m->hMusicController->GetCurrentSongIndex(&index))
1491 _ERR(" music get current song index failed ");
1493 for (i = 0; i < ts; i++) {
1494 if (!m->hMusicController->GetSonginfoFromIndex(i, &sinfo)) {
1495 _ERR(" music get songinfo failed ");
1498 pItemInfo = (SItemInfo *)calloc(1, sizeof(*pItemInfo));
1501 pItemInfo->sinfo = sinfo;
1502 pItemInfo->edit_mode = false;
1503 pItemInfo->check_status = false;
1504 pItemInfo->select_status = false;
1506 item = elm_genlist_item_append(m->eoPlaylist, list_item,
1507 pItemInfo, NULL, ELM_GENLIST_ITEM_NONE,
1508 sm_CbItemSelect, m);
1509 pItemInfo->item = item;
1512 pItemInfo->select_status = true;
1513 m->cs_itinfo = pItemInfo;
1515 m->elInfo = eina_list_append(m->elInfo, pItemInfo);
1520 void CPlaybackView::m_RemovePlaylist(void)
1522 if (m->eoPlaylist) {
1523 elm_genlist_clear(m->eoPlaylist);
1524 m->eoPlaylist = NULL;
1528 eina_list_free(m->elInfo);
1534 void CPlaybackView::m_HandleRewindBtnClicked(Evas_Object *obj)
1536 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1537 MUSIC_PLAYBACK_VIEW);
1539 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1542 if (!m->hMusicController->PlayPreviousSong()){
1543 _ERR(" music play previous song failed ");
1547 m_UpdateCurrentSongInfo();
1551 void CPlaybackView::m_HandleForwardBtnClicked(Evas_Object *obj)
1553 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1554 MUSIC_PLAYBACK_VIEW);
1556 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1559 if (!m->hMusicController->PlayNextSong()) {
1560 _ERR(" music play next song failed ");
1564 m_UpdateCurrentSongInfo();
1568 void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
1570 m->press_status = PRESS_SHORT;
1571 m->eoPressedObj = obj;
1573 m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, m);
1577 void CPlaybackView::m_HandleOnUnpressed(Evas_Object *obj)
1579 m_RemoveTimer(TIMER_WAIT);
1580 m_RemoveTimer(TIMER_LONGPRESS);
1582 if (m->press_status == PRESS_SHORT) {
1583 /* Handle song change */
1584 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY)
1587 if (obj == m->eoBtnControl[BTN_FORWARD])
1588 m_HandleForwardBtnClicked(obj);
1590 m_HandleRewindBtnClicked(obj);
1592 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1595 else if (m->press_status == PRESS_LONG) {
1596 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1600 m->press_status = PRESS_SHORT;
1604 void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_Item *genListItem)
1607 SItemInfo *itinfo = NULL;
1609 if (!obj || !genListItem)
1612 itinfo = m_FindItemInfoFromItem(m->elInfo, genListItem);
1614 _ERR(" no item info found ");
1618 if (itinfo->edit_mode) {
1619 m_UpdateItemCheck(itinfo);
1620 m_DisableEditButtons(false);
1624 index = elm_genlist_item_index_get(genListItem);
1626 m->hMusicController->PlayIndexSong(--index);
1627 m_UpdateCurrentSongInfo();
1631 bool CPlaybackView::Create(void *data)
1636 _CHECK(m = new SPlaybackView)
1637 _CHECK(m->mgr = CViewMgr::GetInstance())
1638 _CHECK(m->eoWin = m->mgr->Window())
1639 _CHECK(m->hMusicController = CMusicController::GetInstance())
1640 _CHECK(m->eoBase = CCommonUI::AddBase(m->eoWin, MUSIC_PLAYBACK_VIEW))
1641 _CHECK(CBaseView::Create(data))
1642 _CHECK(m->hMusicController->AddListener(this))
1645 m->press_status = PRESS_SHORT;
1648 evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1650 m_AddControlButtons();
1651 m_AddEditPlaylistButtons();
1652 m_AddCurrentSonginfo();
1655 m->pHandleVolume->Create(m->eoBase);
1656 m_UpdatePlaymodeFocusSequence();
1658 Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1661 _CHECK_FAIL{ m->hMusicController->RemoveListener(this); }
1662 _CHECK_FAIL{ CBaseView::Destroy(); }
1663 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1664 _CHECK_FAIL{ /* CMusicController::GetInstance())*/ }
1665 _CHECK_FAIL{ /* mgr->Window() */ }
1666 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1667 _CHECK_FAIL{ delete m; m = NULL; }
1668 }_CREATE_END_AND_CATCH{ return false; }
1674 void CPlaybackView::Destroy(void)
1678 Disconnect(m->eoBase);
1679 m->hMusicController->RemoveListener(this);
1681 m_DestroyErrorPopup();
1683 m_RemoveTimer(TIMER_SLIDER);
1684 m_RemoveTimer(TIMER_WAIT);
1685 m_RemoveTimer(TIMER_LONGPRESS);
1686 m_DestroySettingsPopup();
1688 m->pHandleVolume->Destroy();
1689 CBaseView::Destroy();
1690 evas_object_del(m->eoBase);
1698 Evas_Object* CPlaybackView::Base(void)
1706 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1708 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1710 if (eina_list_count(m->elInfo) == 0)
1713 elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1714 m_DestroySettingsPopup();
1715 m_CreateSettingsPopup();
1719 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1721 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1723 switch (m->hMusicController->ShuffleState()) {
1724 case SHUFFLE_STATUS_OFF:
1725 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_ON);
1726 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1730 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_OFF);
1731 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1737 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1739 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1741 switch (m->hMusicController->RepeatState()) {
1742 case REPEAT_STATUS_NONE:
1743 m->hMusicController->SetRepeatState(REPEAT_STATUS_ALL);
1744 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1747 case REPEAT_STATUS_ALL:
1748 m->hMusicController->SetRepeatState(REPEAT_STATUS_ONE);
1749 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1753 m->hMusicController->SetRepeatState(REPEAT_STATUS_NONE);
1754 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1760 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1762 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1764 switch (m->hMusicController->PlayState()) {
1765 case PLAY_STATUS_PAUSE:
1767 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1770 case PLAY_STATUS_PLAY:
1771 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1776 if (m->hMusicController)
1777 m->hMusicController->Start();
1778 m_UpdateCurrentSongInfo();
1784 void CPlaybackView::t_OnShow(void)
1790 m_UpdateCurrentSongInfo();
1793 elm_genlist_item_show(m->cs_itinfo->item,
1794 ELM_GENLIST_ITEM_SCROLLTO_IN);
1795 elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
1798 state = m->hMusicController->PlayState();
1799 if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
1802 m->hMusicController->Start();
1803 m_UpdateCurrentSongInfo();
1806 evas_object_show(m->eoBase);
1810 void CPlaybackView::t_OnUpdate(void *data)
1817 SParcel *parcel = (SParcel *)data;
1818 int updateType = parcel->updateType;
1819 char *key = (char *)parcel->keyEvent;
1821 switch (updateType) {
1822 case E_PLAYLIST_UPDATE:
1825 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
1826 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
1827 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
1828 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
1829 m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
1830 m_FromEditToPlaybackMode();
1834 m_HandleKeyPress(key);
1838 m_HandleKeyUnpress(key);
1847 void CPlaybackView::t_OnHide(void)
1851 evas_object_hide(m->eoBase);
1855 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
1859 m_HandleKeyPress(ev->keyname);
1862 case EO_ERROR_POPUP_BUTTON:
1863 if (!strcmp(ev->keyname, KEY_BACK) ||
1864 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1865 m_DestroyErrorPopup();
1866 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1872 Elm_Object_Item *it = NULL;
1873 SContentInfo *ctxtinfo = NULL;
1874 SItemInfo *itinfo = NULL;
1876 if (strcmp(ev->keyname, KEY_MENU) &&
1877 strcmp(ev->keyname, KEY_MENU_REMOTE))
1880 it = elm_object_focused_item_get(obj);
1882 _ERR(" unable to get focused item ");
1885 m->focused_item = it;
1892 ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
1896 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
1902 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY &&
1903 itinfo == m->cs_itinfo)
1904 ctxtinfo->status = PLAY_STATUS_PLAY;
1906 ctxtinfo->status = PLAY_STATUS_PAUSE;
1908 ctxtinfo->cbdata = m;
1909 ctxtinfo->update = sm_CbCtxtUpdate;
1910 ctxtinfo->close = sm_CbCtxtClose;
1911 ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
1912 ctxtinfo->context = itinfo->sinfo;
1914 m->ctxtinfo = ctxtinfo;
1917 parcel.ctxtInfo = ctxtinfo;
1918 if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
1919 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
1923 if (!strcmp(ev->keyname, KEY_BACK) ||
1924 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1925 _ERR("eoCtxPopup BACK key pressed ");
1926 m_DestroySettingsPopup();
1927 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1930 else if (!strcmp(ev->keyname, KEY_EXIT)) {
1931 _ERR("eoCtxPopup EXIT key pressed ");
1932 m_DestroySettingsPopup();
1933 m_RemoveTimer(TIMER_SLIDER);
1934 m->hMusicController->Stop();
1945 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
1949 m_HandleKeyUnpress(ev->keyname);
1958 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
1961 case EO_ERROR_POPUP_BUTTON:
1962 m_DestroyErrorPopup();
1963 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1967 m_DisableCheckAll(m->elInfo);
1968 m_DisableEditButtons(true);
1969 m_FromEditToPlaybackMode();
1973 m_DisableCheckAll(m->elInfo);
1974 m_DisableEditButtons(true);
1975 elm_genlist_realized_items_update(m->eoPlaylist);
1976 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1980 m_DeleteSelectedItems();
1983 case EO_BTN_SETTINGS:
1984 t_OnClickedSettings(obj);
1987 case EO_BTN_SHUFFLE:
1988 t_OnClickedShuffle(obj);
1992 t_OnClickedRepeat(obj);
1996 t_OnClickedPlay(obj);
2005 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
2012 case EO_BTN_FORWARD:
2016 case EO_BTN_SETTINGS:
2017 case EO_BTN_SHUFFLE:
2018 if (!elm_object_focus_get(obj))
2019 elm_object_focus_set(obj, EINA_TRUE);
2024 Elm_Object_Item *item;
2026 item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
2027 ev->cur.canvas.y, NULL);
2031 if (!elm_object_item_focus_get(item))
2032 elm_object_item_focus_set(item, EINA_TRUE);
2042 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2045 case EO_BTN_FORWARD:
2047 m_HandleOnPressed(obj);
2056 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2059 case EO_BTN_FORWARD:
2061 m_HandleOnUnpressed(obj);
2070 void CPlaybackView::OnChanged(int id, Evas_Object *obj)
2075 char *timestr = NULL;
2078 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2080 ecore_timer_freeze(m->etSlider);
2083 value = elm_slider_value_get(obj);
2084 m->hMusicController->SetPosition(value);
2085 timestr = CCommonUI::TimeStrFromMilSeconds(value);
2087 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
2092 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2094 ecore_timer_thaw(m->etSlider);
2105 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2109 elm_object_item_signal_callback_add(item,
2110 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2111 sm_CbGenlistItemCheckClicked, this);
2120 void CPlaybackView::OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2124 elm_object_item_signal_callback_del(item,
2125 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2126 sm_CbGenlistItemCheckClicked);
2135 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2139 m_HandleGenlistItemActivated(obj, item);
2148 void CPlaybackView::t_OnComplete(void)
2150 m_UpdateCurrentSongInfo();
2154 void CPlaybackView::t_OnError(void)
2156 m_CreateErrorPopup();
2160 void CPlaybackView::t_OnUsbConnected(void)
2165 void CPlaybackView::t_OnUpdateContent(void)