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>
21 #include "AppCommon.h"
22 #include <InputHandler.h>
27 #include "song_info.h"
28 #include "album_info.h"
29 #include "music-controller.h"
30 #include "volume-control.h"
32 #include "common-ui.h"
35 #include "playback-view.h"
36 #include "context-view.h"
37 #include "HandleVolume.h"
38 #include <app-res-defines.h>
39 #include "PlaySettingCtxPopup.h"
43 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
44 #define TITLE_FONT_SIZE 50
45 #define ARTIST_FONT_SIZE 30
46 #define TOTAL_CONTROL_BTNS 6
47 #define TOTAL_EDIT_BTNS 3
48 #define S_INTERVAL 1 /* seconds */
49 #define LP_INTERVAL 0.5 /* seconds */
50 #define WAIT_INTERVAL 0.5 /* seconds */
51 #define SLIDER_STEP 5000 /* milli seconds */
52 #define LP_CHANGE 10000 /* milli seconds */
53 #define S_INCREMENT 1000 /* milli seconds */
59 EO_ERROR_POPUP_BUTTON,
63 EO_DELETE, // TOTAL_EDIT_BTNS
70 EO_BTN_FORWARD, // TOTAL_CONTROL_BTNS
81 Elm_Object_Item *item;
88 struct SPlaybackView {
92 CPlaySettingCtxPopup *eoCtxPopup;
93 Evas_Object *eoErrPopup;
94 Evas_Object *eoPlaylist;
96 Elm_Object_Item *focused_item;
98 Evas_Object *eoBtnControl[TOTAL_CONTROL_BTNS];
99 Evas_Object *eoBtnEdit[TOTAL_EDIT_BTNS];
101 Evas_Object *eoAlbumCover;
102 Evas_Object *eoSlider;
103 Evas_Object *eoPressedObj;
106 Ecore_Timer *etSlider;
107 Ecore_Timer *etLongPress;
109 CMusicController *hMusicController; //! NOT NULL
112 SItemInfo *cs_itinfo;
113 SContentInfo *ctxtinfo;
116 CPlaybackView *parent;
117 CHandleVolume *pHandleVolume;
120 memset(this, 0, sizeof(SPlaybackView));
121 pHandleVolume = new CHandleVolume;
124 delete pHandleVolume;
169 Eina_Bool CPlaybackView::sm_CbUpdateSlider(void *dt)
171 SPlaybackView *m = (SPlaybackView *)dt;
172 char *timestr = NULL;
177 return ECORE_CALLBACK_CANCEL;
179 if (!m->hMusicController->GetPosition(&value)) {
181 return ECORE_CALLBACK_CANCEL;
184 duration = m->csinfo->Duration();
186 value = value + S_INCREMENT;
187 if (value > duration) {
189 return ECORE_CALLBACK_CANCEL;
192 elm_slider_value_set(m->eoSlider, value);
193 timestr = CCommonUI::TimeStrFromMilSeconds(value);
195 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
200 return ECORE_CALLBACK_RENEW;
204 Eina_Bool CPlaybackView::sm_CbLongpressTimer(void *dt)
206 SPlaybackView *m = (SPlaybackView *)dt;
208 m->parent->m_HandleOnRepeated();
210 return ECORE_CALLBACK_RENEW;
214 Eina_Bool CPlaybackView::sm_CbWaitTimer(void *dt)
216 SPlaybackView *m = (SPlaybackView *)dt;
218 m->press_status = PRESS_LONG;
219 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
220 /* Handle long press */
221 m->parent->m_PlaybackPause();
222 m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, m);
225 m->press_status = PRESS_LONG_PAUSE;
229 return ECORE_CALLBACK_CANCEL;
233 void CPlaybackView::sm_CbItemSelect(void *data, Evas_Object *obj, void *event_info)
238 void CPlaybackView::sm_CbGenlistItemCheckClicked(void *data, Elm_Object_Item *it, const char *emission, const char *source)
240 CPlaybackView *root = (CPlaybackView*)data;
242 root->m_OnGenlistItemCheckClicked(it, emission, source);
246 void CPlaybackView::m_OnGenlistItemCheckClicked(Elm_Object_Item *it, const char *emission, const char *source)
248 SItemInfo *itinfo = NULL;
250 if (!it || !emission)
253 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
255 _ERR(" no item info found ");
259 if (itinfo->edit_mode) {
260 m_UpdateItemCheck(itinfo);
261 m_DisableEditButtons(false);
266 void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
268 SPlaybackView *m = (SPlaybackView *)dt;
269 SItemInfo *itinfo = NULL;
274 if (!m->ctxtinfo || !m->ctxtinfo->context)
277 itinfo = m->parent->m_FindItemInfoFromSong(m->elInfo,
278 (CSongInfo *)m->ctxtinfo->context);
280 _ERR(" Unable to find song in the list ");
284 if (type == ACTION_TYPE_DELETE) {
285 itinfo->check_status = true;
286 m->parent->m_DeleteSelectedItems();
288 else if (type == ACTION_TYPE_PLAY) {
289 if (m->ctxtinfo->status == PLAY_STATUS_PLAY)
290 m->parent->m_KeyPausePress();
292 if (itinfo == m->cs_itinfo)
293 m->parent->m_KeyPlayPress();
295 m->parent->m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
299 _ERR(" Wrong ctxt add type in plaback view ");
303 if (!m->mgr->PopView()) {
304 _ERR("CViewMgr::PopView failed");
308 if (!m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL)) {
309 _ERR("CViewMgr::PushView failed");
313 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
317 void CPlaybackView::sm_CbCtxtClose(void *dt)
319 SPlaybackView *m = (SPlaybackView *)dt;
324 if (!m->mgr->PopView()) {
325 _ERR("CViewMgr::PopView failed");
329 if (!m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL)) {
330 _ERR("CViewMgr::PushView failed");
334 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
338 void CPlaybackView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text)
340 CPlaybackView *root = (CPlaybackView *)cookie;
342 root->m_CbCtxPopupBtnSelected(instance, text);
346 void CPlaybackView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text)
348 int type = CInfo::PlaybackSettingType();
352 m_FromPlaybackToEditMode();
356 m->hMusicController->Stop();
357 m->hMusicController->EmptyPlaylist();
358 eina_list_free(m->elInfo);
360 elm_genlist_clear(m->eoPlaylist);
361 m_UpdateEmptySongInfo();
370 void CPlaybackView::m_RemoveTimer(int timer_code)
372 ETimers timerCode = (ETimers)timer_code;
377 ecore_timer_del(m->etSlider);
384 ecore_timer_del(m->etWait);
389 case TIMER_LONGPRESS:
390 if (m->etLongPress) {
391 ecore_timer_del(m->etLongPress);
392 m->etLongPress = NULL;
397 m->pHandleVolume->RemoveTimer();
401 _ERR(" invalid value ");
407 void CPlaybackView::m_PlaybackPause(void)
409 m->hMusicController->Pause();
412 ecore_timer_freeze(m->etSlider);
416 void CPlaybackView::m_PlaybackResume(void)
418 m->hMusicController->Resume();
421 ecore_timer_thaw(m->etSlider);
425 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
427 SItemInfo *itinfo = NULL;
431 EINA_LIST_FOREACH(list, l, obj) {
432 itinfo = (SItemInfo *)obj;
433 itinfo->edit_mode = flag;
438 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
440 SItemInfo *itinfo = NULL;
444 EINA_LIST_FOREACH(list, l, obj) {
445 itinfo = (SItemInfo *)obj;
446 itinfo->check_status = false;
451 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
453 if (!pItemInfo || !pItemInfo->item)
456 elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
457 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
459 pItemInfo->select_status = true;
463 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
465 if (!pItemInfo || !pItemInfo->item)
468 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
469 MUSIC_PLAYBACK_VIEW);
471 pItemInfo->select_status = false;
475 void CPlaybackView::m_UpdateControlBtns(void)
479 state = m->hMusicController->PlayState();
480 if (state != PLAY_STATUS_STOP) {
481 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
482 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
486 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
487 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
488 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
491 if (state == PLAY_STATUS_PLAY) {
492 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
495 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
498 state = m->hMusicController->ShuffleState();
499 if (state == SHUFFLE_STATUS_OFF) {
500 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
503 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
506 state = m->hMusicController->RepeatState();
507 if (state == REPEAT_STATUS_NONE) {
508 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
510 else if (state == REPEAT_STATUS_ALL) {
511 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
514 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
519 void CPlaybackView::m_UpdateCurrentSongProgressbar(void)
522 char *timestr = NULL;
529 elm_slider_value_set(m->eoSlider, 0);
530 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
532 state = m->hMusicController->PlayState();
534 if (state == PLAY_STATUS_STOP) {
535 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
536 m_RemoveTimer(TIMER_SLIDER);
540 elm_object_disabled_set(m->eoSlider, EINA_FALSE);
542 duration = m->csinfo->Duration();
544 m_RemoveTimer(TIMER_SLIDER);
545 m->etSlider = ecore_timer_add(S_INTERVAL,
546 sm_CbUpdateSlider, m);
548 elm_slider_min_max_set(m->eoSlider, 0, duration);
549 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
551 elm_object_part_text_set(m->eoBase,
552 MUSIC_PART_FULLTIME, timestr);
556 step = (double)SLIDER_STEP / (double)duration;
557 elm_slider_step_set(m->eoSlider, step);
562 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
565 char buf[MAX_LENGTH];
567 if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
570 path = m->cs_itinfo->sinfo->ThumbnailPath();
572 elm_image_file_set(m->eoAlbumCover, path, NULL);
574 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
575 MUSIC_IMAGE_DEFAULT_THUMB_450);
576 elm_image_file_set(m->eoAlbumCover, buf, NULL);
581 void CPlaybackView::m_UpdateCurrentSongLabels(void)
583 char buf[MAX_LENGTH];
588 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
591 snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
594 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
598 void CPlaybackView::m_UpdateEmptySongInfo(void)
600 char buf[MAX_LENGTH];
602 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
603 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
604 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
605 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
606 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
607 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
608 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
609 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
610 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
611 elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
612 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
613 elm_slider_value_set(m->eoSlider, 0);
614 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
615 _(NO_PLAYLIST_MESSAGE));
616 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
617 _(NO_PLAYLIST_MESSAGE_SUB));
618 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
619 MUSIC_IMAGE_DEFAULT_THUMB_450);
620 elm_image_file_set(m->eoAlbumCover, buf, NULL);
621 m->hMusicController->SetPlayState(PLAY_STATUS_INITIAL);
625 void CPlaybackView::m_UpdateCtxtView(int playStatus)
627 if (!m->cs_itinfo || !m->ctxtinfo)
630 if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
633 if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
634 m->ctxtinfo->status = (EPlayStatus)playStatus;
637 parcel.ctxtInfo = NULL;
638 parcel.updateType = E_SONG_UPDATE;
639 parcel.layoutId = NULL;
640 parcel.keyEvent = NULL;
641 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
646 void CPlaybackView::m_UpdateCurrentSongItem(int index)
648 SItemInfo *pItemInfo = NULL;
651 m_UnselectItem(m->cs_itinfo);
652 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
655 pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
658 m->cs_itinfo = pItemInfo;
659 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
660 elm_genlist_item_bring_in(pItemInfo->item,
661 ELM_GENLIST_ITEM_SCROLLTO_IN);
664 m_SelectItem(pItemInfo);
665 m_UpdateCtxtView(PLAY_STATUS_PLAY);
671 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
673 elm_object_focus_next_object_set(m->eoPlaylist,
674 m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
675 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
676 m->eoPlaylist, ELM_FOCUS_RIGHT);
677 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnEdit[BTN_CANCEL],
682 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
684 elm_object_focus_next_object_set(m->eoSlider, m->eoPlaylist,
686 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnControl[BTN_PLAY],
688 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
689 elm_object_focus_next_object_set(m->eoPlaylist,
690 m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
691 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
692 m->eoPlaylist, ELM_FOCUS_RIGHT);
695 elm_object_focus_next_object_set(m->eoPlaylist,
696 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
697 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
698 m->eoPlaylist, ELM_FOCUS_RIGHT);
699 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
700 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
705 void CPlaybackView::m_UpdateCurrentSongInfo(void)
707 CSongInfo *sinfo = NULL;
710 if (eina_list_count(m->elInfo) == 0) {
711 m_UpdateEmptySongInfo();
715 if (!m->hMusicController->GetCurrentSongIndex(&index)) {
716 _ERR(" music get current song index failed ");
720 if (!m->hMusicController->GetSonginfoFromIndex(index, &sinfo)) {
721 _ERR(" music get songinfo failed ");
726 m_UpdateCurrentSongItem(index);
727 m_UpdateCurrentSongLabels();
728 m_UpdateCurrentSongThumbnail();
729 m_UpdateCurrentSongProgressbar();
730 m_UpdateControlBtns();
731 m_UpdatePlaymodeFocusSequence();
735 void CPlaybackView::m_DisableEditButtons(bool flag)
737 /* flag - 1 means disable edit buttons and 0 means enable */
739 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
741 elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
742 elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
744 m_UpdateEditmodeFocusSequence();
745 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
748 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
749 m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
750 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE],
751 m->eoPlaylist, ELM_FOCUS_RIGHT);
752 elm_object_focus_next_object_set(m->eoPlaylist,
753 m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
758 void CPlaybackView::m_CreateErrorPopup(void)
760 Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
762 popup = elm_popup_add(m->eoBase);
766 elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
767 evas_object_show(popup);
769 label = elm_label_add(popup);
771 evas_object_del(popup);
775 elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
776 elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
777 elm_object_content_set(popup, label);
779 btn = elm_button_add(popup);
781 evas_object_del(popup);
785 elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
786 elm_object_text_set(btn, MUSIC_TEXT_OK);
787 elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
789 m->eoErrPopup = popup;
791 Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
793 elm_object_focus_set(btn, EINA_TRUE);
799 void CPlaybackView::m_DestroyErrorPopup(void)
804 evas_object_del(m->eoErrPopup);
805 m->eoErrPopup = NULL;
809 void CPlaybackView::m_CreateSettingsPopup(void)
811 CPlaySettingCtxPopup *eoCtxPopup = new CPlaySettingCtxPopup;
812 CCtxPopup::SCallback cb;
814 cb.onSelected = sm_CbCtxPopupBtnSelected;
816 eoCtxPopup->Create(m->eoWin, &cb);
818 m->eoCtxPopup = eoCtxPopup;
822 void CPlaybackView::m_DestroySettingsPopup(void)
827 if (m->eoCtxPopup->FlagCreate())
828 m->eoCtxPopup->Destroy();
830 delete m->eoCtxPopup;
831 m->eoCtxPopup = NULL;
835 void CPlaybackView::m_FromEditToPlaybackMode(void)
837 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
838 elm_genlist_item_bring_in(m->cs_itinfo->item,
839 ELM_GENLIST_ITEM_SCROLLTO_IN);
842 m_SelectItem(m->cs_itinfo);
844 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
845 MUSIC_PLAYBACK_VIEW);
846 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
848 m_ChangeEditmodeAll(m->elInfo, false);
850 elm_genlist_realized_items_update(m->eoPlaylist);
852 m_UpdatePlaymodeFocusSequence();
856 void CPlaybackView::m_FromPlaybackToEditMode(void)
858 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_EDIT_MODE,
859 MUSIC_PLAYBACK_VIEW);
861 m_DisableEditButtons(true);
863 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
865 m_ChangeEditmodeAll(m->elInfo, true);
867 elm_genlist_realized_items_update(m->eoPlaylist);
869 m_UpdateEditmodeFocusSequence();
873 void CPlaybackView::m_HandleOnRepeated(void)
875 Evas_Object *obj = NULL;
878 char *timestr = NULL;
880 if (!m->eoPressedObj)
883 obj = m->eoPressedObj;
885 value = elm_slider_value_get(m->eoSlider);
886 duration = m->cs_itinfo->sinfo->Duration();
888 if (obj == m->eoBtnControl[BTN_REWIND]) {
890 m_RemoveTimer(TIMER_LONGPRESS);
893 value = value - LP_CHANGE;
898 if (value == duration) {
899 if (m->hMusicController->PlayNextSong())
900 m_UpdateCurrentSongInfo();
902 _ERR(" music play next song failed ");
904 m->press_status = PRESS_LONG_PAUSE;
905 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE,
906 MUSIC_PLAYBACK_VIEW);
908 m_RemoveTimer(TIMER_LONGPRESS);
912 value = value + LP_CHANGE;
913 if (value >= duration)
917 m->hMusicController->SetPosition(value);
918 elm_slider_value_set(m->eoSlider, value);
919 timestr = CCommonUI::TimeStrFromMilSeconds(value);
921 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
930 void CPlaybackView::m_DeleteSelectedItems(void)
932 Eina_List *l = NULL, *l_next = NULL;
933 SItemInfo *pItemInfo = NULL;
938 m_DisableEditButtons(true);
939 EINA_LIST_FOREACH_SAFE(m->elInfo, l, l_next, obj) {
940 pItemInfo = (SItemInfo *)obj;
941 if (pItemInfo->check_status) {
942 if (m->cs_itinfo == pItemInfo) {
944 m_UnselectItem(m->cs_itinfo);
945 m_RemoveTimer(TIMER_SLIDER);
947 m->hMusicController->SetPlayState(PLAY_STATUS_STOP);
948 m->hMusicController->Stop();
950 index = elm_genlist_item_index_get(pItemInfo->item);
951 m->hMusicController->RemoveSong(pItemInfo->sinfo, index);
953 m->elInfo = eina_list_remove(m->elInfo,
955 elm_object_item_del(pItemInfo->item);
959 if (eina_list_count(m->elInfo) == 0) {
960 m_UpdateEmptySongInfo();
961 elm_genlist_realized_items_update(m->eoPlaylist);
962 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
967 m_UpdateCurrentSongInfo();
969 elm_genlist_realized_items_update(m->eoPlaylist);
970 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
974 void CPlaybackView::m_KeyBackPress(void)
977 m_DestroySettingsPopup();
978 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_FALSE);
979 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
984 m->mgr->PushView(MUSIC_BASE_VIEW, NULL);
988 void CPlaybackView::m_KeyExitPress(void)
990 m_RemoveTimer(TIMER_SLIDER);
991 m->hMusicController->Stop();
996 void CPlaybackView::m_KeyPlayPress(void)
1000 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1003 state = m->hMusicController->PlayState();
1004 if (state == PLAY_STATUS_PAUSE) {
1006 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1007 MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1009 else if (state != PLAY_STATUS_PLAY) {
1010 if (m->hMusicController)
1011 m->hMusicController->Start();
1013 m_UpdateCurrentSongInfo();
1018 void CPlaybackView::m_KeyPausePress(void)
1022 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1025 state = m->hMusicController->PlayState();
1026 if (state == PLAY_STATUS_PLAY) {
1027 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1028 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1034 void CPlaybackView::m_KeyNextPress(void)
1036 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1039 m_HandleOnPressed(m->eoBtnControl[BTN_FORWARD]);
1043 void CPlaybackView::m_KeyPreviousPress(void)
1045 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1048 m_HandleOnPressed(m->eoBtnControl[BTN_REWIND]);
1052 void CPlaybackView::m_KeyNextUnpress(void)
1054 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1057 m_HandleOnUnpressed(m->eoBtnControl[BTN_FORWARD]);
1061 void CPlaybackView::m_KeyPreviousUnpress(void)
1063 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1066 m_HandleOnUnpressed(m->eoBtnControl[BTN_REWIND]);
1070 void CPlaybackView::m_HandleKeyPress(char *keyname)
1072 if (!strcmp(keyname, (char *)KEY_EXIT))
1074 else if (!strcmp(keyname, (char *)KEY_BACK) ||
1075 !strcmp(keyname, (char *)KEY_BACK_REMOTE))
1077 else if (!strcmp(keyname, (char *)KEY_PLAY))
1079 else if (!strcmp(keyname, (char *)KEY_PAUSE))
1081 else if (!strcmp(keyname, (char *)KEY_NEXT))
1083 else if (!strcmp(keyname, (char *)KEY_PREVIOUS))
1084 m_KeyPreviousPress();
1085 else if (!strcmp(keyname, (char *)KEY_VOLUMEUP))
1086 m->pHandleVolume->Up();
1087 else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN))
1088 m->pHandleVolume->Down();
1089 else if (!strcmp(keyname, (char *)KEY_MUTE))
1090 m->pHandleVolume->Mute();
1094 void CPlaybackView::m_HandleKeyUnpress(char *keyname)
1096 if (!strcmp(keyname, KEY_PREVIOUS))
1097 m_KeyPreviousUnpress();
1098 else if (!strcmp(keyname, KEY_NEXT))
1103 void CPlaybackView::m_AddSlider(void)
1105 Evas_Object *eoSlider = NULL;
1107 eoSlider = elm_slider_add(m->eoBase);
1111 elm_slider_indicator_show_set(eoSlider, EINA_FALSE);
1112 elm_slider_indicator_show_on_focus_set(eoSlider, EINA_FALSE);
1113 elm_object_style_set(eoSlider, MUSIC_STYLE_SLIDER);
1114 elm_slider_horizontal_set(eoSlider, EINA_TRUE);
1115 elm_object_part_content_set(m->eoBase, MUSIC_PART_PROGRESSBAR, eoSlider);
1117 Connect(eoSlider, EO_SLIDER, TYPE_CHANGED | TYPE_MOUSE_MOVE);
1119 evas_object_show(eoSlider);
1120 m->eoSlider = eoSlider;
1124 void CPlaybackView::m_AddAlbumCover(void)
1126 Evas_Object *eoAlbumCover = NULL;
1128 eoAlbumCover = elm_image_add(m->eoBase);
1132 evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
1134 elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
1136 elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
1138 evas_object_show(eoAlbumCover);
1139 m->eoAlbumCover = eoAlbumCover;
1144 void CPlaybackView::m_AddCurrentSonginfo(void)
1151 void CPlaybackView::m_AddEditPlaylistButtons(void)
1153 Evas_Object *box = NULL;
1155 SBtnInfo btninfo[TOTAL_EDIT_BTNS];
1157 btninfo[BTN_CANCEL].txt = MUSIC_TEXT_CANCEL;
1158 btninfo[BTN_CANCEL].type = EO_CANCEL;
1160 btninfo[BTN_DESELECT].txt = MUSIC_TEXT_DESELECT;
1161 btninfo[BTN_DESELECT].type = EO_DESELECT;
1163 btninfo[BTN_DELETE].txt = MUSIC_TEXT_DELETE;
1164 btninfo[BTN_DELETE].type = EO_DELETE;
1166 box = CCommonUI::AddBox(m->eoBase);
1170 elm_box_horizontal_set(box, EINA_TRUE);
1171 elm_box_padding_set(box,
1172 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
1174 for (i = 0; i < TOTAL_EDIT_BTNS; i++) {
1175 m->eoBtnEdit[i] = elm_button_add(m->eoBase);
1176 if (!m->eoBtnEdit[i])
1179 elm_object_style_set(m->eoBtnEdit[i],
1180 MUSIC_STYLE_EDIT_BTN);
1181 evas_object_size_hint_weight_set(m->eoBtnEdit[i],
1182 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1183 elm_box_pack_end(box, m->eoBtnEdit[i]);
1184 elm_object_text_set(m->eoBtnEdit[i], _(btninfo[i].txt));
1186 Connect(m->eoBtnEdit[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1188 evas_object_show(m->eoBtnEdit[i]);
1190 elm_object_part_content_set(m->eoBase, MUSIC_PART_EDITBTNS, box);
1191 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
1192 MUSIC_PLAYBACK_VIEW);
1196 void CPlaybackView::m_AddControlButtons(void)
1198 Evas_Object *box = NULL;
1200 SBtnInfo btninfo[TOTAL_CONTROL_BTNS];
1202 btninfo[BTN_SETTINGS].txt = MUSIC_STYLE_BTN_SETTINGS;
1203 btninfo[BTN_SETTINGS].type = EO_BTN_SETTINGS;
1205 btninfo[BTN_SHUFFLE].txt = MUSIC_STYLE_BTN_SHUFFLE;
1206 btninfo[BTN_SHUFFLE].type = EO_BTN_SHUFFLE;
1208 btninfo[BTN_REPEAT].txt = MUSIC_STYLE_BTN_REPEAT;
1209 btninfo[BTN_REPEAT].type = EO_BTN_REPEAT;
1211 btninfo[BTN_REWIND].txt = MUSIC_STYLE_BTN_REWIND;
1212 btninfo[BTN_REWIND].type = EO_BTN_REWIND;
1214 btninfo[BTN_PLAY].txt = MUSIC_STYLE_BTN_PLAY;
1215 btninfo[BTN_PLAY].type = EO_BTN_PLAY;
1217 btninfo[BTN_FORWARD].txt = MUSIC_STYLE_BTN_FORWARD;
1218 btninfo[BTN_FORWARD].type = EO_BTN_FORWARD;
1220 box = elm_box_add(m->eoBase);
1224 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
1225 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
1226 elm_box_horizontal_set(box, EINA_TRUE);
1227 elm_box_padding_set(box,
1228 MUSIC_CONTROL_BTNS_PADDING * elm_config_scale_get(), 0);
1230 for (i = 0; i < TOTAL_CONTROL_BTNS; i++) {
1231 m->eoBtnControl[i] = elm_button_add(m->eoBase);
1232 if (!m->eoBtnControl[i])
1235 elm_object_style_set(m->eoBtnControl[i], btninfo[i].txt);
1236 evas_object_size_hint_weight_set(m->eoBtnControl[i],
1237 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1238 elm_box_pack_end(box, m->eoBtnControl[i]);
1240 if (i == BTN_REWIND || i == BTN_FORWARD) {
1241 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_PRESSED | TYPE_UNPRESSED | TYPE_MOUSE_MOVE);
1244 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1246 evas_object_show(m->eoBtnControl[i]);
1249 elm_object_part_content_set(m->eoBase, MUSIC_PART_CONTROLBTNS, box);
1253 SItemInfo *CPlaybackView::m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo)
1255 Eina_List *l = NULL;
1256 SItemInfo *itinfo = NULL;
1259 EINA_LIST_FOREACH(list, l, obj) {
1260 itinfo = (SItemInfo *)obj;
1261 if (itinfo->sinfo == sinfo)
1269 SItemInfo *CPlaybackView::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
1271 Eina_List *l = NULL;
1272 SItemInfo *itinfo = NULL;
1275 EINA_LIST_FOREACH(list, l, obj) {
1276 itinfo = (SItemInfo *)obj;
1277 if (itinfo->item == item)
1285 void CPlaybackView::m_UpdateItemCheck(SItemInfo *itinfo)
1288 _ERR(" No item info to Update check ");
1292 if (itinfo->check_status) {
1293 elm_object_item_signal_emit(itinfo->item,
1294 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1295 itinfo->check_status = false;
1299 elm_object_item_signal_emit(itinfo->item,
1300 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
1301 itinfo->check_status = true;
1305 class CElmGenlistItemClass {
1307 static char *sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
1309 CSongInfo *sinfo = NULL;
1310 SItemInfo *pItemInfo = (SItemInfo *)data;
1311 char buf[MAX_LENGTH];
1312 char *timestr = NULL;
1316 if (!pItemInfo || !obj)
1319 sinfo = pItemInfo->sinfo;
1321 snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY);
1323 if (!strcmp(part, "elm.text0")) {
1324 index = elm_genlist_item_index_get(pItemInfo->item);
1325 snprintf(buf, sizeof(buf), "%d", index);
1326 if ((index & 1) == 1) {
1327 elm_object_item_signal_emit(pItemInfo->item,
1328 MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW);
1331 elm_object_item_signal_emit(pItemInfo->item,
1332 MUSIC_SIGNAL_ODD_ROW, MUSIC_PLAYBACK_VIEW);
1335 else if (!strcmp(part, "elm.text1"))
1336 snprintf(buf, sizeof(buf), "%s", sinfo->Name());
1337 else if (!strcmp(part, "elm.text2"))
1338 snprintf(buf, sizeof(buf), "%s - %s",
1341 else if (!strcmp(part, "elm.text3")) {
1342 duration = sinfo->Duration();
1343 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
1345 snprintf(buf, sizeof(buf), "%s", timestr);
1350 if (strcmp(buf, MUSIC_STR_EMPTY))
1355 static Evas_Object *sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
1357 CSongInfo *sinfo = NULL;
1358 SItemInfo *pItemInfo = (SItemInfo *)data;
1359 Evas_Object *img = NULL;
1361 char buf[MAX_LENGTH];
1363 if (!pItemInfo || !obj)
1366 sinfo = pItemInfo->sinfo;
1368 img = elm_image_add(obj);
1372 elm_image_aspect_fixed_set(img, EINA_FALSE);
1374 if (!strcmp(part, "elm.swallow.icon")) {
1375 path = sinfo->ThumbnailPath();
1377 elm_image_file_set(img, path, "NULL");
1379 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
1380 MUSIC_IMAGE_DEFAULT_THUMB_126);
1381 elm_image_file_set(img, buf, "NULL");
1385 if (pItemInfo->select_status) {
1386 elm_object_item_signal_emit(pItemInfo->item,
1387 MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
1390 elm_object_item_signal_emit(pItemInfo->item,
1391 MUSIC_SIGNAL_UNSELECT_ITEM,
1392 MUSIC_PLAYBACK_VIEW);
1395 if (pItemInfo->edit_mode) {
1396 elm_object_item_signal_emit(pItemInfo->item,
1397 MUSIC_SIGNAL_EDITMODE_ON, MUSIC_PLAYBACK_VIEW);
1398 if (pItemInfo->check_status) {
1399 elm_object_item_signal_emit(pItemInfo->item,
1400 MUSIC_SIGNAL_CHECK_ON,
1401 MUSIC_PLAYBACK_VIEW);
1404 elm_object_item_signal_emit(pItemInfo->item,
1405 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1409 elm_object_item_signal_emit(pItemInfo->item,
1410 MUSIC_SIGNAL_EDITMODE_OFF, MUSIC_PLAYBACK_VIEW);
1416 static void sm_CbDel(void *data, Evas_Object *obj)
1423 Elm_Genlist_Item_Class *CPlaybackView::m_GetItemClass(void)
1425 Elm_Genlist_Item_Class *list_item = NULL;
1427 list_item = elm_genlist_item_class_new();
1429 _ERR(" elm_genlist_item_class_new failed ");
1433 list_item->item_style = MUSIC_STYLE_PLAYLIST;
1434 list_item->func.text_get = CElmGenlistItemClass::sm_CbTextGet;
1435 list_item->func.content_get = CElmGenlistItemClass::sm_CbContentGet;
1436 list_item->func.state_get = NULL;
1437 list_item->func.del = CElmGenlistItemClass::sm_CbDel;
1443 void CPlaybackView::m_AddGenlist(void)
1445 Evas_Object *genlist = NULL;
1446 Evas_Object *eoBase = NULL;
1449 genlist = elm_genlist_add(eoBase);
1453 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1454 evas_object_size_hint_weight_set(genlist,
1455 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1456 elm_object_part_content_set(eoBase, MUSIC_PART_PLAYLIST, genlist);
1457 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
1458 elm_genlist_multi_select_set(genlist, EINA_FALSE);
1460 Connect(genlist, EO_PLAYLIST, TYPE_REALIZED | TYPE_UNREALIZED | TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_ACTIVATED);
1462 evas_object_show(genlist);
1463 m->eoPlaylist = genlist;
1467 void CPlaybackView::m_AddPlaylist(void)
1469 Elm_Genlist_Item_Class *list_item = NULL;
1472 CSongInfo *sinfo = NULL;
1473 Elm_Object_Item *item = NULL;
1474 SItemInfo *pItemInfo = NULL;
1480 list_item = m_GetItemClass();
1482 evas_object_del(m->eoPlaylist);
1486 if (!m->hMusicController->GetTotalSongs(&ts)) {
1487 _ERR(" music get total songs failed ");
1491 if (!m->hMusicController->GetCurrentSongIndex(&index))
1492 _ERR(" music get current song index failed ");
1494 for (i = 0; i < ts; i++) {
1495 if (!m->hMusicController->GetSonginfoFromIndex(i, &sinfo)) {
1496 _ERR(" music get songinfo failed ");
1499 pItemInfo = (SItemInfo *)calloc(1, sizeof(*pItemInfo));
1502 pItemInfo->sinfo = sinfo;
1503 pItemInfo->edit_mode = false;
1504 pItemInfo->check_status = false;
1505 pItemInfo->select_status = false;
1507 item = elm_genlist_item_append(m->eoPlaylist, list_item,
1508 pItemInfo, NULL, ELM_GENLIST_ITEM_NONE,
1509 sm_CbItemSelect, m);
1510 pItemInfo->item = item;
1513 pItemInfo->select_status = true;
1514 m->cs_itinfo = pItemInfo;
1516 m->elInfo = eina_list_append(m->elInfo, pItemInfo);
1521 void CPlaybackView::m_RemovePlaylist(void)
1523 if (m->eoPlaylist) {
1524 elm_genlist_clear(m->eoPlaylist);
1525 m->eoPlaylist = NULL;
1529 eina_list_free(m->elInfo);
1535 void CPlaybackView::m_HandleRewindBtnClicked(Evas_Object *obj)
1537 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1538 MUSIC_PLAYBACK_VIEW);
1540 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1543 if (!m->hMusicController->PlayPreviousSong()){
1544 _ERR(" music play previous song failed ");
1548 m_UpdateCurrentSongInfo();
1552 void CPlaybackView::m_HandleForwardBtnClicked(Evas_Object *obj)
1554 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1555 MUSIC_PLAYBACK_VIEW);
1557 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1560 if (!m->hMusicController->PlayNextSong()) {
1561 _ERR(" music play next song failed ");
1565 m_UpdateCurrentSongInfo();
1569 void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
1571 m->press_status = PRESS_SHORT;
1572 m->eoPressedObj = obj;
1574 m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, m);
1578 void CPlaybackView::m_HandleOnUnpressed(Evas_Object *obj)
1580 m_RemoveTimer(TIMER_WAIT);
1581 m_RemoveTimer(TIMER_LONGPRESS);
1583 if (m->press_status == PRESS_SHORT) {
1584 /* Handle song change */
1585 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY)
1588 if (obj == m->eoBtnControl[BTN_FORWARD])
1589 m_HandleForwardBtnClicked(obj);
1591 m_HandleRewindBtnClicked(obj);
1593 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1596 else if (m->press_status == PRESS_LONG) {
1597 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1601 m->press_status = PRESS_SHORT;
1605 void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_Item *genListItem)
1608 SItemInfo *itinfo = NULL;
1610 if (!obj || !genListItem)
1613 itinfo = m_FindItemInfoFromItem(m->elInfo, genListItem);
1615 _ERR(" no item info found ");
1619 if (itinfo->edit_mode) {
1620 m_UpdateItemCheck(itinfo);
1621 m_DisableEditButtons(false);
1625 index = elm_genlist_item_index_get(genListItem);
1627 m->hMusicController->PlayIndexSong(--index);
1628 m_UpdateCurrentSongInfo();
1632 bool CPlaybackView::Create(void *data)
1637 _CHECK(m = new SPlaybackView)
1638 _CHECK(m->mgr = CViewMgr::GetInstance())
1639 _CHECK(m->eoWin = m->mgr->Window())
1640 _CHECK(m->hMusicController = CMusicController::GetInstance())
1641 _CHECK(m->eoBase = CCommonUI::AddBase(m->eoWin, MUSIC_PLAYBACK_VIEW))
1642 _CHECK(CBaseView::Create(data))
1644 _CHECK_FAIL{ CBaseView::Destroy(); }
1645 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1646 _CHECK_FAIL{ /* CMusicController::GetInstance())*/ }
1647 _CHECK_FAIL{ /* mgr->Window() */ }
1648 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1649 _CHECK_FAIL{ delete m; m = NULL; }
1650 }_CREATE_END_AND_CATCH{ return false; }
1652 m->press_status = PRESS_SHORT;
1655 evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1657 m_AddControlButtons();
1658 m_AddEditPlaylistButtons();
1659 m_AddCurrentSonginfo();
1662 m->pHandleVolume->Create(m->eoBase);
1663 m_UpdatePlaymodeFocusSequence();
1665 Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1667 m->hMusicController->AddListener(this);
1673 void CPlaybackView::Destroy(void)
1677 m->hMusicController->RemoveListener(this);
1679 m_DestroyErrorPopup();
1681 m_RemoveTimer(TIMER_SLIDER);
1682 m_RemoveTimer(TIMER_WAIT);
1683 m_RemoveTimer(TIMER_LONGPRESS);
1684 m_DestroySettingsPopup();
1686 m->pHandleVolume->Destroy();
1687 CBaseView::Destroy();
1688 evas_object_del(m->eoBase);
1696 Evas_Object* CPlaybackView::Base(void)
1704 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1706 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1708 if (eina_list_count(m->elInfo) == 0)
1711 elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1712 m_DestroySettingsPopup();
1713 m_CreateSettingsPopup();
1717 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1719 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1721 switch (m->hMusicController->ShuffleState()) {
1722 case SHUFFLE_STATUS_OFF:
1723 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_ON);
1724 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1728 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_OFF);
1729 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1735 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1737 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1739 switch (m->hMusicController->RepeatState()) {
1740 case REPEAT_STATUS_NONE:
1741 m->hMusicController->SetRepeatState(REPEAT_STATUS_ALL);
1742 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1745 case REPEAT_STATUS_ALL:
1746 m->hMusicController->SetRepeatState(REPEAT_STATUS_ONE);
1747 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1751 m->hMusicController->SetRepeatState(REPEAT_STATUS_NONE);
1752 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1758 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1760 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1762 switch (m->hMusicController->PlayState()) {
1763 case PLAY_STATUS_PAUSE:
1765 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1768 case PLAY_STATUS_PLAY:
1769 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1774 if (m->hMusicController)
1775 m->hMusicController->Start();
1776 m_UpdateCurrentSongInfo();
1782 void CPlaybackView::t_OnShow(void)
1789 elm_genlist_item_show(m->cs_itinfo->item,
1790 ELM_GENLIST_ITEM_SCROLLTO_IN);
1791 elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
1794 state = m->hMusicController->PlayState();
1795 if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
1798 m->hMusicController->Start();
1799 m_UpdateCurrentSongInfo();
1802 evas_object_show(m->eoBase);
1806 void CPlaybackView::t_OnUpdate(void *data)
1813 SParcel *parcel = (SParcel *)data;
1814 int updateType = parcel->updateType;
1815 char *key = (char *)parcel->keyEvent;
1817 switch (updateType) {
1818 case E_PLAYLIST_UPDATE:
1821 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
1822 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
1823 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
1824 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
1825 m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
1826 m_FromEditToPlaybackMode();
1830 m_HandleKeyPress(key);
1834 m_HandleKeyUnpress(key);
1843 void CPlaybackView::t_OnHide(void)
1847 evas_object_hide(m->eoBase);
1851 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
1855 m_HandleKeyPress(ev->keyname);
1858 case EO_ERROR_POPUP_BUTTON:
1859 if (!strcmp(ev->keyname, KEY_BACK) ||
1860 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1861 m_DestroyErrorPopup();
1862 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1868 Elm_Object_Item *it = NULL;
1869 SContentInfo *ctxtinfo = NULL;
1870 SItemInfo *itinfo = NULL;
1872 if (strcmp(ev->keyname, KEY_MENU) &&
1873 strcmp(ev->keyname, KEY_MENU_REMOTE))
1876 it = elm_object_focused_item_get(obj);
1878 _ERR(" unable to get focused item ");
1881 m->focused_item = it;
1888 ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
1892 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
1898 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY &&
1899 itinfo == m->cs_itinfo)
1900 ctxtinfo->status = PLAY_STATUS_PLAY;
1902 ctxtinfo->status = PLAY_STATUS_PAUSE;
1904 ctxtinfo->cbdata = m;
1905 ctxtinfo->update = sm_CbCtxtUpdate;
1906 ctxtinfo->close = sm_CbCtxtClose;
1907 ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
1908 ctxtinfo->context = itinfo->sinfo;
1910 m->ctxtinfo = ctxtinfo;
1913 parcel.ctxtInfo = ctxtinfo;
1914 if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
1915 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
1919 if (!strcmp(ev->keyname, KEY_BACK) ||
1920 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1921 _ERR("eoCtxPopup BACK key pressed ");
1922 m_DestroySettingsPopup();
1923 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1926 else if (!strcmp(ev->keyname, KEY_EXIT)) {
1927 _ERR("eoCtxPopup EXIT key pressed ");
1928 m_DestroySettingsPopup();
1929 m_RemoveTimer(TIMER_SLIDER);
1930 m->hMusicController->Stop();
1941 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
1945 m_HandleKeyUnpress(ev->keyname);
1954 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
1957 case EO_ERROR_POPUP_BUTTON:
1958 m_DestroyErrorPopup();
1959 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1963 m_DisableCheckAll(m->elInfo);
1964 m_DisableEditButtons(true);
1965 m_FromEditToPlaybackMode();
1969 m_DisableCheckAll(m->elInfo);
1970 m_DisableEditButtons(true);
1971 elm_genlist_realized_items_update(m->eoPlaylist);
1972 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1976 m_DeleteSelectedItems();
1979 case EO_BTN_SETTINGS:
1980 t_OnClickedSettings(obj);
1983 case EO_BTN_SHUFFLE:
1984 t_OnClickedShuffle(obj);
1988 t_OnClickedRepeat(obj);
1992 t_OnClickedPlay(obj);
2001 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
2008 case EO_BTN_FORWARD:
2012 case EO_BTN_SETTINGS:
2013 case EO_BTN_SHUFFLE:
2014 if (!elm_object_focus_get(obj))
2015 elm_object_focus_set(obj, EINA_TRUE);
2020 Elm_Object_Item *item;
2022 item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
2023 ev->cur.canvas.y, NULL);
2027 if (!elm_object_item_focus_get(item))
2028 elm_object_item_focus_set(item, EINA_TRUE);
2038 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2041 case EO_BTN_FORWARD:
2043 m_HandleOnPressed(obj);
2052 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2055 case EO_BTN_FORWARD:
2057 m_HandleOnUnpressed(obj);
2066 void CPlaybackView::OnChanged(int id, Evas_Object *obj)
2071 char *timestr = NULL;
2074 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2076 ecore_timer_freeze(m->etSlider);
2079 value = elm_slider_value_get(obj);
2080 m->hMusicController->SetPosition(value);
2081 timestr = CCommonUI::TimeStrFromMilSeconds(value);
2083 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
2088 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2090 ecore_timer_thaw(m->etSlider);
2101 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2105 elm_object_item_signal_callback_add(item,
2106 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2107 sm_CbGenlistItemCheckClicked, this);
2116 void CPlaybackView::OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2120 elm_object_item_signal_callback_del(item,
2121 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2122 sm_CbGenlistItemCheckClicked);
2131 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2135 m_HandleGenlistItemActivated(obj, item);
2144 void CPlaybackView::t_OnComplete(void)
2146 m_UpdateCurrentSongInfo();
2150 void CPlaybackView::t_OnError(void)
2152 m_CreateErrorPopup();
2156 void CPlaybackView::t_OnUsbConnected(void)
2161 void CPlaybackView::t_OnUpdateContent(void)