2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 * @file MpMusicPlayerForm.h
19 * @brief This is the implementation file for MusicPlayerForm class.
27 #include <FUiScenes.h>
28 #include "MpAllListPresentationModel.h"
29 #include "MpCommonUtil.h"
30 #include "MpMusicPlayerApp.h"
31 #include "MpMusicPlayerForm.h"
32 #include "MpMusicPlayerPresentationModel.h"
33 #include "MpPlaylistPickerPopup.h"
34 #include "MpResourceManager.h"
35 #include "MpSceneRegister.h"
36 #include "MpSetAsPopup.h"
37 #include "MpSettingPresentationModel.h"
38 #include "MpSharePopup.h"
39 #include "MpSoundPathPopup.h"
40 #include "MpThumbnailInfo.h"
42 using namespace Tizen::App;
43 using namespace Tizen::Base;
44 using namespace Tizen::Base::Collection;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Io;
47 using namespace Tizen::Media;
48 using namespace Tizen::System;
49 using namespace Tizen::Ui;
50 using namespace Tizen::Ui::Animations;
51 using namespace Tizen::Ui::Controls;
52 using namespace Tizen::Ui::Scenes;
54 static const int H_CONTROLLER_PANEL = 288;
55 static const int W_HORIZONTAL_PLAYER = 720;
56 static const int H_HORIZONTAL_CONTROLLER_PANEL = 300;
57 static const int H_VOLUME_PANEL = 112;
59 static const int TRANSPARENT_COLOR = 0x00000000;
61 static const int MIN_VOLUME_SLIDER_COUNT = 0;
62 static const int MAX_VOLUME_SLIDER_COUNT = 15;
64 static const int IDA_BUTTON_CONTENTS_LIST_VIEW = 200;
65 static const int IDA_BUTTON_CONTENTS_ALBUM_VIEW = 201;
67 static const Tizen::Base::String INVALID_VALUE_OF_CONTENT_ID = L"00000000-0000-0000-0000-000000000000";
69 static const wchar_t* IDB_PLAY_BUTTON_ICON_NORMAL = L"T02_control_circle_icon_play.png";
70 static const wchar_t* IDB_PLAY_BUTTON_ICON_PRESSED = L"T02_control_circle_icon_play_press.png";
71 static const wchar_t* IDB_PLAY_BUTTON_ICON_DISABLED = L"T02_control_circle_icon_play_dim.png";
72 static const wchar_t* IDB_PAUSE_BUTTON_ICON_NORMAL = L"T02_control_circle_icon_pause.png";
73 static const wchar_t* IDB_PAUSE_BUTTON_ICON_PRESSED = L"T02_control_circle_icon_pause_press.png";
74 static const wchar_t* IDB_PAUSE_BUTTON_ICON_DISABLED = L"T02_control_circle_icon_pause_dim.png";
76 FloatRectangle rectanglePreviousElement;
77 FloatRectangle rectangleCurrentElement;
78 FloatRectangle rectangleNextElement;
82 IDA_TYPE_REPEAT_A = 0, /**< The repeat type is OFF */
83 IDA_TYPE_REPEAT_ONE, /**< The repeat type is ONE */
84 IDA_TYPE_REPEAT_ALL /**< The repeat type is ALL */
87 enum PlayerScreenState
89 PLAYER_SCREEN_STATE_BASE = 0,
90 PLAYER_SCREEN_STATE_NORMAL = PLAYER_SCREEN_STATE_BASE,
91 PLAYER_SCREEN_STATE_NO_CONTENT_LIST,
92 PLAYER_SCREEN_STATE_APP_CONTROL,
93 PLAYER_SCREEN_STATE_ERROR_CONTENT,
94 PLAYER_SCREEN_STATE_DURING_CALL,
95 PLAYER_SCREEN_STATE_MAX
98 enum IDAPlayerController
100 IDA_PLAYER_CONTROLLER_BASE = 100,
101 IDA_PLAYER_CONTROLLER_REWIND = IDA_PLAYER_CONTROLLER_BASE,
102 IDA_PLAYER_CONTROLLER_PLAY,
103 IDA_PLAYER_CONTROLLER_PAUSE,
104 IDA_PLAYER_CONTROLLER_FORWARD,
105 IDA_PLAYER_CONTROLLER_VOLUME,
106 IDA_PLAYER_CONTROLLER_REPEAT,
107 IDA_PLAYER_CONTROLLER_SHUFFLE,
108 IDA_PLAYER_CONTROLLER_BACK,
109 IDA_PLAYER_CONTROLLER_MORE,
110 IDA_PLAYER_CONTROLLER_MAX
113 PlayerForm::PlayerForm(void)
114 : __pPlayerPresentationModel(null)
115 , __pAlbumArtElements(null)
116 , __pVolumePanel(null)
117 , __pControllerPanel(null)
118 , __pPanelRegisterBar(null)
119 , __pContentsAlbumViewPanel(null)
120 , __pContentsListViewPanel(null)
121 , __pCurrentTimeLabel(null)
122 , __pTotalTimeLabel(null)
124 , __pArtistName(null)
125 , __pRewindButton(null)
126 , __pForwardButton(null)
127 , __pVolumeButton(null)
128 , __pPlayPauseButton(null)
129 , __pBackButton(null)
130 , __pRepeatButton(null)
131 , __pShuffleButton(null)
132 , __pContentsViewToggleButton(null)
133 , __pMoreContextButton(null)
134 , __pPlayStateSlider(null)
135 , __pVolumeSlider(null)
137 , __pPlayListPicker(null)
138 , __pSharePicker(null)
139 , __pSetAsPicker(null)
140 , __pSoundPathPopup(null)
141 , __isLongPressed(false)
142 , flickDirection(FLICK_DIRECTION_NONE)
143 , __transactionID(ANIMATION_TRANSACTION_STATUS_STOPPED)
144 , __playerScreenState(PLAYER_SCREEN_STATE_NORMAL)
145 , __isAnimationPerformed(false)
146 , __isRunByAppControl(false)
147 , __pAnimationFinishedTimer(null)
148 , __pContentPlayTimer(null)
149 , __pPreviousSceneId(null)
151 , __pContextMenu(null)
153 AppLogDebug("ENTER");
157 PlayerForm::~PlayerForm(void)
159 AppLogDebug("ENTER");
164 PlayerForm::Initialize(void)
166 AppLogDebug("ENTER");
167 if (IsFailed(Form::Construct(IDL_MUSIC_PLAYER_FORM)))
169 AppLogDebug("Form::Construct(IDL_MUSIC_PLAYER_FORM) failed(%s)", GetErrorMessage(GetLastResult()));
177 PlayerForm::OnInitializing(void)
179 AppLogDebug("ENTER");
181 __pControllerPanel = static_cast<Panel*>(GetControl(IDC_PLAYER_CONTROL_BAR));
182 __pTitleName = static_cast<Label*>(GetControl(IDC_CONTENTS_TITLE_NAME));
183 __pArtistName = static_cast<Label*>(GetControl(IDC_CONTENTS_ARTIST_NAME));
185 __pContentsViewToggleButton = static_cast<Button*>(GetControl(IDC_CONTENTS_VIEW_TOGGLE_BUTTON));
186 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
187 __pContentsViewToggleButton->AddActionEventListener(*this);
189 __pVolumeButton = static_cast<Button*>(__pControllerPanel->GetControl(L"IDC_OPTION_VOLUMN"));
190 __pVolumeButton->SetActionId(IDA_PLAYER_CONTROLLER_VOLUME);
191 __pVolumeButton->AddActionEventListener(*this);
192 __pShuffleButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_SHUFFLE));
193 __pShuffleButton->SetActionId(IDA_PLAYER_CONTROLLER_SHUFFLE);
194 __pShuffleButton->AddActionEventListener(*this);
195 __pRepeatButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_REPEAT));
196 __pRepeatButton->SetActionId(IDA_PLAYER_CONTROLLER_REPEAT);
197 __pRepeatButton->AddActionEventListener(*this);
199 Button* pButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_PLAY_LIST_ADD));
200 pButton->SetShowState(false);
202 __pRewindButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_PREVIOUS_CONTROL_BUTTON));
203 __pRewindButton->SetActionId(IDA_PLAYER_CONTROLLER_REWIND);
204 __pRewindButton->AddTouchEventListener(*this);
206 __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_PALY_TOGGLE_CONTROL_BUTTON));
207 __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PLAY);
208 __pPlayPauseButton->AddActionEventListener(*this);
210 __pForwardButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_NEXT_CONTROL_BUTTON));
211 __pForwardButton->SetActionId(IDA_PLAYER_CONTROLLER_FORWARD);
212 __pForwardButton->AddTouchEventListener(*this);
214 Bitmap* pBackNormalBitmap = ResourceManager::GetBitmapN(L"00_icon_Back_02_web.png");
215 Bitmap* pBackPressBitmap = ResourceManager::GetBitmapN(L"00_icon_Back_02_press_web.png");
217 __pBackButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BACK_BUTTON));
219 __pBackButton->SetNormalBitmap(__pBackButton->GetPosition(), *pBackNormalBitmap);
220 __pBackButton->SetPressedBitmap(__pBackButton->GetPosition(), *pBackPressBitmap);
222 __pBackButton->SetActionId(IDA_PLAYER_CONTROLLER_BACK);
223 __pBackButton->AddActionEventListener(*this);
225 delete pBackNormalBitmap;
226 delete pBackPressBitmap;
228 __pCurrentTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_CURRENT_PLAYING_TIME));
229 __pTotalTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_CONTENT_TOTAL_TIME));
230 __pPlayStateSlider = static_cast<Slider*>(__pControllerPanel->GetControl(IDC_SLIDER_BAR));
231 __pPlayStateSlider->AddSliderEventListener(*this);
233 __pPlayStateSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL, Color(255, 255, 255, 0));
234 __pPlayStateSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED, Color(255, 255, 255, 0));
235 __pPlayStateSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED, Color(255, 255, 255, 0));
237 __pMoreContextButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_MORE_CONTEXT_MENU_BUTTON));
239 Bitmap* pMoreContextNormalBitmap = ResourceManager::GetBitmapN(L"00_icon_more_web.png");
240 Bitmap* pMoreContextPressBitmap = ResourceManager::GetBitmapN(L"00_icon_more_press_web.png");
241 Bitmap* pMoreContextDisableBitmap = ResourceManager::GetBitmapN(L"00_icon_more_dim_web.png");
243 __pMoreContextButton->SetNormalBitmap(__pMoreContextButton->GetPosition(), *pMoreContextNormalBitmap);
244 __pMoreContextButton->SetPressedBitmap(__pMoreContextButton->GetPosition(), *pMoreContextPressBitmap);
245 __pMoreContextButton->SetDisabledBitmap(__pMoreContextButton->GetPosition(), *pMoreContextDisableBitmap);
247 __pMoreContextButton->SetActionId(IDA_PLAYER_CONTROLLER_MORE);
248 __pMoreContextButton->AddActionEventListener(*this);
250 delete pMoreContextNormalBitmap;
251 delete pMoreContextPressBitmap;
252 delete pMoreContextDisableBitmap;
254 __pAnimationFinishedTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
255 __pAnimationFinishedTimer->Construct(*this);
256 __pContentPlayTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
257 __pContentPlayTimer->Construct(*this);
258 __pPlayerPresentationModel = PlayerPresentationModel::GetInstance();
260 __pContentsListViewPanel = new (std::nothrow) Panel();
261 if (IsFailed(__pContentsListViewPanel->Construct(IDL_MUSIC_PLAYER_CONTENTS_LIST_VIEW_PANEL)))
263 AppLogDebug("Construct(IDL_MUSIC_PLAYER_CONTENTS_LIST_VIEW_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
264 delete __pContentsListViewPanel;
268 __pPanelRegisterBar = static_cast<Panel*>(GetControl(IDC_PANEL_REGISTER_BAR));
269 __pPanelRegisterBar->AddControl(*__pContentsListViewPanel);
270 __pContentsListViewPanel->SetShowState(false);
271 __pContentsListViewPanel->SetEnabled(false);
273 CommonUtil::SetLayoutFitToContainer(*__pPanelRegisterBar, *__pContentsListViewPanel);
274 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
275 pContentsTableView->AddTableViewItemEventListener(*this);
276 pContentsTableView->SetItemProvider(this);
278 __pContentsAlbumViewPanel = new (std::nothrow) Panel();
279 if (IsFailed(__pContentsAlbumViewPanel->Construct(IDL_MUSIC_PLAYER_CONTENTS_ALBUM_VIEW_PANEL)))
281 AppLogDebug("Construct(IDL_MUSIC_PLAYER_CONTENTS_ALBUM_VIEW_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
282 delete __pContentsAlbumViewPanel;
285 __pPanelRegisterBar->AddControl(*__pContentsAlbumViewPanel);
286 CommonUtil::SetLayoutFitToContainer(*__pPanelRegisterBar, *__pContentsAlbumViewPanel);
288 Label* pAlbumThumbnailLabel = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
289 __pContentsAlbumViewPanel->SetControlAlwaysOnTop(*pAlbumThumbnailLabel, true);
290 pAlbumThumbnailLabel->AddTouchEventListener(*this);
292 FloatDimension floatDimension = pAlbumThumbnailLabel->GetSizeF();
293 __pAlbumArtElements = new (std::nothrow) VisualElement();
294 __pAlbumArtElements->Construct();
295 __pAlbumArtElements->SetName(L"VisualElement");
296 __pAlbumArtElements->SetBounds(FloatRectangle(0.0f, 0.0f, floatDimension.width, floatDimension.height));
297 __pAlbumArtElements->SetClipChildrenEnabled(false);
298 __pAlbumArtElements->SetShowState(true);
299 pAlbumThumbnailLabel->GetVisualElement()->AttachChild(*__pAlbumArtElements);
301 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT] = new (std::nothrow) VisualElement();
302 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->Construct();
303 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->SetBounds(FloatRectangle(0.0f, 0.0f, floatDimension.width, floatDimension.height));
304 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->SetShowState(true);
305 __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]);
307 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS] = new (std::nothrow) VisualElement();
308 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->Construct();
309 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetBounds(FloatRectangle(-604.0, 0.0f, floatDimension.width, floatDimension.height));
310 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(true);
311 __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]);
313 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT] = new (std::nothrow) VisualElement();
314 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->Construct();
315 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetName(L"Rect3");
316 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetBounds(FloatRectangle(836.0, 0.0f, floatDimension.width, floatDimension.height));
318 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(true);
319 __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]);
321 rectanglePreviousElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetBounds();
322 rectangleCurrentElement = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetBounds();
323 rectangleNextElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetBounds();
325 AddOrientationEventListener(*this);
326 AddKeyEventListener(*this);
328 UpdateSplitBarState();
329 TogglePlayPauseImage(PLAYER_STATE_CLOSED);
332 return ThumbnailBase::Construct();
336 PlayerForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
338 AppLogDebug("ENTER");
339 FloatDimension floatDimension = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->GetSizeF();
341 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->SetBounds(FloatRectangle(0.0f, 0.0f, floatDimension.width, floatDimension.height));
342 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetBounds(FloatRectangle(-604.0, 0.0f, floatDimension.width, floatDimension.height));
343 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetBounds(FloatRectangle(836.0, 0.0f, floatDimension.width, floatDimension.height));
345 rectanglePreviousElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetBounds();
346 rectangleCurrentElement = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetBounds();
347 rectangleNextElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetBounds();
349 UpdateSplitBarState();
351 Rectangle clientBounds = GetClientAreaBounds();
352 if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE
353 || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
355 if (__pVolumePanel != null)
357 if (clientBounds.width > 1200)
359 __pVolumePanel->SetPosition(clientBounds.width - W_HORIZONTAL_PLAYER , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50);
363 __pVolumePanel->SetBounds(Rectangle(clientBounds.width - 670
364 , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
368 __pVolumePanel->Invalidate(true);
371 else if (orientationStatus == ORIENTATION_STATUS_PORTRAIT
372 || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
374 if (__pVolumePanel != null)
376 if (clientBounds.width > 1200)
378 __pVolumePanel->SetPosition(0, clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50);
382 __pVolumePanel->SetBounds( Rectangle(0
383 , clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
387 __pVolumePanel->Invalidate(true);
391 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
392 pContentsTableView->UpdateTableView();
393 __pContentsListViewPanel->Invalidate(true);
398 PlayerForm::OnTerminating(void)
400 AppLogDebug("ENTER");
401 ThumbnailBase::Stop();
402 if (__pAlbumArtElements)
404 __pAlbumArtElements->Destroy();
405 __pAlbumArtElements = null;
408 __isRunByAppControl = false;
412 RemovePlayListPicker();
415 RemoveOrientationEventListener(*this);
416 RemoveKeyEventListener(*this);
418 delete __pSoundPathPopup;
419 __pSoundPathPopup = null;
421 if (__pAnimationFinishedTimer != null)
423 __pAnimationFinishedTimer->Cancel();
424 delete __pAnimationFinishedTimer;
427 if (__pContentPlayTimer != null)
429 __pContentPlayTimer->Cancel();
430 delete __pContentPlayTimer;
433 if (__pPlayerPresentationModel != null)
435 __pPlayerPresentationModel->RemoveMusicPlayerEventListener(*this);
436 __pPlayerPresentationModel->DestroyPlayerPresentationModel();
438 SettingPresentationModel::GetInstance()->DestroySettingPresentationModel();
444 PlayerForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
446 AppLogDebug("ENTER");
447 SceneManager* pSceneManager = SceneManager::GetInstance();
448 AppAssert(pSceneManager);
452 case IDA_BUTTON_CONTENTS_ALBUM_VIEW:
454 CancelAllThumbnailRequest();
455 __pContentsListViewPanel->SetShowState(false);
456 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
457 __pContentsAlbumViewPanel->SetShowState(true);
458 __pPanelRegisterBar->Invalidate(true);
462 case IDA_BUTTON_CONTENTS_LIST_VIEW:
464 __pContentsAlbumViewPanel->SetShowState(false);
465 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_ALBUM_VIEW);
467 if (__pContentsListViewPanel->IsEnabled() == false)
469 __pContentsListViewPanel->SetEnabled(true);
470 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
471 pContentsTableView->UpdateTableView();
473 __pContentsListViewPanel->SetShowState(true);
474 __pPanelRegisterBar->Invalidate(true);
478 case IDA_PLAYER_CONTROLLER_VOLUME:
480 if (__pVolumePanel == null)
482 InitializeVolumeBar();
486 if (__pVolumePanel->GetShowState() == true)
488 __pVolumePanel->SetShowState(false);
492 int MediaSoundVolume = 0;
493 SettingInfo::GetValue(MEDIA_VOLUME, MediaSoundVolume);
494 __pPlayerPresentationModel->SetVolume(MediaSoundVolume);
495 __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
496 __pVolumeSlider->Invalidate(true);
497 __pVolumePanel->SetShowState(true);
503 case IDA_PLAYER_CONTROLLER_PLAY:
505 String* currentPlayConent = __pPlayerPresentationModel->GetPlayContentPath();
506 String* ContentPath = __pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetCurrentContentIndex());
508 if (currentPlayConent->Equals(*ContentPath))
510 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), __pPlayStateSlider->GetValue(), true);
514 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), __pPlayStateSlider->GetValue());
517 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
519 SetFileNotExistState(false);
524 case IDA_PLAYER_CONTROLLER_PAUSE:
526 __pPlayerPresentationModel->Pause();
530 case IDA_PLAYER_CONTROLLER_BACK:
532 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_DESTROY_OPTION_KEEP));
535 UiApp* pApp = UiApp::GetInstance();
541 case IDA_PLAYER_CONTROLLER_REPEAT:
543 switch (__pPlayerPresentationModel->GetRepeatState())
545 case IDA_TYPE_REPEAT_A:
547 SetRepeatButtonImage(IDA_TYPE_REPEAT_ONE);
551 case IDA_TYPE_REPEAT_ONE:
553 SetRepeatButtonImage(IDA_TYPE_REPEAT_ALL);
557 case IDA_TYPE_REPEAT_ALL:
559 SetRepeatButtonImage(IDA_TYPE_REPEAT_A);
569 case IDA_PLAYER_CONTROLLER_SHUFFLE:
571 if (__pPlayerPresentationModel->IsShuffleEnable() == false)
573 SetShuffleButtonImage(true);
577 SetShuffleButtonImage(false);
582 case IDA_PLAYER_CONTROLLER_MORE:
584 if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_NORMAL)
586 CreateContextMenuN(source);
587 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_SET_AS | CONTEXT_MENU_ITEM_STYLE_DETAILS | CONTEXT_MENU_ITEM_STYLE_SHARE_VIA
588 | CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST | CONTEXT_MENU_ITEM_STYLE_SETTINGS);
590 else if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_APP_CONTROL)
592 CreateContextMenuN(source);
593 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_SET_AS | CONTEXT_MENU_ITEM_STYLE_DETAILS | CONTEXT_MENU_ITEM_STYLE_SHARE_VIA);
598 case IDA_CONTEXT_MENU_ITEM_SHARE_VIA:
600 LanucherPicker(PICKER_TYPE_SHARE_PICKER);
604 case IDA_CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST:
606 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
610 case IDA_CONTEXT_MENU_ITEM_STYLE_SET_AS:
612 LanucherPicker(PICKER_TYPE_SET_AS_PICKER);
616 case IDA_CONTEXT_MENU_ITEM_STYLE_SOUND_PATH:
618 if (__pSoundPathPopup == null)
620 __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
621 __pSoundPathPopup->Initialize();
623 __pSoundPathPopup->ShowPopup(true);
627 case IDA_CONTEXT_MENU_ITEM_STYLE_DETAILS:
629 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTENT_DETAIL));
633 case IDA_CONTEXT_MENU_ITEM_SETTINGS:
635 SettingPresentationModel::GetInstance()->InitializeSettingValue();
636 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_MUSIC_SETTING));
644 TryRemoveContextMenu(actionId);
649 PlayerForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
651 AppLogDebug("ENTER");
656 if (__pVolumePanel == null)
658 InitializeVolumeBar();
661 __pVolumePanel->SetShowState(true);
662 __pPlayerPresentationModel->SetVolume(__pPlayerPresentationModel->GetVolume() + 1);
663 __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
664 __pVolumeSlider->Invalidate(true);
670 if (__pVolumePanel == null)
672 InitializeVolumeBar();
675 __pVolumePanel->SetShowState(true);
676 __pPlayerPresentationModel->SetVolume(__pPlayerPresentationModel->GetVolume() - 1);
677 __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
678 __pVolumeSlider->Invalidate(true);
689 PlayerForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
691 AppLogDebug("ENTER");
696 PlayerForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
698 AppLogDebug("ENTER");
703 PlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
705 AppLogDebug("ENTER");
706 if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
708 __isLongPressed = true;
709 if (source.Equals(*__pRewindButton))
711 __pPlayerPresentationModel->SeekToRewind();
715 __pPlayerPresentationModel->SeekToForward();
722 PlayerForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
724 AppLogDebug("ENTER");
725 if (__isAnimationPerformed == true)
730 if (currentPosition.y < 0 || currentPosition.y > GetBounds().height - __pControllerPanel->GetBounds().height)
735 if (Tizen::Base::Utility::Math::Abs(touchInfo.GetStartPosition().y - currentPosition.y) > 100)
740 if (currentPosition.x > touchInfo.GetStartPosition().x + 100)
742 if (__pPlayerPresentationModel->GetContentListCount() > 1)
744 while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetPreviousContentIndex()) == false
745 && __pPlayerPresentationModel->GetContentListCount() > 0)
747 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetPreviousContentIndex()));
750 flickDirection = FLICK_DIRECTION_RIGHT;
751 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
753 MessageBox messageBox;
754 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
757 messageBox.ShowAndWait(modalResult);
762 __isAnimationPerformed = true;
765 else if (currentPosition.x < touchInfo.GetStartPosition().x - 100)
767 if (__pPlayerPresentationModel->GetContentListCount() > 1)
769 while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetNextContentIndex()) == false
770 && __pPlayerPresentationModel->GetContentListCount() > 0)
772 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetNextContentIndex()));
775 flickDirection = FLICK_DIRECTION_LEFT;
776 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
778 MessageBox messageBox;
779 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
782 messageBox.ShowAndWait(modalResult);
787 __isAnimationPerformed = true;
794 PlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
796 AppLogDebug("ENTER");
797 if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
799 __isLongPressed = false;
803 if (!(currentPosition.y < 0 || currentPosition.y > GetBounds().height - __pControllerPanel->GetBounds().height))
805 __isAnimationPerformed = false;
808 if (__pVolumePanel != null && __pVolumePanel->GetShowState())
810 __pVolumePanel->SetShowState(false);
817 PlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
819 AppLogDebug("ENTER");
820 if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
822 if (__isLongPressed == true)
824 __pPlayerPresentationModel->StopForwardRewind();
828 if (source.Equals(*__pRewindButton))
830 if (__pPlayerPresentationModel->GetContentListCount() > 1)
832 while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetPreviousContentIndex()) == false
833 && __pPlayerPresentationModel->GetContentListCount() > 0)
835 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetPreviousContentIndex()));
838 flickDirection = FLICK_DIRECTION_RIGHT;
840 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
842 MessageBox messageBox;
843 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
846 messageBox.ShowAndWait(modalResult);
855 if (__pPlayerPresentationModel->GetContentListCount() > 1)
857 while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetNextContentIndex()) == false
858 && __pPlayerPresentationModel->GetContentListCount() > 0)
860 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetNextContentIndex()));
863 flickDirection = FLICK_DIRECTION_LEFT;
865 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
867 MessageBox messageBox;
868 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
871 messageBox.ShowAndWait(modalResult);
888 PlayerForm::PlayAnimation(void)
890 AppLogDebug("ENTER");
891 if (AnimationTransaction::GetStatus(__transactionID) == ANIMATION_TRANSACTION_STATUS_STOPPED)
893 if (flickDirection == FLICK_DIRECTION_RIGHT)
895 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(true);
897 AnimationTransaction::Begin(__transactionID);
898 AnimationTransaction::SetVisualElementAnimationDuration(200);
899 AnimationTransaction::SetCurrentTransactionEventListener(this);
901 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
902 pAnimation->SetPropertyName(L"bounds");
903 pAnimation->SetStartValue(Variant(rectanglePreviousElement));
904 pAnimation->SetEndValue(Variant(rectangleCurrentElement));
906 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->AddAnimation(*pAnimation);
909 pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
910 pAnimation->SetPropertyName(L"bounds");
911 pAnimation->SetStartValue(Variant(rectangleCurrentElement));
912 pAnimation->SetEndValue(Variant(rectangleNextElement));
914 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->AddAnimation(*pAnimation);
916 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(false);
919 AnimationTransaction::Commit();
921 else if (flickDirection == FLICK_DIRECTION_LEFT)
923 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(true);
925 AnimationTransaction::Begin(__transactionID);
926 AnimationTransaction::SetVisualElementAnimationDuration(200);
927 AnimationTransaction::SetCurrentTransactionEventListener(this);
929 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
930 pAnimation->SetPropertyName(L"bounds");
931 pAnimation->SetStartValue(Variant(rectangleCurrentElement));
932 pAnimation->SetEndValue(Variant(rectanglePreviousElement));
934 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->AddAnimation(*pAnimation);
937 pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
938 pAnimation->SetPropertyName(L"bounds");
939 pAnimation->SetStartValue(Variant(rectangleNextElement));
940 pAnimation->SetEndValue(Variant(rectangleCurrentElement));
942 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->AddAnimation(*pAnimation);
943 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(false);
946 AnimationTransaction::Commit();
957 PlayerForm::StopAnimation(void)
959 AppLogDebug("ENTER");
964 PlayerForm::OnAnimationTransactionStarted(int transactionId)
966 AppLogDebug("ENTER");
967 __pContentPlayTimer->Cancel();
972 PlayerForm::OnAnimationTransactionStopped(int transactionId)
974 AppLogDebug("ENTER");
979 PlayerForm::OnAnimationTransactionFinished(int transactionId)
981 AppLogDebug("ENTER");
982 __pAnimationFinishedTimer->Start(1);
983 __pContentPlayTimer->Start(700);
988 PlayerForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
990 AppLogDebug("ENTER");
991 if (source.Equals(*__pPlayStateSlider))
993 __pPlayerPresentationModel->SetPlayPosition(value);
997 __pPlayerPresentationModel->SetVolume(value);
1003 PlayerForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1005 AppLogDebug("ENTER");
1006 if (&timer == __pAnimationFinishedTimer)
1008 if (flickDirection == FLICK_DIRECTION_RIGHT)
1010 Tizen::Ui::Animations::VisualElement* pTempVisualElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT];
1011 pTempVisualElement->SetBounds(rectanglePreviousElement);
1013 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT] = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT];
1014 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT] = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS];
1015 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS] = pTempVisualElement;
1016 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(false);
1018 __pPlayerPresentationModel->MovePreviousContent(true);
1020 else if (flickDirection == FLICK_DIRECTION_LEFT)
1022 Tizen::Ui::Animations::VisualElement* pTempVisualElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS];
1023 pTempVisualElement->SetBounds(rectangleNextElement);
1025 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS] = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT];
1026 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT] = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT];
1027 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT] = pTempVisualElement;
1028 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(false);
1030 __pPlayerPresentationModel->MoveNextContent();
1032 flickDirection = FLICK_DIRECTION_NONE;
1033 __transactionID = ANIMATION_TRANSACTION_STATUS_STOPPED;
1037 if ((__pPlayerPresentationModel->GetPlayerState() != PLAYER_STATE_PAUSED) && (__pPlayerPresentationModel->IsDuringCall() == false))
1039 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), MIN_PLAY_STATE_SLIDER_COUNT);
1041 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1043 SetFileNotExistState(false);
1046 AppLogDebug("EXIT");
1050 PlayerForm::GetItemCount(void)
1052 AppLogDebug("ENTER");
1053 if (__pPlayerPresentationModel == null)
1057 AppLogDebug("EXIT");
1058 return __pPlayerPresentationModel->GetContentListCount();
1061 Tizen::Ui::Controls::TableViewItem*
1062 PlayerForm::CreateItem(int index, int itemWidth)
1064 AppLogDebug("ENTER");
1065 RelativeLayout layout;
1068 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1069 ContentInformation* pContentInfo = __pPlayerPresentationModel->GetContentInfoN(index);
1071 result r = pItem->Construct(layout, Dimension(itemWidth, ITEM_HEIGHT), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1072 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
1073 TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
1075 r = CreateTableViewItem(*pItem, *pContentInfo);
1076 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
1078 RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(index)));
1079 delete pContentInfo;
1081 AppLogDebug("EXIT");
1085 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1086 delete pContentInfo;
1091 PlayerForm::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1093 AppLogDebug("ENTER");
1096 AppLogDebug("EXIT");
1101 PlayerForm::GetDefaultItemHeight(void)
1103 AppLogDebug("ENTER");
1104 AppLogDebug("EXIT");
1109 PlayerForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1111 AppLogDebug("ENTER");
1112 SceneManager* pSceneManager = SceneManager::GetInstance();
1113 AppAssert(pSceneManager);
1115 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1117 __pPlayerPresentationModel->Play(itemIndex, MIN_PLAY_STATE_SLIDER_COUNT);
1119 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1121 SetFileNotExistState(false);
1124 AppLogDebug("EXIT");
1128 PlayerForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1130 AppLogDebug("ENTER");
1131 AppLogDebug("EXIT");
1135 PlayerForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo)
1137 AppLogDebug("ENTER");
1138 AppLogDebug("EXIT");
1142 PlayerForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1144 AppLogDebug("ENTER");
1145 AppLogDebug("EXIT");
1149 PlayerForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1150 const Tizen::Ui::Scenes::SceneId& currentSceneId,
1151 Tizen::Base::Collection::IList* pArgs)
1153 AppLogDebug("ENTER");
1154 MusicPlayerApp* pMusicPlayerApp = static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance());
1155 TryReturnVoid(pMusicPlayerApp != null, "Unable to cast UiApp to MusicPlayerApp");
1156 /* Comment out this code temporarily in 2.0. This will be supported in 2.1.
1157 SetKeyCapture(KEY_SIDE_UP);
1158 SetKeyCapture(KEY_SIDE_DOWN);
1161 __pPlayerPresentationModel->AddMusicPlayerEventListener(*this);
1164 if (IsFailed(__pPlayerPresentationModel->SetContentList(pArgs)))
1166 AppLogDebug("__pPlayerPresentationModel->SetContentList failed(%s)", GetErrorMessage(GetLastResult()));
1167 SetPlayerScreenState(PLAYER_SCREEN_STATE_NO_CONTENT_LIST);
1171 __pPlayerPresentationModel->Play(static_cast<Integer*>(pArgs->GetAt(1))->ToInt(), MIN_PLAY_STATE_SLIDER_COUNT);
1172 SetRepeatButtonImage(__pPlayerPresentationModel->GetRepeatState());// 0 - 2 (OFF, ONE, ALL)
1173 SetShuffleButtonImage(__pPlayerPresentationModel->IsShuffleEnable());// 0 - 1 (OFF, ON)
1174 TogglePlayPauseImage(__pPlayerPresentationModel->GetPlayerState());
1176 if (!static_cast<String*>(pArgs->GetAt(0))->Equals(MUSIC, false))
1178 SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1181 pArgs->RemoveAll(true);
1186 if (__pPlayerPresentationModel->GetContentListCount() == INIT_VALUE)
1188 AppLogDebug("__pPlayerPresentationModel->GetContentListCount() is 0");
1189 SetPlayerScreenState(PLAYER_SCREEN_STATE_NO_CONTENT_LIST);
1193 SetContentInfo( __pPlayerPresentationModel->GetCurrentContentIndex());
1194 OnPlayStateChanged(__pPlayerPresentationModel->GetPlayerState());
1195 OnPlayTimeChanged(__pPlayerPresentationModel->GetCurrentDuration(), __pPlayerPresentationModel->GetPlayPosition());
1197 if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_DURING_CALL)
1199 SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1203 if (__pContentsListViewPanel->IsEnabled() == true && __isRunByAppControl == false)
1205 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1206 pContentsTableView->UpdateTableView();
1209 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1211 SetFileNotExistState(false);
1215 AppLogDebug("EXIT");
1219 PlayerForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
1220 const Tizen::Ui::Scenes::SceneId& nextSceneId)
1222 AppLogDebug("ENTER");
1223 CancelAllThumbnailRequest();
1224 __pPlayerPresentationModel->RemoveMusicPlayerEventListener(*this);
1226 if (__pVolumePanel != null && __pVolumePanel->GetShowState())
1228 __pVolumePanel->SetShowState(false);
1230 AppLogDebug("EXIT");
1234 PlayerForm::OnChangedContentList(Tizen::Base::Collection::IList* pArgs)
1236 AppLogDebug("ENTER");
1237 MusicPlayerApp* pMusicPlayerApp = static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance());
1238 TryReturnVoid(pMusicPlayerApp != null, "Unable to cast UiApp to MusicPlayerApp");
1242 AppLogDebug("%d", pArgs->GetCount());
1243 __pPlayerPresentationModel->SetContentList(pArgs);
1245 int playIndex = (static_cast<Integer*>(pArgs->GetAt(1)))->ToInt();
1246 __pPlayerPresentationModel->Play(playIndex, MIN_PLAY_STATE_SLIDER_COUNT);
1249 if (__pContentsListViewPanel->GetShowState() == true)
1251 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1252 pContentsTableView->UpdateTableView();
1255 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1257 SetFileNotExistState(false);
1260 AppLogDebug("EXIT");
1264 PlayerForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1266 AppLogDebug("ENTER");
1267 AppLogDebug("OnUserEventReceivedN %d", requestId);
1268 if (requestId == ID_DESTORY_PLAY_LIST_PICKER_POPUP || requestId == ID_DESTORY_SHARE_POPUP)
1270 RemovePlayListPicker();
1271 RemoveSharePicker();
1276 pArgs->RemoveAll(true);
1279 AppLogDebug("EXIT");
1283 PlayerForm::OnPlayStateChanged(PlayerState playerState)
1285 AppLogDebug("ENTER");
1286 AppLogDebug("%d", playerState);
1287 if (playerState == PLAYER_STATE_ERROR)
1289 RemoveContextMenu();
1290 SetContentInfo( __pPlayerPresentationModel->GetCurrentContentIndex());
1291 SetPlayerScreenState(PLAYER_SCREEN_STATE_ERROR_CONTENT);
1292 ShowMessageBox(L"file play failed");
1295 if (playerState == PLAYER_STATE_PAUSED)
1297 if (__pPlayerPresentationModel->IsDuringCall() == true)
1299 SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1302 TogglePlayPauseImage(playerState);
1303 AppLogDebug("EXIT");
1307 PlayerForm::OnPlayContentChanged(int currentContentIndex)
1309 AppLogDebug("ENTER");
1310 SetContentInfo(currentContentIndex);
1311 if ( __pPlayerPresentationModel->IsDuringCall() == false)
1313 SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1317 SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1319 AppLogDebug("EXIT");
1323 PlayerForm::OnPlayContentRemoved(int removedContentIndex)
1325 AppLogDebug("ENTER");
1326 int currentIndex = __pPlayerPresentationModel->GetCurrentContentIndex();
1327 int currentContentCount = __pPlayerPresentationModel->GetContentListCount();
1329 if ((removedContentIndex == currentIndex - 1)
1330 || (currentIndex == 0 && removedContentIndex == 0)
1331 || (currentIndex == removedContentIndex)
1332 || (currentIndex == __pPlayerPresentationModel->GetPreviousContentIndex()))
1334 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_PREVIOUS);
1336 else if ((removedContentIndex == currentIndex + 1)
1337 || (currentIndex == currentContentCount - 1 && removedContentIndex == 0))
1339 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_NEXT);
1341 AppLogDebug("EXIT");
1345 PlayerForm::OnPlayVolumeBarStateChanged(void)
1347 AppLogDebug("ENTER");
1348 if (__pVolumePanel->GetShowState() == true)
1350 __pVolumePanel->SetShowState(false);
1352 AppLogDebug("EXIT");
1356 PlayerForm::OnPlayTimeChanged(const Tizen::Base::String& currentDuration, int currentPosition)
1358 AppLogDebug("ENTER");
1359 __pCurrentTimeLabel->SetText(currentDuration);
1360 __pPlayStateSlider->SetValue(currentPosition);
1361 __pCurrentTimeLabel->Invalidate(true);
1362 __pPlayStateSlider->Invalidate(true);
1363 AppLogDebug("EXIT");
1367 PlayerForm::OnAutoOffTimeChanged(int autoOffTime)
1369 AppLogDebug("ENTER");
1370 __pPlayerPresentationModel->StartAutoOffTimer(autoOffTime);
1371 AppLogDebug("EXIT");
1375 PlayerForm::OnPlayPresentationModelDestroying(void)
1377 AppLogDebug("ENTER");
1378 if (__pPlayerPresentationModel != null)
1380 __pPlayerPresentationModel = null;
1382 AppLogDebug("EXIT");
1386 PlayerForm::ShowMessageBox(const Tizen::Base::String& showText)
1388 AppLogDebug("ENTER");
1389 MessageBox messageBox;
1390 messageBox.Construct(L"Error", showText, MSGBOX_STYLE_NONE, 3000);
1391 int modalResult = 0;
1392 messageBox.ShowAndWait(modalResult);
1394 SceneManager* pSceneManager = SceneManager::GetInstance();
1395 AppAssert(pSceneManager);
1396 // if (static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance())->GetOperationId().Equals(TIZEN_APPCONTROL_OPERATION_PLAY, true)
1397 // || static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance())->GetOperationId().Equals(TIZEN_APPCONTROL_OPERATION_VIEW, true))
1399 // UiApp* pApp = UiApp::GetInstance();
1400 // pApp->Terminate();
1404 // if (pSceneManager->IsSceneAlive(IDSCN_ALL_LIST))
1406 // pSceneManager->GoBackward(BackwardSceneTransition());
1410 // UiApp* pApp = UiApp::GetInstance();
1411 // pApp->Terminate();
1414 AppLogDebug("EXIT");
1419 PlayerForm::SetContentInfo(int currentContentIndex)
1421 AppLogDebug("ENTER");
1422 ContentInformation* pContentInfoStruct = __pPlayerPresentationModel->GetContentInfoN(currentContentIndex);
1423 TryReturnVoid(pContentInfoStruct != null, "The currentContentIndex is invalid");
1425 __pTitleName->SetText(pContentInfoStruct->TitleName);
1426 __pArtistName->SetText(pContentInfoStruct->ArtistName);
1428 __pPlayStateSlider->SetRange(MIN_PLAY_STATE_SLIDER_COUNT, MAX_PLAY_STATE_SLIDER_COUNT);
1430 String totalTime = CommonUtil::GetFormatDate(pContentInfoStruct->Duration);
1431 if (totalTime.Equals(INITIAL_TIME, true) != true)
1433 __pTotalTimeLabel->SetText(totalTime);
1437 __pTotalTimeLabel->SetText(INITIAL_TIME);
1440 if (pContentInfoStruct->contentId.ToString().Equals(INVALID_VALUE_OF_CONTENT_ID, true))
1442 SetFileNotExistState(false);
1446 if (__pPlayerPresentationModel->GetPlayerState() != PLAYER_STATE_ERROR)
1448 if (__pPlayStateSlider->IsEnabled() != true)
1450 __pPlayStateSlider->SetEnabled(true);
1452 SetFileNotExistState(true);
1455 delete pContentInfoStruct;
1457 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_CURRENT);
1459 AppLogDebug("EXIT");
1463 PlayerForm::UpdateAnimationAlbumArt(AlbumArtImage position)
1465 AppLogDebug("ENTER");
1466 Bitmap* pAlbumArtBitmap[ALBUM_ART_IMAGE_COUNT] = {null, };
1467 FloatDimension floatDimension = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->GetSizeF();
1471 case ALBUM_ART_IMAGE_CURRENT:
1473 pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetCurrentContentIndex());
1474 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetPreviousContentIndex());
1475 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetNextContentIndex());
1477 pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT]->Scale(floatDimension);
1478 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]->Scale(floatDimension);
1479 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]->Scale(floatDimension);
1483 case ALBUM_ART_IMAGE_PREVIOUS:
1485 pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = null;
1486 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetPreviousContentIndex());
1487 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = null;
1489 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]->Scale(floatDimension);
1493 case ALBUM_ART_IMAGE_NEXT:
1495 pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = null;
1496 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = null;
1497 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetNextContentIndex());
1499 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]->Scale(floatDimension);
1507 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] != null)
1509 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetCanvasN();
1512 Point point(INIT_VALUE, INIT_VALUE);
1513 pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT]);
1516 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT];
1519 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] != null)
1521 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetCanvasN();
1524 Point point(INIT_VALUE, INIT_VALUE);
1525 pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]);
1528 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS];
1531 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] != null)
1533 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetCanvasN();
1536 Point point(INIT_VALUE, INIT_VALUE);
1537 pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]);
1540 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT];
1542 AppLogDebug("EXIT");
1547 PlayerForm::SetRepeatButtonImage(int repeatValue)// 0 - 2 (OFF, ONE, ALL)
1549 AppLogDebug("ENTER");
1550 Bitmap* pOptionRepeatBitmap;
1551 Bitmap* pOptionRepeatPressBitmap;
1553 switch (repeatValue)
1557 pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_A.png");
1558 pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_A_press.png");
1564 pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_1.png");
1565 pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_1_press.png");
1571 pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_all.png");
1572 pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_all_press.png");
1579 __pRepeatButton->SetNormalBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionRepeatBitmap);
1580 __pRepeatButton->SetPressedBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionRepeatPressBitmap);
1581 __pPlayerPresentationModel->SetRepeatMode(repeatValue);
1583 delete pOptionRepeatBitmap;
1584 pOptionRepeatBitmap = null;
1585 delete pOptionRepeatPressBitmap;
1586 pOptionRepeatPressBitmap = null;
1587 AppLogDebug("EXIT");
1591 PlayerForm::SetShuffleButtonImage(bool shuffleEnable)
1593 AppLogDebug("ENTER");
1594 Bitmap* pOptionShuffleBitmap;
1596 if (shuffleEnable == false)
1598 pOptionShuffleBitmap = ResourceManager::GetBitmapN(L"T02_option_shuffle_on_dim.png");
1602 pOptionShuffleBitmap = ResourceManager::GetBitmapN(L"T02_option_shuffle_on.png");
1605 __pShuffleButton->SetNormalBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionShuffleBitmap);
1606 __pPlayerPresentationModel->SetShuffleEnable(shuffleEnable);
1607 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_CURRENT);
1609 delete pOptionShuffleBitmap;
1610 pOptionShuffleBitmap = null;
1611 AppLogDebug("EXIT");
1615 PlayerForm::SetFileNotExistState(bool isFileExist)
1617 AppLogDebug("ENTER");
1618 RemoveContextMenu();
1619 __pMoreContextButton->SetEnabled(isFileExist);
1620 __pMoreContextButton->Invalidate(true);
1622 if (__isRunByAppControl == false)
1624 __pContentsViewToggleButton->SetEnabled(isFileExist);
1625 __pContentsViewToggleButton->Invalidate(true);
1627 AppLogDebug("EXIT");
1631 PlayerForm::TogglePlayPauseImage(PlayerState playerState)
1633 AppLogDebug("ENTER");
1634 if (playerState == PLAYER_STATE_PLAYING)
1636 RelativeLayout* layout = dynamic_cast<RelativeLayout*>(__pContentsAlbumViewPanel->GetLayoutN());
1637 layout->ResetCenterAligned(*static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_THUMBANIL_BACKGROUND)), CENTER_ALIGN_HORIZONTAL);
1640 Label* pAlbumTurnTable = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_TURN_TABLE));
1641 pAlbumTurnTable->SetShowState(true);
1642 SetPauseButtonImage();
1646 RelativeLayout* layout = dynamic_cast<RelativeLayout*>(__pContentsAlbumViewPanel->GetLayoutN());
1647 layout->SetCenterAligned(*static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_THUMBANIL_BACKGROUND)), CENTER_ALIGN_HORIZONTAL);
1649 Label* pAlbumTurnTable = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_TURN_TABLE));
1650 pAlbumTurnTable->SetShowState(false);
1651 SetPlayButtonImage();
1654 if (__pContentsAlbumViewPanel->GetShowState() == true)
1656 __pContentsAlbumViewPanel->Invalidate(true);
1658 AppLogDebug("EXIT");
1661 PlayerForm::SetPlayButtonImage(void)
1663 AppLogDebug("ENTER");
1664 Point point(INIT_VALUE, INIT_VALUE);
1665 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_NORMAL);
1666 __pPlayPauseButton->SetNormalBitmap(point, *pBitmap);
1669 pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_PRESSED);
1670 __pPlayPauseButton->SetPressedBitmap(point, *pBitmap);
1673 pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_DISABLED);
1674 __pPlayPauseButton->SetDisabledBitmap(point, *pBitmap);
1677 __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PLAY);
1678 __pPlayPauseButton->Invalidate(true);
1679 AppLogDebug("EXIT");
1683 PlayerForm::SetPauseButtonImage(void)
1685 AppLogDebug("ENTER");
1686 Point point(INIT_VALUE, INIT_VALUE);
1687 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_NORMAL);
1688 __pPlayPauseButton->SetNormalBitmap(point, *pBitmap);
1691 pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_PRESSED);
1692 __pPlayPauseButton->SetPressedBitmap(point, *pBitmap);
1695 pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_DISABLED);
1696 __pPlayPauseButton->SetDisabledBitmap(point, *pBitmap);
1699 __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PAUSE);
1700 __pPlayPauseButton->Invalidate(true);
1701 AppLogDebug("EXIT");
1705 PlayerForm::InitializeVolumeBar(void)
1707 AppLogDebug("ENTER");
1708 int MediaSoundVolume = 0;
1709 SettingInfo::GetValue(MEDIA_VOLUME, MediaSoundVolume);
1710 __pPlayerPresentationModel->SetVolume(MediaSoundVolume);
1712 __pVolumePanel = new (std::nothrow) Panel();
1713 __pVolumeSlider = new (std::nothrow) Slider();
1714 OrientationStatus orientationStatue = GetOrientationStatus();
1715 Rectangle clientBounds = GetClientAreaBounds();
1716 Rectangle bounds = GetBounds();
1717 RelativeLayout layout;
1720 if (orientationStatue == ORIENTATION_STATUS_LANDSCAPE
1721 || orientationStatue == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1723 AppLogDebug("CHECK %d", clientBounds.width);
1724 if (clientBounds.width > 1200)
1726 __pVolumePanel->Construct(layout, Rectangle(clientBounds.width - W_HORIZONTAL_PLAYER
1727 , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1728 , W_HORIZONTAL_PLAYER
1733 __pVolumePanel->Construct(layout, Rectangle(clientBounds.width - 670
1734 , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1739 else if (orientationStatue == ORIENTATION_STATUS_PORTRAIT
1740 || orientationStatue == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1742 __pVolumePanel->Construct(layout, Rectangle(0
1743 , clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1744 , clientBounds.width
1748 if (clientBounds.width > 1200)
1750 __pVolumeSlider->Construct(Rectangle(0
1751 , 0, W_HORIZONTAL_PLAYER, H_VOLUME_PANEL)
1752 , BACKGROUND_STYLE_NONE
1754 , MIN_VOLUME_SLIDER_COUNT
1755 , MAX_VOLUME_SLIDER_COUNT
1756 , GROUP_STYLE_NONE);
1760 __pVolumeSlider->Construct(Rectangle(0
1761 , 0, 680, H_VOLUME_PANEL)
1762 , BACKGROUND_STYLE_NONE
1764 , MIN_VOLUME_SLIDER_COUNT
1765 , MAX_VOLUME_SLIDER_COUNT
1766 , GROUP_STYLE_NONE);
1769 __pVolumeSlider->SetColor(TRANSPARENT_COLOR);
1770 AddControl(*__pVolumePanel);
1771 __pVolumePanel->AddControl(*__pVolumeSlider);
1772 CommonUtil::SetLayoutFitToContainer(*__pVolumePanel, *__pVolumeSlider);
1774 Bitmap* pVolumeLeftIconBitmap = ResourceManager::GetBitmapN(L"T02_volume_icon_01.png");
1775 Bitmap* pVolumeRightIconBitmap = ResourceManager::GetBitmapN(L"T02_volume_icon_02.png");
1777 __pVolumeSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *ResourceManager::GetBitmapN(L"T02_player_progress_handle.png"));
1778 __pVolumeSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *ResourceManager::GetBitmapN(L"T02_player_progress_handle_press.png"));
1779 __pVolumeSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL, Color(255, 255, 255, 0));
1780 __pVolumeSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED, Color(255, 255, 255, 0));
1782 __pVolumeSlider->SetIcon(ICON_POSITION_LEFT, *pVolumeLeftIconBitmap);
1783 __pVolumeSlider->SetIcon(ICON_POSITION_RIGHT, *pVolumeRightIconBitmap);
1784 __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
1785 __pVolumeSlider->AddSliderEventListener(*this);
1787 delete pVolumeLeftIconBitmap;
1788 pVolumeLeftIconBitmap = null;
1789 delete pVolumeRightIconBitmap;
1790 pVolumeRightIconBitmap = null;
1796 PlayerForm::CreateTableViewItem(Tizen::Ui::Container& parent,
1797 const ContentInformation& contentInfoStruct)
1799 AppLogDebug("ENTER");
1800 Panel* pTableViewItem = new (std::nothrow) Panel();
1801 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL)))
1803 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
1807 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_TITLE_NAME))->SetText(contentInfoStruct.TitleName);
1808 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ARTIST_NAME))->SetText(contentInfoStruct.ArtistName);
1809 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
1811 parent.AddControl(*pTableViewItem);
1812 CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
1814 AppLogDebug("EXIT");
1819 PlayerForm::UpdateSplitBarState(void)
1821 AppLogDebug("ENTER");
1822 Label* pSplitBar = static_cast<Label*>(GetControl(IDC_SPLIT_BAR));
1823 if ((GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT) || (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE))
1825 pSplitBar->SetSize(GetClientAreaBounds().width, 0);
1829 pSplitBar->SetSize(13, GetClientAreaBounds().height);
1831 AppLogDebug("EXIT");
1835 PlayerForm::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
1837 AppLogDebug("ENTER");
1838 __pThumbnail = pThumbnailInfo->GetBitmapN();
1839 Object* pParam = pThumbnailInfo->GetUserParamN();
1842 static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW))->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1846 delete pThumbnailInfo;
1847 AppLogDebug("EXIT");
1851 PlayerForm::OnMusicContentUpdateCompleted(void)
1853 AppLogDebug("ENTER");
1854 RemoveContextMenu();
1855 RemoveSharePicker();
1856 RemovePlayListPicker();
1857 RemoveSetAsPicker();
1859 AllListPresentationModel* pPresentationModel = AllListPresentationModel::GetInstance();
1860 if (pPresentationModel == null)
1862 AppLogDebug("EXIT");
1866 IList* pList = pPresentationModel->GetContentListN();
1867 if (pList == null || pList->GetCount() == INIT_VALUE)
1869 AppLogDebug("EXIT");
1874 int iContentListCount = __pPlayerPresentationModel->GetContentListCount();
1875 for (int iCount = iContentListCount - 1; iCount >= 0; iCount--)
1877 bool isFind = false;
1878 String* pContentPath = __pPlayerPresentationModel->GetContentPath(iCount);
1879 if (pContentPath == null)
1883 IEnumerator* pIEnum = pList->GetEnumeratorN();
1884 while (pIEnum->MoveNext() == E_SUCCESS)
1886 String* pCurrentPath = static_cast<String*>(pIEnum->GetCurrent());
1887 if (pCurrentPath == null)
1892 if (pContentPath->Equals(*pCurrentPath, false))
1900 if (isFind == false)
1902 __pPlayerPresentationModel->RemoveContent(*pContentPath);
1906 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1908 SetFileNotExistState(false);
1911 if (__pContentsListViewPanel->IsEnabled() == true)
1913 if (__pPlayerPresentationModel->GetContentListCount() != INIT_VALUE)
1915 static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW))->UpdateTableView();
1917 else if (__pContentsListViewPanel->GetShowState() == true)
1919 __pContentsListViewPanel->SetShowState(false);
1920 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
1921 __pContentsAlbumViewPanel->SetShowState(true);
1922 __pPanelRegisterBar->Invalidate(true);
1925 AppLogDebug("EXIT");
1929 PlayerForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1931 AppLogDebug("ENTER");
1932 Panel* pItemPanel = static_cast<Panel*>(pItem->GetControl(IDL_CONTENTS_LIBARY_ITEM_PANEL));
1933 if (pItemPanel == null)
1935 AppLogDebug("pItemPanel is null");
1936 delete __pThumbnail;
1937 __pThumbnail = null;
1940 Label* pThumbnailLabel = static_cast<Label*>(pItemPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
1941 if (__pThumbnail == null || pThumbnailLabel == null)
1943 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
1944 delete __pThumbnail;
1945 __pThumbnail = null;
1948 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
1949 delete __pThumbnail;
1950 __pThumbnail = null;
1951 pThumbnailLabel->Invalidate(true);
1952 AppLogDebug("EXIT");
1956 PlayerForm::SetPlayerScreenState(unsigned int playerScreenState)
1958 AppLogDebug("ENTER");
1959 if (__playerScreenState == playerScreenState)
1961 AppLogDebug("EXIT");
1965 switch (playerScreenState)
1967 case PLAYER_SCREEN_STATE_NORMAL:
1969 __pVolumeButton->SetEnabled(true);
1970 __pContentsViewToggleButton->SetEnabled(true);
1971 __pShuffleButton->SetEnabled(true);
1972 __pRepeatButton->SetEnabled(true);
1973 __pRewindButton->SetEnabled(true);
1974 __pPlayPauseButton->SetEnabled(true);
1975 __pForwardButton->SetEnabled(true);
1976 __pPlayStateSlider->SetEnabled(true);
1977 __pMoreContextButton->SetEnabled(true);
1979 if (__isRunByAppControl == false)
1985 case PLAYER_SCREEN_STATE_APP_CONTROL:
1987 __pContentsViewToggleButton->SetEnabled(false);
1988 __pContentsViewToggleButton->Invalidate(true);
1989 __pShuffleButton->SetEnabled(false);
1990 __pRepeatButton->SetEnabled(false);
1992 __isRunByAppControl = true;
1996 case PLAYER_SCREEN_STATE_NO_CONTENT_LIST:
1998 __pVolumeButton->SetEnabled(false);
1999 __pContentsViewToggleButton->SetEnabled(false);
2000 __pShuffleButton->SetEnabled(false);
2001 __pRepeatButton->SetEnabled(false);
2002 __pRewindButton->SetEnabled(false);
2003 __pPlayPauseButton->SetEnabled(false);
2004 __pForwardButton->SetEnabled(false);
2005 __pPlayStateSlider->SetEnabled(false);
2006 __pMoreContextButton->SetEnabled(false);
2008 Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2009 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2014 case PLAYER_SCREEN_STATE_ERROR_CONTENT:
2016 __pPlayPauseButton->SetEnabled(false);
2017 __pPlayStateSlider->SetEnabled(false);
2018 __pMoreContextButton->SetEnabled(false);
2019 Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2020 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2025 case PLAYER_SCREEN_STATE_DURING_CALL:
2027 __pPlayPauseButton->SetEnabled(false);
2028 __pMoreContextButton->SetEnabled(false);
2029 Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2030 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2039 __playerScreenState = playerScreenState;
2041 AppLogDebug("EXIT");
2045 PlayerForm::GetPlayerScreenState(void)
2047 AppLogDebug("ENTER");
2048 AppLogDebug("EXIT");
2049 return __playerScreenState;
2053 PlayerForm::SetContextMenuItem(unsigned int contextMenuItemStyle, Tizen::Graphics::Point anchorPosition)
2055 AppLogDebug("ENTER");
2056 if (__pContextMenu == null)
2058 AppLogDebug("EXIT");
2062 CommonUtil::AddContextMenuItem(*__pContextMenu, contextMenuItemStyle);
2063 CommonUtil::ShowContextMenu(*__pContextMenu, true);
2065 if (anchorPosition.x != -1 && anchorPosition.y != -1)
2067 __pContextMenu->SetAnchorPosition(anchorPosition);
2069 AppLogDebug("EXIT");
2074 PlayerForm::CreateContextMenuN(const Tizen::Ui::Control& source)
2076 AppLogDebug("ENTER");
2077 RemoveContextMenu();
2078 __pContextMenu = CommonUtil::CreateContextMenuN(source, *this);
2079 if (__pContextMenu != null)
2083 AppLogDebug("EXIT");
2088 PlayerForm::RemoveContextMenu(void)
2090 AppLogDebug("ENTER");
2091 if (__pContextMenu != null)
2093 CommonUtil::SetShowStateControl(*__pContextMenu, false);
2094 delete __pContextMenu;
2095 __pContextMenu = null;
2097 AppLogDebug("EXIT");
2101 PlayerForm::TryRemoveContextMenu(int actionId)
2103 AppLogDebug("ENTER");
2104 result r = E_FAILURE;
2105 if (CommonUtil::IsVaildContextMenuItemActionId(actionId) == true)
2107 RemoveContextMenu();
2110 AppLogDebug("EXIT");
2115 PlayerForm::ShowSharePicker(Tizen::Base::Collection::IList* pIList)
2117 AppLogDebug("ENTER");
2118 RemoveSharePicker();
2120 __pSharePicker = new (std::nothrow) SharePopup();
2121 if (IsFailed(__pSharePicker->Initialize(this)))
2123 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2124 RemoveSharePicker();
2128 __pSharePicker->SetArguments(pIList);
2129 __pSharePicker->SetShowState(true);
2130 __pSharePicker->Show();
2132 AppLogDebug("EXIT");
2137 PlayerForm::RemoveSharePicker(void)
2139 AppLogDebug("ENTER");
2140 if (__pSharePicker != null)
2142 CommonUtil::SetShowStateControl(*__pSharePicker, false);
2143 delete __pSharePicker;
2144 __pSharePicker = null;
2146 AppLogDebug("EXIT");
2150 PlayerForm::ShowPlayListPicker(Tizen::Base::Collection::IList* pIList)
2152 AppLogDebug("ENTER");
2153 RemovePlayListPicker();
2155 __pPlayListPicker = new (std::nothrow) PlayListPickerPopup();
2156 if (IsFailed(__pPlayListPicker->Initialize(this, pIList)))
2158 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2159 RemovePlayListPicker();
2163 __pPlayListPicker->SetShowState(true);
2164 __pPlayListPicker->Show();
2166 AppLogDebug("EXIT");
2171 PlayerForm::RemovePlayListPicker(void)
2173 AppLogDebug("ENTER");
2174 if (__pPlayListPicker != null)
2176 CommonUtil::SetShowStateControl(*__pPlayListPicker, false);
2177 delete __pPlayListPicker;
2178 __pPlayListPicker = null;
2180 AppLogDebug("EXIT");
2184 PlayerForm::ShowSetAsPicker(Tizen::Base::Collection::IList* pIList)
2186 AppLogDebug("ENTER");
2187 RemoveSetAsPicker();
2189 __pSetAsPicker = new (std::nothrow) SetAsPopup();
2190 if (IsFailed(__pSetAsPicker->Initialize(this)))
2192 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2193 RemoveSetAsPicker();
2197 __pSetAsPicker->SetCurrentContentPath(new (std::nothrow) String(*static_cast<String*>(pIList->GetAt(0))));
2198 __pSetAsPicker->SetShowState(true);
2199 __pSetAsPicker->Show();
2201 pIList->RemoveAll(true);
2204 AppLogDebug("EXIT");
2209 PlayerForm::RemoveSetAsPicker(void)
2211 AppLogDebug("ENTER");
2212 if (__pSetAsPicker != null)
2214 CommonUtil::SetShowStateControl(*__pSetAsPicker, false);
2215 delete __pSetAsPicker;
2216 __pSetAsPicker = null;
2218 AppLogDebug("EXIT");
2222 PlayerForm::LanucherPicker(PickerType pickerType)
2224 AppLogDebug("ENTER");
2225 IList* pArgumentList = GetPickerArgumentListN(pickerType);
2226 if (pArgumentList == null)
2228 AppLogDebug("GetPickerArgumentListN is null");
2232 result r = E_FAILURE;
2233 if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER)
2235 r = ShowPlayListPicker(pArgumentList);
2237 else if (pickerType == PICKER_TYPE_SHARE_PICKER)
2239 r = ShowSharePicker(pArgumentList);
2241 else if (pickerType == PICKER_TYPE_SET_AS_PICKER)
2243 r = ShowSetAsPicker(pArgumentList);
2248 AppLogDebug("ShowPlayListPicker failed(%s)", GetErrorMessage(r));
2249 delete pArgumentList;
2251 AppLogDebug("EXIT");
2255 Tizen::Base::Collection::IList*
2256 PlayerForm::GetPickerArgumentListN(PickerType pickerType)
2258 AppLogDebug("ENTER");
2262 case PICKER_TYPE_SET_AS_PICKER:
2264 case PICKER_TYPE_PLAY_LIST_PICKER:
2266 case PICKER_TYPE_SHARE_PICKER:
2268 contentPath.Append(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetCurrentContentIndex()));
2274 AppLogDebug("EXIT");
2280 Tizen::Base::Collection::ArrayList* pDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2281 if (IsFailed(pDataList->Construct()))
2283 AppLogDebug("Construct failed(%s)", GetErrorMessage(GetLastResult()));
2288 pDataList->Add(*(new (std::nothrow) String(contentPath)));
2289 AppLogDebug("EXIT");