2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
20 #include "AppCommon.h"
23 #include <InputHandler.h>
24 #include "song_info.h"
25 #include "album_info.h"
26 #include "music-controller.h"
27 #include "volume-control.h"
30 #include "common-ui.h"
33 #include "playback-view.h"
34 #include "context-view.h"
35 #include "HandleVolume.h"
38 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
39 #define TITLE_FONT_SIZE 50
40 #define ARTIST_FONT_SIZE 30
41 #define TOTAL_CONTROL_BTNS 6
42 #define TOTAL_SETTING_BTNS 2
43 #define TOTAL_EDIT_BTNS 3
44 #define S_INTERVAL 1 /* seconds */
45 #define LP_INTERVAL 0.5 /* seconds */
46 #define WAIT_INTERVAL 0.5 /* seconds */
47 #define SLIDER_STEP 5000 /* milli seconds */
48 #define LP_CHANGE 10000 /* milli seconds */
49 #define S_INCREMENT 1000 /* milli seconds */
55 EO_ERROR_POPUP_BUTTON,
58 EO_CLEAR_PLAYLIST, // TOTAL_SETTING_BTNS
62 EO_DELETE, // TOTAL_EDIT_BTNS
69 EO_BTN_FORWARD, // TOTAL_CONTROL_BTNS
80 Elm_Object_Item *item;
87 struct SPlaybackView {
91 Evas_Object *eoCtxPopup; /*settings popup*/
92 Evas_Object *eoErrPopup;
93 Evas_Object *eoPlaylist;
95 Elm_Object_Item *focused_item;
97 Evas_Object *eoBtnControl[TOTAL_CONTROL_BTNS];
98 Evas_Object *eoBtnSetting[TOTAL_SETTING_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;
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 = _get_timestr_from_milseconds(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 ");
300 if (!m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL)) {
301 _ERR(" viewmgr show failed ");
304 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
308 void CPlaybackView::sm_CbCtxtClose(void *dt)
310 SPlaybackView *m = (SPlaybackView *)dt;
316 m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL);
317 elm_object_item_focus_set(m->focused_item, EINA_TRUE);
321 void CPlaybackView::m_RemoveTimer(int timer_code)
323 ETimers timerCode = (ETimers)timer_code;
328 ecore_timer_del(m->etSlider);
335 ecore_timer_del(m->etWait);
340 case TIMER_LONGPRESS:
341 if (m->etLongPress) {
342 ecore_timer_del(m->etLongPress);
343 m->etLongPress = NULL;
348 m->pHandleVolume->RemoveTimer();
352 _ERR(" invalid value ");
358 void CPlaybackView::m_PlaybackPause(void)
360 m->hMusicController->Pause();
363 ecore_timer_freeze(m->etSlider);
367 void CPlaybackView::m_PlaybackResume(void)
369 m->hMusicController->Resume();
372 ecore_timer_thaw(m->etSlider);
376 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
378 SItemInfo *itinfo = NULL;
382 EINA_LIST_FOREACH(list, l, obj) {
383 itinfo = (SItemInfo *)obj;
384 itinfo->edit_mode = flag;
389 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
391 SItemInfo *itinfo = NULL;
395 EINA_LIST_FOREACH(list, l, obj) {
396 itinfo = (SItemInfo *)obj;
397 itinfo->check_status = false;
402 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
404 if (!pItemInfo || !pItemInfo->item)
407 elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
408 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
410 pItemInfo->select_status = true;
414 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
416 if (!pItemInfo || !pItemInfo->item)
419 elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
420 MUSIC_PLAYBACK_VIEW);
422 pItemInfo->select_status = false;
426 void CPlaybackView::m_UpdateControlBtns(void)
430 state = m->hMusicController->PlayState();
431 if (state != PLAY_STATUS_STOP) {
432 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
433 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
437 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
438 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
439 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
442 if (state == PLAY_STATUS_PLAY) {
443 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
446 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
449 state = m->hMusicController->ShuffleState();
450 if (state == SHUFFLE_STATUS_OFF) {
451 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
454 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
457 state = m->hMusicController->RepeatState();
458 if (state == REPEAT_STATUS_NONE) {
459 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
461 else if (state == REPEAT_STATUS_ALL) {
462 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
465 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
470 void CPlaybackView::m_UpdateCurrentSongProgressbar(void)
473 char *timestr = NULL;
480 elm_slider_value_set(m->eoSlider, 0);
481 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
483 state = m->hMusicController->PlayState();
485 if (state == PLAY_STATUS_STOP) {
486 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
487 m_RemoveTimer(TIMER_SLIDER);
491 elm_object_disabled_set(m->eoSlider, EINA_FALSE);
493 duration = m->csinfo->Duration();
495 m_RemoveTimer(TIMER_SLIDER);
496 m->etSlider = ecore_timer_add(S_INTERVAL,
497 sm_CbUpdateSlider, m);
499 elm_slider_min_max_set(m->eoSlider, 0, duration);
500 timestr = _get_timestr_from_milseconds(duration);
502 elm_object_part_text_set(m->eoBase,
503 MUSIC_PART_FULLTIME, timestr);
507 step = (double)SLIDER_STEP / (double)duration;
508 elm_slider_step_set(m->eoSlider, step);
513 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
516 char buf[MAX_LENGTH];
518 if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
521 path = m->cs_itinfo->sinfo->ThumbnailPath();
523 elm_image_file_set(m->eoAlbumCover, path, NULL);
525 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
526 MUSIC_IMAGE_DEFAULT_THUMB_450);
527 elm_image_file_set(m->eoAlbumCover, buf, NULL);
532 void CPlaybackView::m_UpdateCurrentSongLabels(void)
534 char buf[MAX_LENGTH];
539 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
542 snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
545 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
549 void CPlaybackView::m_UpdateEmptySongInfo(void)
551 char buf[MAX_LENGTH];
553 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
554 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
555 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
556 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
557 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
558 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
559 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
560 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
561 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
562 elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
563 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
564 elm_slider_value_set(m->eoSlider, 0);
565 elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
566 _(NO_PLAYLIST_MESSAGE));
567 elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
568 _(NO_PLAYLIST_MESSAGE_SUB));
569 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
570 MUSIC_IMAGE_DEFAULT_THUMB_450);
571 elm_image_file_set(m->eoAlbumCover, buf, NULL);
572 m->hMusicController->SetPlayState(PLAY_STATUS_INITIAL);
576 void CPlaybackView::m_UpdateCtxtView(int playStatus)
578 if (!m->cs_itinfo || !m->ctxtinfo)
581 if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
584 if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
585 m->ctxtinfo->status = (EPlayStatus)playStatus;
588 parcel.ctxtInfo = NULL;
589 parcel.updateType = E_SONG_UPDATE;
590 parcel.layoutId = NULL;
591 parcel.keyEvent = NULL;
592 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
597 void CPlaybackView::m_UpdateCurrentSongItem(int index)
599 SItemInfo *pItemInfo = NULL;
602 m_UnselectItem(m->cs_itinfo);
603 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
606 pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
609 m->cs_itinfo = pItemInfo;
610 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
611 elm_genlist_item_bring_in(pItemInfo->item,
612 ELM_GENLIST_ITEM_SCROLLTO_IN);
615 m_SelectItem(pItemInfo);
616 m_UpdateCtxtView(PLAY_STATUS_PLAY);
622 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
624 elm_object_focus_next_object_set(m->eoPlaylist,
625 m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
626 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
627 m->eoPlaylist, ELM_FOCUS_RIGHT);
628 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnEdit[BTN_CANCEL],
633 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
635 elm_object_focus_next_object_set(m->eoSlider, m->eoPlaylist,
637 elm_object_focus_next_object_set(m->eoSlider, m->eoBtnControl[BTN_PLAY],
639 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
640 elm_object_focus_next_object_set(m->eoPlaylist,
641 m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
642 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
643 m->eoPlaylist, ELM_FOCUS_RIGHT);
646 elm_object_focus_next_object_set(m->eoPlaylist,
647 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
648 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
649 m->eoPlaylist, ELM_FOCUS_RIGHT);
650 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
651 m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
656 void CPlaybackView::m_UpdateCurrentSongInfo(void)
658 CSongInfo *sinfo = NULL;
661 if (eina_list_count(m->elInfo) == 0) {
662 m_UpdateEmptySongInfo();
666 if (!m->hMusicController->GetCurrentSongIndex(&index)) {
667 _ERR(" music get current song index failed ");
671 if (!m->hMusicController->GetSonginfoFromIndex(index, &sinfo)) {
672 _ERR(" music get songinfo failed ");
677 m_UpdateCurrentSongItem(index);
678 m_UpdateCurrentSongLabels();
679 m_UpdateCurrentSongThumbnail();
680 m_UpdateCurrentSongProgressbar();
681 m_UpdateControlBtns();
682 m_UpdatePlaymodeFocusSequence();
686 void CPlaybackView::m_DisableEditButtons(bool flag)
688 /* flag - 1 means disable edit buttons and 0 means enable */
690 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
692 elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
693 elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
695 m_UpdateEditmodeFocusSequence();
696 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
699 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
700 m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
701 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE],
702 m->eoPlaylist, ELM_FOCUS_RIGHT);
703 elm_object_focus_next_object_set(m->eoPlaylist,
704 m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
709 void CPlaybackView::m_CreateErrorPopup(void)
711 Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
713 popup = elm_popup_add(m->eoBase);
717 elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
718 evas_object_show(popup);
720 label = elm_label_add(popup);
722 evas_object_del(popup);
726 elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
727 elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
728 elm_object_content_set(popup, label);
730 btn = elm_button_add(popup);
732 evas_object_del(popup);
736 elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
737 elm_object_text_set(btn, MUSIC_TEXT_OK);
738 elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
740 m->eoErrPopup = popup;
742 Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
744 elm_object_focus_set(btn, EINA_TRUE);
750 void CPlaybackView::m_DestroyErrorPopup(void)
755 evas_object_del(m->eoErrPopup);
756 m->eoErrPopup = NULL;
760 void CPlaybackView::m_CreateSettingsPopup(void)
762 Evas_Object *box = NULL;
763 Evas_Object *eoCtxPopup = NULL;
766 SBtnInfo btninfo[TOTAL_SETTING_BTNS];
768 btninfo[BTN_EDIT].txt = MUSIC_TEXT_EDIT_PLAYLIST;
769 btninfo[BTN_EDIT].type = EO_EDIT_PLAYLIST;
771 btninfo[BTN_CLEAR].txt = MUSIC_TEXT_CLEAR_PLAYLIST;
772 btninfo[BTN_CLEAR].type = EO_CLEAR_PLAYLIST;
774 eoCtxPopup = elm_ctxpopup_add(m->eoWin);
778 box = _add_box(eoCtxPopup);
780 evas_object_del(eoCtxPopup);
784 for (i = 0; i < TOTAL_SETTING_BTNS; i++) {
785 m->eoBtnSetting[i] = elm_button_add(box);
786 if (!m->eoBtnSetting[i])
789 elm_object_style_set(m->eoBtnSetting[i],
790 MUSIC_STYLE_SETTING_BTN_T);
793 elm_object_style_set(m->eoBtnSetting[i],
794 MUSIC_STYLE_SETTING_BTN_B);
796 evas_object_size_hint_weight_set(m->eoBtnSetting[i],
797 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
798 elm_box_pack_end(box, m->eoBtnSetting[i]);
799 elm_object_text_set(m->eoBtnSetting[i], _(btninfo[i].txt));
801 Connect(m->eoBtnSetting[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
803 evas_object_show(m->eoBtnSetting[i]);
806 elm_object_style_set(eoCtxPopup, MUSIC_STYLE_SETTING_POPUP);
807 elm_object_content_set(eoCtxPopup, box);
809 scale = elm_config_scale_get();
810 Connect(box, EO_BOX, TYPE_KEY_DOWN);
811 elm_object_part_content_set(m->eoBase, MUSIC_PART_SETTINGS_POPUP, eoCtxPopup);
813 /* If list empty disable these options */
814 if (eina_list_count(m->elInfo) == 0) {
815 elm_object_disabled_set(m->eoBtnSetting[BTN_EDIT], EINA_TRUE);
816 elm_object_disabled_set(m->eoBtnSetting[BTN_CLEAR], EINA_TRUE);
819 elm_object_focus_set(m->eoBtnSetting[BTN_EDIT], EINA_TRUE);
821 m->eoCtxPopup = eoCtxPopup;
825 void CPlaybackView::m_DestroySettingsPopup(void)
830 evas_object_del(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 = _get_timestr_from_milseconds(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) == 0)
1074 else if (strcmp(keyname, (char*)KEY_BACK) == 0)
1076 else if (strcmp(keyname, (char*)KEY_PLAY) == 0)
1078 else if (strcmp(keyname, (char*)KEY_PAUSE) == 0)
1080 else if (strcmp(keyname, (char*)KEY_NEXT) == 0)
1082 else if (strcmp(keyname, (char*)KEY_PREVIOUS) == 0)
1083 m_KeyPreviousPress();
1084 else if (strcmp(keyname, (char*)KEY_VOLUMEUP) == 0)
1085 m->pHandleVolume->Up();
1086 else if (strcmp(keyname, (char*)KEY_VOLUMEDOWN) == 0)
1087 m->pHandleVolume->Down();
1088 else if (strcmp(keyname, (char*)KEY_MUTE) == 0)
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 = _add_box(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 + 1);
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 = _get_timestr_from_milseconds(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 = _add_base(m->eoWin, MUSIC_PLAYBACK_VIEW))
1641 _CHECK(CBaseView::Create(data))
1643 _CHECK_FAIL{ CBaseView::Destroy(); }
1644 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1645 _CHECK_FAIL{ /* CMusicController::GetInstance())*/ }
1646 _CHECK_FAIL{ /* mgr->Window() */ }
1647 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1648 _CHECK_FAIL{ delete m; m = NULL; }
1649 }_CREATE_END_AND_CATCH{ return false; }
1651 m->press_status = PRESS_SHORT;
1654 evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1656 m_AddControlButtons();
1657 m_AddEditPlaylistButtons();
1658 m_AddCurrentSonginfo();
1661 m->pHandleVolume->Create(m->eoBase);
1662 m_UpdatePlaymodeFocusSequence();
1664 Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1666 m->hMusicController->AddListener(this);
1672 void CPlaybackView::Destroy(void)
1676 m->hMusicController->RemoveListener(this);
1678 m_DestroyErrorPopup();
1680 m_RemoveTimer(TIMER_SLIDER);
1681 m_RemoveTimer(TIMER_WAIT);
1682 m_RemoveTimer(TIMER_LONGPRESS);
1683 m_DestroySettingsPopup();
1685 m->pHandleVolume->Destroy();
1686 CBaseView::Destroy();
1687 evas_object_del(m->eoBase);
1695 Evas_Object* CPlaybackView::Base(void)
1703 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1705 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1707 if (eina_list_count(m->elInfo) == 0)
1710 elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1711 m_DestroySettingsPopup();
1712 m_CreateSettingsPopup();
1716 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1718 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1720 switch (m->hMusicController->ShuffleState()) {
1721 case SHUFFLE_STATUS_OFF:
1722 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_ON);
1723 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1727 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_OFF);
1728 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1734 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1736 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1738 switch (m->hMusicController->RepeatState()) {
1739 case REPEAT_STATUS_NONE:
1740 m->hMusicController->SetRepeatState(REPEAT_STATUS_ALL);
1741 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1744 case REPEAT_STATUS_ALL:
1745 m->hMusicController->SetRepeatState(REPEAT_STATUS_ONE);
1746 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1750 m->hMusicController->SetRepeatState(REPEAT_STATUS_NONE);
1751 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1757 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1759 elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1761 switch (m->hMusicController->PlayState()) {
1762 case PLAY_STATUS_PAUSE:
1764 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1767 case PLAY_STATUS_PLAY:
1768 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1773 if (m->hMusicController)
1774 m->hMusicController->Start();
1775 m_UpdateCurrentSongInfo();
1781 void CPlaybackView::t_OnShow(void)
1788 elm_genlist_item_show(m->cs_itinfo->item,
1789 ELM_GENLIST_ITEM_SCROLLTO_IN);
1790 elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
1793 state = m->hMusicController->PlayState();
1794 if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
1797 m->hMusicController->Start();
1798 m_UpdateCurrentSongInfo();
1801 evas_object_show(m->eoBase);
1805 void CPlaybackView::t_OnUpdate(void *data)
1812 SParcel *parcel = (SParcel *)data;
1813 int updateType = parcel->updateType;
1814 char *key = (char *)parcel->keyEvent;
1816 switch (updateType) {
1817 case E_PLAYLIST_UPDATE:
1820 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
1821 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
1822 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
1823 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
1824 m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
1825 m_FromEditToPlaybackMode();
1829 m_HandleKeyPress(key);
1833 m_HandleKeyUnpress(key);
1842 void CPlaybackView::t_OnHide(void)
1846 evas_object_hide(m->eoBase);
1850 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
1854 m_HandleKeyPress(ev->keyname);
1857 case EO_ERROR_POPUP_BUTTON:
1858 if (!strcmp(ev->keyname, KEY_BACK)) {
1859 m_DestroyErrorPopup();
1860 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1866 Elm_Object_Item *it = NULL;
1867 SContentInfo *ctxtinfo = NULL;
1868 SItemInfo *itinfo = NULL;
1870 if (strcmp(ev->keyname, KEY_MENU))
1873 it = elm_object_focused_item_get(obj);
1875 _ERR(" unable to get focused item ");
1878 m->focused_item = it;
1885 ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
1889 itinfo = m_FindItemInfoFromItem(m->elInfo, it);
1895 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY &&
1896 itinfo == m->cs_itinfo)
1897 ctxtinfo->status = PLAY_STATUS_PLAY;
1899 ctxtinfo->status = PLAY_STATUS_PAUSE;
1901 ctxtinfo->cbdata = m;
1902 ctxtinfo->update = sm_CbCtxtUpdate;
1903 ctxtinfo->close = sm_CbCtxtClose;
1904 ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
1905 ctxtinfo->context = itinfo->sinfo;
1907 m->ctxtinfo = ctxtinfo;
1910 parcel.ctxtInfo = ctxtinfo;
1911 if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
1912 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
1916 if (!strcmp(ev->keyname, KEY_BACK)) {
1917 _ERR("eoCtxPopup BACK key pressed ");
1918 m_DestroySettingsPopup();
1919 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1922 else if (!strcmp(ev->keyname, KEY_EXIT)) {
1923 _ERR("eoCtxPopup EXIT key pressed ");
1924 m_DestroySettingsPopup();
1925 m_RemoveTimer(TIMER_SLIDER);
1926 m->hMusicController->Stop();
1937 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
1941 m_HandleKeyUnpress(ev->keyname);
1950 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
1953 case EO_ERROR_POPUP_BUTTON:
1954 m_DestroyErrorPopup();
1955 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1958 case EO_EDIT_PLAYLIST:
1959 m_DestroySettingsPopup();
1960 m_FromPlaybackToEditMode();
1963 case EO_CLEAR_PLAYLIST:
1964 m->hMusicController->Stop();
1965 m->hMusicController->EmptyPlaylist();
1967 eina_list_free(m->elInfo);
1970 elm_genlist_clear(m->eoPlaylist);
1972 m_DestroySettingsPopup();
1973 m_UpdateEmptySongInfo();
1977 m_DisableCheckAll(m->elInfo);
1978 m_DisableEditButtons(true);
1979 m_FromEditToPlaybackMode();
1983 m_DisableCheckAll(m->elInfo);
1984 m_DisableEditButtons(true);
1985 elm_genlist_realized_items_update(m->eoPlaylist);
1986 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1990 m_DeleteSelectedItems();
1993 case EO_BTN_SETTINGS:
1994 t_OnClickedSettings(obj);
1997 case EO_BTN_SHUFFLE:
1998 t_OnClickedShuffle(obj);
2002 t_OnClickedRepeat(obj);
2006 t_OnClickedPlay(obj);
2015 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
2022 case EO_BTN_FORWARD:
2026 case EO_BTN_SETTINGS:
2027 case EO_BTN_SHUFFLE:
2028 case EO_EDIT_PLAYLIST:
2029 case EO_CLEAR_PLAYLIST:
2030 if (!elm_object_focus_get(obj))
2031 elm_object_focus_set(obj, EINA_TRUE);
2036 Elm_Object_Item *item;
2038 item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
2039 ev->cur.canvas.y, NULL);
2043 if (!elm_object_item_focus_get(item))
2044 elm_object_item_focus_set(item, EINA_TRUE);
2054 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2057 case EO_BTN_FORWARD:
2059 m_HandleOnPressed(obj);
2068 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2071 case EO_BTN_FORWARD:
2073 m_HandleOnUnpressed(obj);
2082 void CPlaybackView::OnChanged(int id, Evas_Object *obj)
2087 char *timestr = NULL;
2090 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2092 ecore_timer_freeze(m->etSlider);
2095 value = elm_slider_value_get(obj);
2096 m->hMusicController->SetPosition(value);
2097 timestr = _get_timestr_from_milseconds(value);
2099 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
2104 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2106 ecore_timer_thaw(m->etSlider);
2117 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2121 elm_object_item_signal_callback_add(item,
2122 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2123 sm_CbGenlistItemCheckClicked, this);
2132 void CPlaybackView::OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2136 elm_object_item_signal_callback_del(item,
2137 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2138 sm_CbGenlistItemCheckClicked);
2147 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2151 m_HandleGenlistItemActivated(obj, item);
2160 void CPlaybackView::t_OnComplete(void)
2162 m_UpdateCurrentSongInfo();
2166 void CPlaybackView::t_OnError(void)
2168 m_CreateErrorPopup();
2172 void CPlaybackView::t_OnUsbConnected(void)
2177 void CPlaybackView::t_OnUpdateContent(void)