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 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 CPlaybackView *root = (CPlaybackView *)dt;
206 root->m_OnLongpressTimer();
208 return ECORE_CALLBACK_RENEW;
212 void CPlaybackView::m_OnLongpressTimer(void)
214 m_HandleOnRepeated();
218 Eina_Bool CPlaybackView::sm_CbWaitTimer(void *dt)
220 CPlaybackView *root = (CPlaybackView *)dt;
222 root->m_OnWaitTimer();
224 return ECORE_CALLBACK_CANCEL;
228 void CPlaybackView::m_OnWaitTimer(void)
230 m->press_status = PRESS_LONG;
231 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
232 /* Handle long press */
234 m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, this);
237 m->press_status = PRESS_LONG_PAUSE;
244 void CPlaybackView::sm_CbItemSelect(void *data, Evas_Object *obj, void *event_info)
249 void CPlaybackView::sm_CbGenlistItemCheckClicked(void *data, Elm_Object_Item *it, const char *emission, const char *source)
251 CPlaybackView *root = (CPlaybackView*)data;
253 root->m_OnGenlistItemCheckClicked(it, emission, source);
257 void CPlaybackView::m_OnGenlistItemCheckClicked(Elm_Object_Item *it, const char *emission, const char *source)
259 SItemInfo *itinfo = NULL;
261 if (!it || !emission)
264 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
266 _ERR(" no item info found ");
270 if (itinfo->edit_mode) {
271 m_UpdateItemCheck(itinfo);
272 m_DisableEditButtons(false);
277 void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
279 CPlaybackView *root = (CPlaybackView *)dt;
281 root->m_OnCtxtUpdate(type, lid);
285 void CPlaybackView::m_OnCtxtUpdate(EActionType type, int lid)
287 SItemInfo *itinfo = NULL;
288 Elm_Object_Item *focusedItem = NULL;
290 if (!m->ctxtinfo || !m->ctxtinfo->context)
293 itinfo = m_FindItemInfoFromSong(m->elInfo,
294 (CSongInfo *)m->ctxtinfo->context);
296 _ERR(" Unable to find song in the list ");
300 if (type == ACTION_TYPE_DELETE) {
301 itinfo->check_status = true;
302 m_DeleteSelectedItems();
304 if (!m->mgr->PopView()) {
305 _ERR("CViewMgr::PopView failed");
310 memset(&parcel, 0, sizeof(SParcel));
311 parcel.updateType = E_PLAYLIST_UPDATE;
314 focusedItem = m->cs_itinfo->item;
316 else { // ACTION_TYPE_PLAY
317 if (m->ctxtinfo->status == PLAY_STATUS_PLAY)
320 if (itinfo == m->cs_itinfo)
323 m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
326 if (!m->mgr->PopView()) {
327 _ERR("CViewMgr::PopView failed");
331 focusedItem = m->focused_item;
335 elm_genlist_item_show(focusedItem, ELM_GENLIST_ITEM_SCROLLTO_IN);
336 elm_object_item_focus_set(focusedItem, EINA_TRUE);
341 void CPlaybackView::sm_CbCtxtClose(void *dt)
343 CPlaybackView *root = (CPlaybackView *)dt;
345 root->m_OnCtxtClose();
349 void CPlaybackView::m_OnCtxtClose(void)
351 if (!m->mgr->PopView()) {
352 _ERR("CViewMgr::PopView failed");
356 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
360 void CPlaybackView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text)
362 CPlaybackView *root = (CPlaybackView *)cookie;
364 root->m_CbCtxPopupBtnSelected(instance, text);
368 void CPlaybackView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text)
370 int type = CInfo::PlaybackSettingType();
374 m_FromPlaybackToEditMode();
378 m->hMusicController->Stop();
379 m->hMusicController->EmptyPlaylist();
380 eina_list_free(m->elInfo);
382 elm_genlist_clear(m->eoPlaylist);
383 m_UpdateEmptySongInfo();
392 void CPlaybackView::m_RemoveTimer(int timer_code)
394 ETimers timerCode = (ETimers)timer_code;
399 ecore_timer_del(m->etSlider);
406 ecore_timer_del(m->etWait);
411 case TIMER_LONGPRESS:
412 if (m->etLongPress) {
413 ecore_timer_del(m->etLongPress);
414 m->etLongPress = NULL;
419 m->pHandleVolume->RemoveTimer();
423 _ERR(" invalid value ");
429 void CPlaybackView::m_PlaybackPause(void)
431 m->hMusicController->Pause();
434 ecore_timer_freeze(m->etSlider);
438 void CPlaybackView::m_PlaybackResume(void)
440 m->hMusicController->Resume();
443 ecore_timer_thaw(m->etSlider);
447 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
449 SItemInfo *itinfo = NULL;
453 EINA_LIST_FOREACH(list, l, obj) {
454 itinfo = (SItemInfo *)obj;
455 itinfo->edit_mode = flag;
460 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
462 SItemInfo *itinfo = NULL;
466 EINA_LIST_FOREACH(list, l, obj) {
467 itinfo = (SItemInfo *)obj;
468 itinfo->check_status = false;
473 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
475 if (!pItemInfo || !pItemInfo->item)
478 elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
479 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
481 pItemInfo->select_status = true;
485 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
487 if (!pItemInfo || !pItemInfo->item)
490 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
491 MUSIC_PLAYBACK_VIEW);
493 pItemInfo->select_status = false;
497 void CPlaybackView::m_UpdateControlBtns(void)
501 state = m->hMusicController->PlayState();
502 if (state != PLAY_STATUS_STOP) {
503 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
504 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
508 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
509 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
510 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
513 if (state == PLAY_STATUS_PLAY) {
514 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
517 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
520 state = m->hMusicController->ShuffleState();
521 if (state == SHUFFLE_STATUS_OFF) {
522 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
525 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
528 state = m->hMusicController->RepeatState();
529 if (state == REPEAT_STATUS_NONE) {
530 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
532 else if (state == REPEAT_STATUS_ALL) {
533 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
536 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
541 void CPlaybackView::m_UpdateCurrentSongProgressbar(void)
544 char *timestr = NULL;
551 elm_slider_value_set(m->eoSlider, 0);
552 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
554 state = m->hMusicController->PlayState();
556 if (state == PLAY_STATUS_STOP) {
557 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
558 m_RemoveTimer(TIMER_SLIDER);
562 elm_object_disabled_set(m->eoSlider, EINA_FALSE);
564 duration = m->csinfo->Duration();
566 m_RemoveTimer(TIMER_SLIDER);
567 m->etSlider = ecore_timer_add(S_INTERVAL,
568 sm_CbUpdateSlider, m);
570 elm_slider_min_max_set(m->eoSlider, 0, duration);
571 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
573 elm_object_part_text_set(m->eoBase,
574 MUSIC_PART_FULLTIME, timestr);
578 step = (double)SLIDER_STEP / (double)duration;
579 elm_slider_step_set(m->eoSlider, step);
584 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
587 char buf[MAX_LENGTH];
589 if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
592 path = m->cs_itinfo->sinfo->ThumbnailPath();
594 elm_image_file_set(m->eoAlbumCover, path, NULL);
596 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
597 MUSIC_IMAGE_DEFAULT_THUMB_450);
598 elm_image_file_set(m->eoAlbumCover, buf, NULL);
603 void CPlaybackView::m_UpdateCurrentSongLabels(void)
605 char buf[MAX_LENGTH];
610 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
613 snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
616 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
620 void CPlaybackView::m_UpdateEmptySongInfo(void)
622 char buf[MAX_LENGTH];
624 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
625 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
626 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
627 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
628 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
629 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
630 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
631 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
632 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
633 elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
634 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
635 elm_slider_value_set(m->eoSlider, 0);
636 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
637 _(NO_PLAYLIST_MESSAGE));
638 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
639 _(NO_PLAYLIST_MESSAGE_SUB));
640 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
641 MUSIC_IMAGE_DEFAULT_THUMB_450);
642 elm_image_file_set(m->eoAlbumCover, buf, NULL);
643 m->hMusicController->SetPlayState(PLAY_STATUS_INITIAL);
647 void CPlaybackView::m_UpdateCtxtView(int playStatus)
649 if (!m->cs_itinfo || !m->ctxtinfo)
652 if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
655 if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
656 m->ctxtinfo->status = (EPlayStatus)playStatus;
659 memset(&parcel, 0, sizeof(SParcel));
660 parcel.updateType = E_SONG_UPDATE;
661 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
666 void CPlaybackView::m_UpdateCurrentSongItem(int index)
668 SItemInfo *pItemInfo = NULL;
671 m_UnselectItem(m->cs_itinfo);
672 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
675 pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
678 m->cs_itinfo = pItemInfo;
679 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
680 elm_genlist_item_bring_in(pItemInfo->item,
681 ELM_GENLIST_ITEM_SCROLLTO_IN);
684 m_SelectItem(pItemInfo);
685 m_UpdateCtxtView(PLAY_STATUS_PLAY);
691 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
693 elm_object_focus_next_object_set(m->eoPlaylist,
694 m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
695 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
696 m->eoPlaylist, ELM_FOCUS_RIGHT);
697 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnEdit[BTN_CANCEL],
702 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
704 elm_object_focus_next_object_set(m->eoSlider, m->eoPlaylist,
706 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnControl[BTN_PLAY],
708 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
709 elm_object_focus_next_object_set(m->eoPlaylist,
710 m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
711 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
712 m->eoPlaylist, ELM_FOCUS_RIGHT);
715 elm_object_focus_next_object_set(m->eoPlaylist,
716 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
717 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
718 m->eoPlaylist, ELM_FOCUS_RIGHT);
719 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
720 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
725 void CPlaybackView::m_UpdateCurrentSongInfo(void)
727 CSongInfo *sinfo = NULL;
730 if (eina_list_count(m->elInfo) == 0) {
731 m_UpdateEmptySongInfo();
735 if (!m->hMusicController->GetCurrentSongIndex(&index)) {
736 _ERR(" music get current song index failed ");
740 if (!m->hMusicController->GetSonginfoFromIndex(index, &sinfo)) {
741 _ERR(" music get songinfo failed ");
746 m_UpdateCurrentSongItem(index);
747 m_UpdateCurrentSongLabels();
748 m_UpdateCurrentSongThumbnail();
749 m_UpdateCurrentSongProgressbar();
750 m_UpdateControlBtns();
751 m_UpdatePlaymodeFocusSequence();
755 void CPlaybackView::m_DisableEditButtons(bool flag)
757 /* flag - 1 means disable edit buttons and 0 means enable */
759 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
761 elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
762 elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
764 m_UpdateEditmodeFocusSequence();
765 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
768 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
769 m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
770 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE],
771 m->eoPlaylist, ELM_FOCUS_RIGHT);
772 elm_object_focus_next_object_set(m->eoPlaylist,
773 m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
778 void CPlaybackView::m_CreateErrorPopup(void)
780 Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
782 popup = elm_popup_add(m->eoBase);
786 elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
787 evas_object_show(popup);
789 label = elm_label_add(popup);
791 evas_object_del(popup);
795 elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
796 elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
797 elm_object_content_set(popup, label);
799 btn = elm_button_add(popup);
801 evas_object_del(popup);
805 elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
806 elm_object_text_set(btn, MUSIC_TEXT_OK);
807 elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
809 m->eoErrPopup = popup;
811 Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
813 elm_object_focus_set(btn, EINA_TRUE);
819 void CPlaybackView::m_DestroyErrorPopup(void)
824 evas_object_del(m->eoErrPopup);
825 m->eoErrPopup = NULL;
829 void CPlaybackView::m_CreateSettingsPopup(void)
831 CPlaySettingCtxPopup *eoCtxPopup = new CPlaySettingCtxPopup;
832 CCtxPopup::SCallback cb;
834 cb.onSelected = sm_CbCtxPopupBtnSelected;
836 eoCtxPopup->Create(m->eoWin, &cb);
838 m->eoCtxPopup = eoCtxPopup;
842 void CPlaybackView::m_DestroySettingsPopup(void)
847 if (m->eoCtxPopup->FlagCreate())
848 m->eoCtxPopup->Destroy();
850 delete m->eoCtxPopup;
851 m->eoCtxPopup = NULL;
855 void CPlaybackView::m_FromEditToPlaybackMode(void)
857 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
858 elm_genlist_item_bring_in(m->cs_itinfo->item,
859 ELM_GENLIST_ITEM_SCROLLTO_IN);
862 m_SelectItem(m->cs_itinfo);
864 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
865 MUSIC_PLAYBACK_VIEW);
866 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
868 m_ChangeEditmodeAll(m->elInfo, false);
870 elm_genlist_realized_items_update(m->eoPlaylist);
872 m_UpdatePlaymodeFocusSequence();
876 void CPlaybackView::m_FromPlaybackToEditMode(void)
878 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_EDIT_MODE,
879 MUSIC_PLAYBACK_VIEW);
881 m_DisableEditButtons(true);
883 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
885 m_ChangeEditmodeAll(m->elInfo, true);
887 elm_genlist_realized_items_update(m->eoPlaylist);
889 m_UpdateEditmodeFocusSequence();
893 void CPlaybackView::m_HandleOnRepeated(void)
895 Evas_Object *obj = NULL;
898 char *timestr = NULL;
900 if (!m->eoPressedObj)
903 obj = m->eoPressedObj;
905 value = elm_slider_value_get(m->eoSlider);
906 duration = m->cs_itinfo->sinfo->Duration();
908 if (obj == m->eoBtnControl[BTN_REWIND]) {
910 m_RemoveTimer(TIMER_LONGPRESS);
913 value = value - LP_CHANGE;
918 if (value == duration) {
919 if (m->hMusicController->PlayNextSong())
920 m_UpdateCurrentSongInfo();
922 _ERR(" music play next song failed ");
924 m->press_status = PRESS_LONG_PAUSE;
925 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE,
926 MUSIC_PLAYBACK_VIEW);
928 m_RemoveTimer(TIMER_LONGPRESS);
932 value = value + LP_CHANGE;
933 if (value >= duration)
937 m->hMusicController->SetPosition(value);
938 elm_slider_value_set(m->eoSlider, value);
939 timestr = CCommonUI::TimeStrFromMilSeconds(value);
941 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
950 void CPlaybackView::m_DeleteSelectedItems(void)
952 Eina_List *l = NULL, *l_next = NULL;
953 SItemInfo *pItemInfo = NULL;
958 m_DisableEditButtons(true);
959 EINA_LIST_FOREACH_SAFE(m->elInfo, l, l_next, obj) {
960 pItemInfo = (SItemInfo *)obj;
961 if (pItemInfo->check_status) {
962 if (m->cs_itinfo == pItemInfo) {
964 m_UnselectItem(m->cs_itinfo);
965 m_RemoveTimer(TIMER_SLIDER);
967 m->hMusicController->SetPlayState(PLAY_STATUS_STOP);
968 m->hMusicController->Stop();
970 index = elm_genlist_item_index_get(pItemInfo->item);
971 m->hMusicController->RemoveSong(pItemInfo->sinfo, index);
973 m->elInfo = eina_list_remove(m->elInfo,
975 elm_object_item_del(pItemInfo->item);
979 if (eina_list_count(m->elInfo) == 0) {
980 m_UpdateEmptySongInfo();
981 elm_genlist_realized_items_update(m->eoPlaylist);
982 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
987 m_UpdateCurrentSongInfo();
989 elm_genlist_realized_items_update(m->eoPlaylist);
990 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
994 void CPlaybackView::m_KeyBackPress(void)
997 m_DestroySettingsPopup();
998 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_FALSE);
999 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1008 void CPlaybackView::m_KeyExitPress(void)
1010 m_RemoveTimer(TIMER_SLIDER);
1011 m->hMusicController->Stop();
1016 void CPlaybackView::m_KeyPlayPress(void)
1020 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1023 state = m->hMusicController->PlayState();
1024 if (state == PLAY_STATUS_PAUSE) {
1026 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1027 MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1029 else if (state != PLAY_STATUS_PLAY) {
1030 if (m->hMusicController)
1031 m->hMusicController->Start();
1033 m_UpdateCurrentSongInfo();
1038 void CPlaybackView::m_KeyPausePress(void)
1042 if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1045 state = m->hMusicController->PlayState();
1046 if (state == PLAY_STATUS_PLAY) {
1047 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1048 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1054 void CPlaybackView::m_KeyNextPress(void)
1056 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1059 m_HandleOnPressed(m->eoBtnControl[BTN_FORWARD]);
1063 void CPlaybackView::m_KeyPreviousPress(void)
1065 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1068 m_HandleOnPressed(m->eoBtnControl[BTN_REWIND]);
1072 void CPlaybackView::m_KeyNextUnpress(void)
1074 if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1077 m_HandleOnUnpressed(m->eoBtnControl[BTN_FORWARD]);
1081 void CPlaybackView::m_KeyPreviousUnpress(void)
1083 if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1086 m_HandleOnUnpressed(m->eoBtnControl[BTN_REWIND]);
1090 void CPlaybackView::m_HandleKeyPress(char *keyname)
1092 if (!strcmp(keyname, (char *)KEY_EXIT))
1094 else if (!strcmp(keyname, (char *)KEY_BACK) ||
1095 !strcmp(keyname, (char *)KEY_BACK_REMOTE))
1097 else if (!strcmp(keyname, (char *)KEY_PLAY))
1099 else if (!strcmp(keyname, (char *)KEY_PAUSE))
1101 else if (!strcmp(keyname, (char *)KEY_NEXT))
1103 else if (!strcmp(keyname, (char *)KEY_PREVIOUS))
1104 m_KeyPreviousPress();
1105 else if (!strcmp(keyname, (char *)KEY_VOLUMEUP))
1106 m->pHandleVolume->Up();
1107 else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN))
1108 m->pHandleVolume->Down();
1109 else if (!strcmp(keyname, (char *)KEY_MUTE))
1110 m->pHandleVolume->Mute();
1114 void CPlaybackView::m_HandleKeyUnpress(char *keyname)
1116 if (!strcmp(keyname, KEY_PREVIOUS))
1117 m_KeyPreviousUnpress();
1118 else if (!strcmp(keyname, KEY_NEXT))
1123 void CPlaybackView::m_AddSlider(void)
1125 Evas_Object *eoSlider = NULL;
1127 eoSlider = elm_slider_add(m->eoBase);
1131 elm_slider_indicator_show_set(eoSlider, EINA_FALSE);
1132 elm_slider_indicator_show_on_focus_set(eoSlider, EINA_FALSE);
1133 elm_object_style_set(eoSlider, MUSIC_STYLE_SLIDER);
1134 elm_slider_horizontal_set(eoSlider, EINA_TRUE);
1135 elm_object_part_content_set(m->eoBase, MUSIC_PART_PROGRESSBAR, eoSlider);
1137 Connect(eoSlider, EO_SLIDER, TYPE_CHANGED | TYPE_MOUSE_MOVE);
1139 evas_object_show(eoSlider);
1140 m->eoSlider = eoSlider;
1144 void CPlaybackView::m_AddAlbumCover(void)
1146 Evas_Object *eoAlbumCover = NULL;
1148 eoAlbumCover = elm_image_add(m->eoBase);
1152 evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
1154 elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
1156 elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
1158 evas_object_show(eoAlbumCover);
1159 m->eoAlbumCover = eoAlbumCover;
1164 void CPlaybackView::m_AddCurrentSonginfo(void)
1171 void CPlaybackView::m_AddEditPlaylistButtons(void)
1173 Evas_Object *box = NULL;
1175 SBtnInfo btninfo[TOTAL_EDIT_BTNS];
1177 btninfo[BTN_CANCEL].txt = MUSIC_TEXT_CANCEL;
1178 btninfo[BTN_CANCEL].type = EO_CANCEL;
1180 btninfo[BTN_DESELECT].txt = MUSIC_TEXT_DESELECT;
1181 btninfo[BTN_DESELECT].type = EO_DESELECT;
1183 btninfo[BTN_DELETE].txt = MUSIC_TEXT_DELETE;
1184 btninfo[BTN_DELETE].type = EO_DELETE;
1186 box = CCommonUI::AddBox(m->eoBase);
1190 elm_box_horizontal_set(box, EINA_TRUE);
1191 elm_box_padding_set(box,
1192 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
1194 for (i = 0; i < TOTAL_EDIT_BTNS; i++) {
1195 m->eoBtnEdit[i] = elm_button_add(m->eoBase);
1196 if (!m->eoBtnEdit[i])
1199 elm_object_style_set(m->eoBtnEdit[i],
1200 MUSIC_STYLE_EDIT_BTN);
1201 evas_object_size_hint_weight_set(m->eoBtnEdit[i],
1202 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1203 elm_box_pack_end(box, m->eoBtnEdit[i]);
1204 elm_object_text_set(m->eoBtnEdit[i], _(btninfo[i].txt));
1206 Connect(m->eoBtnEdit[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1208 evas_object_show(m->eoBtnEdit[i]);
1210 elm_object_part_content_set(m->eoBase, MUSIC_PART_EDITBTNS, box);
1211 elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
1212 MUSIC_PLAYBACK_VIEW);
1216 void CPlaybackView::m_AddControlButtons(void)
1218 Evas_Object *box = NULL;
1220 SBtnInfo btninfo[TOTAL_CONTROL_BTNS];
1222 btninfo[BTN_SETTINGS].txt = MUSIC_STYLE_BTN_SETTINGS;
1223 btninfo[BTN_SETTINGS].type = EO_BTN_SETTINGS;
1225 btninfo[BTN_SHUFFLE].txt = MUSIC_STYLE_BTN_SHUFFLE;
1226 btninfo[BTN_SHUFFLE].type = EO_BTN_SHUFFLE;
1228 btninfo[BTN_REPEAT].txt = MUSIC_STYLE_BTN_REPEAT;
1229 btninfo[BTN_REPEAT].type = EO_BTN_REPEAT;
1231 btninfo[BTN_REWIND].txt = MUSIC_STYLE_BTN_REWIND;
1232 btninfo[BTN_REWIND].type = EO_BTN_REWIND;
1234 btninfo[BTN_PLAY].txt = MUSIC_STYLE_BTN_PLAY;
1235 btninfo[BTN_PLAY].type = EO_BTN_PLAY;
1237 btninfo[BTN_FORWARD].txt = MUSIC_STYLE_BTN_FORWARD;
1238 btninfo[BTN_FORWARD].type = EO_BTN_FORWARD;
1240 box = elm_box_add(m->eoBase);
1244 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
1245 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
1246 elm_box_horizontal_set(box, EINA_TRUE);
1247 elm_box_padding_set(box,
1248 MUSIC_CONTROL_BTNS_PADDING * elm_config_scale_get(), 0);
1250 for (i = 0; i < TOTAL_CONTROL_BTNS; i++) {
1251 m->eoBtnControl[i] = elm_button_add(m->eoBase);
1252 if (!m->eoBtnControl[i])
1255 elm_object_style_set(m->eoBtnControl[i], btninfo[i].txt);
1256 evas_object_size_hint_weight_set(m->eoBtnControl[i],
1257 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1258 elm_box_pack_end(box, m->eoBtnControl[i]);
1260 if (i == BTN_REWIND || i == BTN_FORWARD) {
1261 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_PRESSED | TYPE_UNPRESSED | TYPE_MOUSE_MOVE);
1264 Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1266 evas_object_show(m->eoBtnControl[i]);
1269 elm_object_part_content_set(m->eoBase, MUSIC_PART_CONTROLBTNS, box);
1273 SItemInfo *CPlaybackView::m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo)
1275 Eina_List *l = NULL;
1276 SItemInfo *itinfo = NULL;
1279 EINA_LIST_FOREACH(list, l, obj) {
1280 itinfo = (SItemInfo *)obj;
1281 if (itinfo->sinfo == sinfo)
1289 SItemInfo *CPlaybackView::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
1291 Eina_List *l = NULL;
1292 SItemInfo *itinfo = NULL;
1295 EINA_LIST_FOREACH(list, l, obj) {
1296 itinfo = (SItemInfo *)obj;
1297 if (itinfo->item == item)
1305 void CPlaybackView::m_UpdateItemCheck(SItemInfo *itinfo)
1308 _ERR(" No item info to Update check ");
1312 if (itinfo->check_status) {
1313 elm_object_item_signal_emit(itinfo->item,
1314 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1315 itinfo->check_status = false;
1319 elm_object_item_signal_emit(itinfo->item,
1320 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
1321 itinfo->check_status = true;
1325 class CElmGenlistItemClass {
1327 static char *sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
1329 CSongInfo *sinfo = NULL;
1330 SItemInfo *pItemInfo = (SItemInfo *)data;
1331 char buf[MAX_LENGTH];
1332 char *timestr = NULL;
1336 if (!pItemInfo || !obj)
1339 sinfo = pItemInfo->sinfo;
1341 snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY);
1343 if (!strcmp(part, "elm.text0")) {
1344 index = elm_genlist_item_index_get(pItemInfo->item);
1345 snprintf(buf, sizeof(buf), "%d", index);
1347 else if (!strcmp(part, "elm.text1"))
1348 snprintf(buf, sizeof(buf), "%s", sinfo->Name());
1349 else if (!strcmp(part, "elm.text2"))
1350 snprintf(buf, sizeof(buf), "%s - %s",
1353 else if (!strcmp(part, "elm.text3")) {
1354 duration = sinfo->Duration();
1355 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
1357 snprintf(buf, sizeof(buf), "%s", timestr);
1362 if (strcmp(buf, MUSIC_STR_EMPTY))
1367 static Evas_Object *sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
1369 CSongInfo *sinfo = NULL;
1370 SItemInfo *pItemInfo = (SItemInfo *)data;
1371 Evas_Object *img = NULL;
1373 char buf[MAX_LENGTH];
1375 if (!pItemInfo || !obj)
1378 sinfo = pItemInfo->sinfo;
1380 img = elm_image_add(obj);
1384 elm_image_aspect_fixed_set(img, EINA_FALSE);
1386 if (!strcmp(part, "elm.swallow.icon")) {
1387 path = sinfo->ThumbnailPath();
1389 elm_image_file_set(img, path, "NULL");
1391 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
1392 MUSIC_IMAGE_DEFAULT_THUMB_126);
1393 elm_image_file_set(img, buf, "NULL");
1400 static void sm_CbDel(void *data, Evas_Object *obj)
1407 Elm_Genlist_Item_Class *CPlaybackView::m_GetItemClass(void)
1409 Elm_Genlist_Item_Class *list_item = NULL;
1411 list_item = elm_genlist_item_class_new();
1413 _ERR(" elm_genlist_item_class_new failed ");
1417 list_item->item_style = MUSIC_STYLE_PLAYLIST;
1418 list_item->func.text_get = CElmGenlistItemClass::sm_CbTextGet;
1419 list_item->func.content_get = CElmGenlistItemClass::sm_CbContentGet;
1420 list_item->func.state_get = NULL;
1421 list_item->func.del = CElmGenlistItemClass::sm_CbDel;
1427 void CPlaybackView::m_AddGenlist(void)
1429 Evas_Object *genlist = NULL;
1430 Evas_Object *eoBase = NULL;
1433 genlist = elm_genlist_add(eoBase);
1437 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1438 evas_object_size_hint_weight_set(genlist,
1439 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1440 elm_object_part_content_set(eoBase, MUSIC_PART_PLAYLIST, genlist);
1441 elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
1442 elm_genlist_multi_select_set(genlist, EINA_FALSE);
1444 Connect(genlist, EO_PLAYLIST, TYPE_REALIZED | TYPE_UNREALIZED |
1445 TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_ACTIVATED);
1447 evas_object_show(genlist);
1448 m->eoPlaylist = genlist;
1452 void CPlaybackView::m_AddPlaylist(void)
1454 Elm_Genlist_Item_Class *list_item = NULL;
1457 CSongInfo *sinfo = NULL;
1458 Elm_Object_Item *item = NULL;
1459 SItemInfo *pItemInfo = NULL;
1465 list_item = m_GetItemClass();
1467 evas_object_del(m->eoPlaylist);
1471 if (!m->hMusicController->GetTotalSongs(&ts)) {
1472 _ERR(" music get total songs failed ");
1476 if (!m->hMusicController->GetCurrentSongIndex(&index))
1477 _ERR(" music get current song index failed ");
1479 for (i = 0; i < ts; i++) {
1480 if (!m->hMusicController->GetSonginfoFromIndex(i, &sinfo)) {
1481 _ERR(" music get songinfo failed ");
1484 pItemInfo = (SItemInfo *)calloc(1, sizeof(*pItemInfo));
1487 pItemInfo->sinfo = sinfo;
1488 pItemInfo->edit_mode = false;
1489 pItemInfo->check_status = false;
1490 pItemInfo->select_status = false;
1492 item = elm_genlist_item_append(m->eoPlaylist, list_item,
1493 pItemInfo, NULL, ELM_GENLIST_ITEM_NONE,
1494 sm_CbItemSelect, m);
1495 pItemInfo->item = item;
1498 pItemInfo->select_status = true;
1499 m->cs_itinfo = pItemInfo;
1501 m->elInfo = eina_list_append(m->elInfo, pItemInfo);
1506 void CPlaybackView::m_RemovePlaylist(void)
1508 if (m->eoPlaylist) {
1509 elm_genlist_clear(m->eoPlaylist);
1510 m->eoPlaylist = NULL;
1514 eina_list_free(m->elInfo);
1520 void CPlaybackView::m_HandleRewindBtnClicked(Evas_Object *obj)
1522 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1523 MUSIC_PLAYBACK_VIEW);
1525 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1528 if (!m->hMusicController->PlayPreviousSong()){
1529 _ERR(" music play previous song failed ");
1533 m_UpdateCurrentSongInfo();
1537 void CPlaybackView::m_HandleForwardBtnClicked(Evas_Object *obj)
1539 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1540 MUSIC_PLAYBACK_VIEW);
1542 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1545 if (!m->hMusicController->PlayNextSong()) {
1546 _ERR(" music play next song failed ");
1550 m_UpdateCurrentSongInfo();
1554 void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
1556 m->press_status = PRESS_SHORT;
1557 m->eoPressedObj = obj;
1559 m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, this);
1563 void CPlaybackView::m_HandleOnUnpressed(Evas_Object *obj)
1565 m_RemoveTimer(TIMER_WAIT);
1566 m_RemoveTimer(TIMER_LONGPRESS);
1568 if (m->press_status == PRESS_SHORT) {
1569 /* Handle song change */
1570 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY)
1573 if (obj == m->eoBtnControl[BTN_FORWARD])
1574 m_HandleForwardBtnClicked(obj);
1576 m_HandleRewindBtnClicked(obj);
1578 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1581 else if (m->press_status == PRESS_LONG) {
1582 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1586 m->press_status = PRESS_SHORT;
1590 void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_Item *genListItem)
1593 SItemInfo *itinfo = NULL;
1595 if (!obj || !genListItem)
1598 itinfo = m_FindItemInfoFromItem(m->elInfo, genListItem);
1600 _ERR(" no item info found ");
1604 if (itinfo->edit_mode) {
1605 m_UpdateItemCheck(itinfo);
1606 m_DisableEditButtons(false);
1610 index = elm_genlist_item_index_get(genListItem);
1612 m->hMusicController->PlayIndexSong(--index);
1613 m_UpdateCurrentSongInfo();
1617 bool CPlaybackView::Create(void *data)
1622 _CHECK(m = new SPlaybackView)
1623 _CHECK(m->mgr = CViewMgr::GetInstance())
1624 _CHECK(m->eoWin = m->mgr->Window())
1625 _CHECK(m->hMusicController = CMusicController::GetInstance())
1626 _CHECK(m->eoBase = CCommonUI::AddBase(m->eoWin, MUSIC_PLAYBACK_VIEW))
1627 _CHECK(CBaseView::Create(data))
1628 _CHECK(m->hMusicController->AddListener(this))
1631 m->press_status = PRESS_SHORT;
1632 evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1634 m_AddControlButtons();
1635 m_AddEditPlaylistButtons();
1636 m_AddCurrentSonginfo();
1639 m->pHandleVolume->Create(m->eoBase);
1640 m_UpdatePlaymodeFocusSequence();
1642 Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1645 _CHECK_FAIL{ m->hMusicController->RemoveListener(this); }
1646 _CHECK_FAIL{ CBaseView::Destroy(); }
1647 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1648 _CHECK_FAIL{ /* CMusicController::GetInstance())*/ }
1649 _CHECK_FAIL{ /* mgr->Window() */ }
1650 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1651 _CHECK_FAIL{ delete m; m = NULL; }
1652 }_CREATE_END_AND_CATCH{ return false; }
1658 void CPlaybackView::Destroy(void)
1662 Disconnect(m->eoBase);
1663 m->hMusicController->RemoveListener(this);
1665 m_DestroyErrorPopup();
1667 m_RemoveTimer(TIMER_SLIDER);
1668 m_RemoveTimer(TIMER_WAIT);
1669 m_RemoveTimer(TIMER_LONGPRESS);
1670 m_DestroySettingsPopup();
1672 m->pHandleVolume->Destroy();
1673 CBaseView::Destroy();
1674 evas_object_del(m->eoBase);
1682 Evas_Object* CPlaybackView::Base(void)
1690 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1692 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1694 if (eina_list_count(m->elInfo) == 0)
1697 elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1698 m_DestroySettingsPopup();
1699 m_CreateSettingsPopup();
1703 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1705 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1707 switch (m->hMusicController->ShuffleState()) {
1708 case SHUFFLE_STATUS_OFF:
1709 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_ON);
1710 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1714 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_OFF);
1715 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1721 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1723 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1725 switch (m->hMusicController->RepeatState()) {
1726 case REPEAT_STATUS_NONE:
1727 m->hMusicController->SetRepeatState(REPEAT_STATUS_ALL);
1728 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1731 case REPEAT_STATUS_ALL:
1732 m->hMusicController->SetRepeatState(REPEAT_STATUS_ONE);
1733 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1737 m->hMusicController->SetRepeatState(REPEAT_STATUS_NONE);
1738 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1744 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1746 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1748 switch (m->hMusicController->PlayState()) {
1749 case PLAY_STATUS_PAUSE:
1751 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1754 case PLAY_STATUS_PLAY:
1755 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1760 if (m->hMusicController)
1761 m->hMusicController->Start();
1762 m_UpdateCurrentSongInfo();
1768 void CPlaybackView::t_OnShow(void)
1774 m_UpdateCurrentSongInfo();
1776 state = m->hMusicController->PlayState();
1777 if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
1780 m->hMusicController->Start();
1781 m_UpdateCurrentSongInfo();
1785 elm_genlist_item_show(m->cs_itinfo->item,
1786 ELM_GENLIST_ITEM_SCROLLTO_IN);
1787 elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
1790 evas_object_show(m->eoBase);
1794 void CPlaybackView::t_OnUpdate(void *data)
1798 SParcel *parcel = (SParcel *)data;
1800 char *keyEvent = NULL;
1803 updateType = E_PLAYLIST_UPDATE;
1805 updateType = parcel->updateType;
1806 keyEvent = (char *)parcel->keyEvent;
1809 switch (updateType) {
1810 case E_PLAYLIST_UPDATE:
1813 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
1814 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
1815 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
1816 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
1817 m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
1818 m_FromEditToPlaybackMode();
1822 m_HandleKeyPress(keyEvent);
1826 m_HandleKeyUnpress(keyEvent);
1835 void CPlaybackView::t_OnHide(void)
1839 evas_object_hide(m->eoBase);
1843 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
1847 m_HandleKeyPress(ev->keyname);
1850 case EO_ERROR_POPUP_BUTTON:
1851 if (!strcmp(ev->keyname, KEY_BACK) ||
1852 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1853 m_DestroyErrorPopup();
1854 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1860 Elm_Object_Item *it = NULL;
1861 SContentInfo *ctxtinfo = NULL;
1862 SItemInfo *itinfo = NULL;
1864 if (strcmp(ev->keyname, KEY_MENU) &&
1865 strcmp(ev->keyname, KEY_MENU_REMOTE))
1868 it = elm_object_focused_item_get(obj);
1870 _ERR(" unable to get focused item ");
1873 m->focused_item = it;
1880 ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
1884 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
1890 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY &&
1891 itinfo == m->cs_itinfo)
1892 ctxtinfo->status = PLAY_STATUS_PLAY;
1894 ctxtinfo->status = PLAY_STATUS_PAUSE;
1896 ctxtinfo->cbdata = this;
1897 ctxtinfo->update = sm_CbCtxtUpdate;
1898 ctxtinfo->close = sm_CbCtxtClose;
1899 ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
1900 ctxtinfo->context = itinfo->sinfo;
1902 m->ctxtinfo = ctxtinfo;
1905 memset(&parcel, 0, sizeof(SParcel));
1906 parcel.ctxtInfo = ctxtinfo;
1907 if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
1908 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
1912 if (!strcmp(ev->keyname, KEY_BACK) ||
1913 !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1914 _ERR("eoCtxPopup BACK key pressed ");
1915 m_DestroySettingsPopup();
1916 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1919 else if (!strcmp(ev->keyname, KEY_EXIT)) {
1920 _ERR("eoCtxPopup EXIT key pressed ");
1921 m_DestroySettingsPopup();
1922 m_RemoveTimer(TIMER_SLIDER);
1923 m->hMusicController->Stop();
1934 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
1938 m_HandleKeyUnpress(ev->keyname);
1947 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
1950 case EO_ERROR_POPUP_BUTTON:
1951 m_DestroyErrorPopup();
1952 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1956 m_DisableCheckAll(m->elInfo);
1957 m_DisableEditButtons(true);
1958 m_FromEditToPlaybackMode();
1962 m_DisableCheckAll(m->elInfo);
1963 m_DisableEditButtons(true);
1964 elm_genlist_realized_items_update(m->eoPlaylist);
1965 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1969 m_DeleteSelectedItems();
1972 case EO_BTN_SETTINGS:
1973 t_OnClickedSettings(obj);
1976 case EO_BTN_SHUFFLE:
1977 t_OnClickedShuffle(obj);
1981 t_OnClickedRepeat(obj);
1985 t_OnClickedPlay(obj);
1994 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
2001 case EO_BTN_FORWARD:
2005 case EO_BTN_SETTINGS:
2006 case EO_BTN_SHUFFLE:
2007 if (!elm_object_focus_get(obj))
2008 elm_object_focus_set(obj, EINA_TRUE);
2013 Elm_Object_Item *item;
2015 item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
2016 ev->cur.canvas.y, NULL);
2020 if (!elm_object_item_focus_get(item))
2021 elm_object_item_focus_set(item, EINA_TRUE);
2031 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2034 case EO_BTN_FORWARD:
2036 m_HandleOnPressed(obj);
2045 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2048 case EO_BTN_FORWARD:
2050 m_HandleOnUnpressed(obj);
2059 void CPlaybackView::OnChanged(int id, Evas_Object *obj)
2064 char *timestr = NULL;
2067 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2069 ecore_timer_freeze(m->etSlider);
2072 value = elm_slider_value_get(obj);
2073 m->hMusicController->SetPosition(value);
2074 timestr = CCommonUI::TimeStrFromMilSeconds(value);
2076 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
2081 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2083 ecore_timer_thaw(m->etSlider);
2094 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2099 elm_object_item_signal_callback_add(item,
2100 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2101 sm_CbGenlistItemCheckClicked, this);
2103 int index = elm_genlist_item_index_get(item);
2104 if ((index & 1) == 1)
2105 elm_object_item_signal_emit(item,
2106 MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW);
2108 elm_object_item_signal_emit(item,
2109 MUSIC_SIGNAL_ODD_ROW, MUSIC_PLAYBACK_VIEW);
2111 SItemInfo *itInfo = m_FindItemInfoFromItem(m->elInfo, item);
2112 if (itInfo->select_status)
2113 elm_object_item_signal_emit(item,
2114 MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2116 elm_object_item_signal_emit(item,
2117 MUSIC_SIGNAL_UNSELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2119 if (itInfo->edit_mode) {
2120 elm_object_item_signal_emit(item,
2121 MUSIC_SIGNAL_EDITMODE_ON, MUSIC_PLAYBACK_VIEW);
2122 if (itInfo->check_status) {
2123 elm_object_item_signal_emit(item,
2124 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
2127 elm_object_item_signal_emit(item,
2128 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
2131 elm_object_item_signal_emit(item,
2132 MUSIC_SIGNAL_EDITMODE_OFF, MUSIC_PLAYBACK_VIEW);
2142 void CPlaybackView::OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2146 elm_object_item_signal_callback_del(item,
2147 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2148 sm_CbGenlistItemCheckClicked);
2157 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2161 m_HandleGenlistItemActivated(obj, item);
2170 void CPlaybackView::OnComplete(void)
2172 m_UpdateCurrentSongInfo();
2176 void CPlaybackView::OnError(void)
2178 m_CreateErrorPopup();
2182 void CPlaybackView::OnUsbConnected(void)
2187 void CPlaybackView::OnUpdateContent(void)