2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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_INVALID_CONTENT_ID,
94 PLAYER_SCREEN_STATE_ERROR_CONTENT,
95 PLAYER_SCREEN_STATE_DURING_CALL,
96 PLAYER_SCREEN_STATE_MAX
99 enum IDAPlayerController
101 IDA_PLAYER_CONTROLLER_BASE = 100,
102 IDA_PLAYER_CONTROLLER_REWIND = IDA_PLAYER_CONTROLLER_BASE,
103 IDA_PLAYER_CONTROLLER_PLAY,
104 IDA_PLAYER_CONTROLLER_PAUSE,
105 IDA_PLAYER_CONTROLLER_FORWARD,
106 IDA_PLAYER_CONTROLLER_VOLUME,
107 IDA_PLAYER_CONTROLLER_REPEAT,
108 IDA_PLAYER_CONTROLLER_SHUFFLE,
109 IDA_PLAYER_CONTROLLER_BACK,
110 IDA_PLAYER_CONTROLLER_MORE,
111 IDA_PLAYER_CONTROLLER_MAX
114 PlayerForm::PlayerForm(void)
115 : __pPlayerPresentationModel(null)
116 , __pAlbumArtElements(null)
117 , __pVolumePanel(null)
118 , __pControllerPanel(null)
119 , __pPanelRegisterBar(null)
120 , __pContentsAlbumViewPanel(null)
121 , __pContentsListViewPanel(null)
122 , __pCurrentTimeLabel(null)
123 , __pTotalTimeLabel(null)
125 , __pArtistName(null)
126 , __pRewindButton(null)
127 , __pForwardButton(null)
128 , __pVolumeButton(null)
129 , __pPlayPauseButton(null)
130 , __pBackButton(null)
131 , __pRepeatButton(null)
132 , __pShuffleButton(null)
133 , __pContentsViewToggleButton(null)
134 , __pMoreContextButton(null)
135 , __pPlayStateSlider(null)
136 , __pVolumeSlider(null)
138 , __pPlayListPicker(null)
139 , __pSharePicker(null)
140 , __pSetAsPicker(null)
141 , __pSoundPathPopup(null)
142 , __isLongPressed(false)
143 , __isAppControlDuringCall(false)
144 , __flickDirection(FLICK_DIRECTION_NONE)
145 , __transactionID(ANIMATION_TRANSACTION_STATUS_STOPPED)
146 , __playerScreenState(PLAYER_SCREEN_STATE_NORMAL)
147 , __isAnimationPerformed(false)
148 , __isRunByAppControl(false)
149 , __isContentMoveCompleted(false)
150 , __prevRepeatStateRunByAppControl(0)
151 , __pAnimationFinishedTimer(null)
152 , __pContentPlayTimer(null)
153 , __pPreviousSceneId(null)
155 , __pContextMenu(null)
157 AppLogDebug("ENTER");
161 PlayerForm::~PlayerForm(void)
163 AppLogDebug("ENTER");
168 PlayerForm::Initialize(void)
170 AppLogDebug("ENTER");
171 if (IsFailed(Form::Construct(IDL_MUSIC_PLAYER_FORM)))
173 AppLogDebug("Form::Construct(IDL_MUSIC_PLAYER_FORM) failed(%s)", GetErrorMessage(GetLastResult()));
181 PlayerForm::OnInitializing(void)
183 AppLogDebug("ENTER");
185 __pControllerPanel = static_cast<Panel*>(GetControl(IDC_PLAYER_CONTROL_BAR));
186 __pTitleName = static_cast<Label*>(GetControl(IDC_CONTENTS_TITLE_NAME));
187 __pArtistName = static_cast<Label*>(GetControl(IDC_CONTENTS_ARTIST_NAME));
189 __pContentsViewToggleButton = static_cast<Button*>(GetControl(IDC_CONTENTS_VIEW_TOGGLE_BUTTON));
190 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
191 Bitmap* pContentsViewToggleNormalBitmap = ResourceManager::GetBitmapN(L"T02_icon_play_list_web.png");
193 if (pContentsViewToggleNormalBitmap != null)
195 __pContentsViewToggleButton->SetNormalBackgroundBitmap(*pContentsViewToggleNormalBitmap);
196 delete pContentsViewToggleNormalBitmap;
199 Bitmap* pContentsViewTogglePressedBitmap = ResourceManager::GetBitmapN(L"T02_icon_play_list_web_press.png");
201 if (pContentsViewTogglePressedBitmap != null)
203 __pContentsViewToggleButton->SetPressedBackgroundBitmap(*pContentsViewTogglePressedBitmap);
204 delete pContentsViewTogglePressedBitmap;
206 Bitmap* pContentsViewToggleDisabledBitmap = ResourceManager::GetBitmapN(L"T02_icon_play_list_web_dim.png");
208 if (pContentsViewToggleDisabledBitmap)
210 __pContentsViewToggleButton->SetDisabledBackgroundBitmap(*pContentsViewToggleDisabledBitmap);
211 delete pContentsViewToggleDisabledBitmap;
214 __pContentsViewToggleButton->AddActionEventListener(*this);
216 __pVolumeButton = static_cast<Button*>(__pControllerPanel->GetControl(L"IDC_OPTION_VOLUMN"));
217 __pVolumeButton->SetActionId(IDA_PLAYER_CONTROLLER_VOLUME);
218 __pVolumeButton->AddActionEventListener(*this);
219 __pShuffleButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_SHUFFLE));
220 __pShuffleButton->SetActionId(IDA_PLAYER_CONTROLLER_SHUFFLE);
221 __pShuffleButton->AddActionEventListener(*this);
222 __pRepeatButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_REPEAT));
223 __pRepeatButton->SetActionId(IDA_PLAYER_CONTROLLER_REPEAT);
224 __pRepeatButton->AddActionEventListener(*this);
226 Button* pButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_PLAY_LIST_ADD));
227 pButton->SetShowState(false);
229 __pRewindButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_PREVIOUS_CONTROL_BUTTON));
230 __pRewindButton->SetActionId(IDA_PLAYER_CONTROLLER_REWIND);
231 __pRewindButton->AddTouchEventListener(*this);
233 __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_PALY_TOGGLE_CONTROL_BUTTON));
234 __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PLAY);
235 __pPlayPauseButton->AddActionEventListener(*this);
237 __pForwardButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_NEXT_CONTROL_BUTTON));
238 __pForwardButton->SetActionId(IDA_PLAYER_CONTROLLER_FORWARD);
239 __pForwardButton->AddTouchEventListener(*this);
241 Bitmap* pBackNormalBitmap = ResourceManager::GetBitmapN(L"00_icon_Back_02_web.png");
242 Bitmap* pBackPressBitmap = ResourceManager::GetBitmapN(L"00_icon_Back_02_press_web.png");
244 __pBackButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BACK_BUTTON));
246 __pBackButton->SetNormalBitmap(__pBackButton->GetPosition(), *pBackNormalBitmap);
247 __pBackButton->SetPressedBitmap(__pBackButton->GetPosition(), *pBackPressBitmap);
249 __pBackButton->SetActionId(IDA_PLAYER_CONTROLLER_BACK);
250 __pBackButton->AddActionEventListener(*this);
252 delete pBackNormalBitmap;
253 delete pBackPressBitmap;
255 __pCurrentTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_CURRENT_PLAYING_TIME));
256 __pTotalTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_CONTENT_TOTAL_TIME));
257 __pPlayStateSlider = static_cast<Slider*>(__pControllerPanel->GetControl(IDC_SLIDER_BAR));
258 __pPlayStateSlider->AddSliderEventListener(*this);
260 __pPlayStateSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL, Color(255, 255, 255, 0));
261 __pPlayStateSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED, Color(255, 255, 255, 0));
262 __pPlayStateSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED, Color(255, 255, 255, 0));
264 __pMoreContextButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_MORE_CONTEXT_MENU_BUTTON));
266 Bitmap* pMoreContextNormalBitmap = ResourceManager::GetBitmapN(L"00_icon_more_web.png");
267 Bitmap* pMoreContextPressBitmap = ResourceManager::GetBitmapN(L"00_icon_more_press_web.png");
268 Bitmap* pMoreContextDisableBitmap = ResourceManager::GetBitmapN(L"00_icon_more_dim_web.png");
270 // __pMoreContextButton->SetNormalBitmap(__pMoreContextButton->GetPosition(), *pMoreContextNormalBitmap);
271 // __pMoreContextButton->SetPressedBitmap(__pMoreContextButton->GetPosition(), *pMoreContextPressBitmap);
272 // __pMoreContextButton->SetDisabledBitmap(__pMoreContextButton->GetPosition(), *pMoreContextDisableBitmap);
274 __pMoreContextButton->SetNormalBackgroundBitmap(*pMoreContextNormalBitmap);
275 __pMoreContextButton->SetPressedBackgroundBitmap(*pMoreContextPressBitmap);
276 __pMoreContextButton->SetDisabledBackgroundBitmap(*pMoreContextDisableBitmap);
278 __pMoreContextButton->SetActionId(IDA_PLAYER_CONTROLLER_MORE);
279 __pMoreContextButton->AddActionEventListener(*this);
281 delete pMoreContextNormalBitmap;
282 delete pMoreContextPressBitmap;
283 delete pMoreContextDisableBitmap;
285 __pAnimationFinishedTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
286 __pAnimationFinishedTimer->Construct(*this);
287 __pContentPlayTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
288 __pContentPlayTimer->Construct(*this);
289 __pPlayerPresentationModel = PlayerPresentationModel::GetInstance();
291 __pContentsListViewPanel = new (std::nothrow) Panel();
292 if (IsFailed(__pContentsListViewPanel->Construct(IDL_MUSIC_PLAYER_CONTENTS_LIST_VIEW_PANEL)))
294 AppLogDebug("Construct(IDL_MUSIC_PLAYER_CONTENTS_LIST_VIEW_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
295 delete __pContentsListViewPanel;
299 __pPanelRegisterBar = static_cast<Panel*>(GetControl(IDC_PANEL_REGISTER_BAR));
300 __pPanelRegisterBar->AddControl(__pContentsListViewPanel);
301 __pContentsListViewPanel->SetShowState(false);
302 __pContentsListViewPanel->SetEnabled(false);
304 CommonUtil::SetLayoutFitToContainer(*__pPanelRegisterBar, *__pContentsListViewPanel);
305 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
306 pContentsTableView->AddTableViewItemEventListener(*this);
307 pContentsTableView->SetItemProvider(this);
309 __pContentsAlbumViewPanel = new (std::nothrow) Panel();
310 if (IsFailed(__pContentsAlbumViewPanel->Construct(IDL_MUSIC_PLAYER_CONTENTS_ALBUM_VIEW_PANEL)))
312 AppLogDebug("Construct(IDL_MUSIC_PLAYER_CONTENTS_ALBUM_VIEW_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
313 delete __pContentsAlbumViewPanel;
316 __pPanelRegisterBar->AddControl(__pContentsAlbumViewPanel);
317 CommonUtil::SetLayoutFitToContainer(*__pPanelRegisterBar, *__pContentsAlbumViewPanel);
319 Label* pAlbumThumbnailLabel = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
320 __pContentsAlbumViewPanel->SetControlAlwaysOnTop(*pAlbumThumbnailLabel, true);
321 pAlbumThumbnailLabel->AddTouchEventListener(*this);
323 FloatDimension floatDimension = pAlbumThumbnailLabel->GetSizeF();
324 __pAlbumArtElements = new (std::nothrow) VisualElement();
325 __pAlbumArtElements->Construct();
326 __pAlbumArtElements->SetName(L"VisualElement");
327 __pAlbumArtElements->SetBounds(FloatRectangle(0.0f, 0.0f, floatDimension.width, floatDimension.height));
328 __pAlbumArtElements->SetClipChildrenEnabled(false);
329 __pAlbumArtElements->SetShowState(true);
330 pAlbumThumbnailLabel->GetVisualElement()->AttachChild(*__pAlbumArtElements);
332 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT] = new (std::nothrow) VisualElement();
333 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->Construct();
334 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->SetBounds(FloatRectangle(0.0f, 0.0f, floatDimension.width, floatDimension.height));
335 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->SetShowState(true);
336 __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]);
338 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS] = new (std::nothrow) VisualElement();
339 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->Construct();
340 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetBounds(FloatRectangle(-604.0, 0.0f, floatDimension.width, floatDimension.height));
341 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(true);
342 __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]);
344 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT] = new (std::nothrow) VisualElement();
345 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->Construct();
346 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetName(L"Rect3");
347 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetBounds(FloatRectangle(836.0, 0.0f, floatDimension.width, floatDimension.height));
349 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(true);
350 __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]);
352 rectanglePreviousElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetBounds();
353 rectangleCurrentElement = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetBounds();
354 rectangleNextElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetBounds();
356 AddOrientationEventListener(*this);
357 AddKeyEventListener(*this);
359 UpdateSplitBarState();
360 TogglePlayPauseImage(PLAYER_STATE_CLOSED);
361 SetRepeatButtonImage(__pPlayerPresentationModel->GetRepeatState());
364 return ThumbnailBase::Construct();
368 PlayerForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
370 AppLogDebug("ENTER");
371 FloatDimension floatDimension = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->GetSizeF();
373 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->SetBounds(FloatRectangle(0.0f, 0.0f, floatDimension.width, floatDimension.height));
374 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetBounds(FloatRectangle(-604.0, 0.0f, floatDimension.width, floatDimension.height));
375 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetBounds(FloatRectangle(836.0, 0.0f, floatDimension.width, floatDimension.height));
377 rectanglePreviousElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetBounds();
378 rectangleCurrentElement = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetBounds();
379 rectangleNextElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetBounds();
381 UpdateSplitBarState();
383 Rectangle clientBounds = GetClientAreaBounds();
384 if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE
385 || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
387 if (__pVolumePanel != null)
389 if (clientBounds.width > 1200)
391 __pVolumePanel->SetPosition(clientBounds.width - W_HORIZONTAL_PLAYER , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50);
395 __pVolumePanel->SetBounds(Rectangle(clientBounds.width - 670
396 , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
400 __pVolumePanel->Invalidate(true);
403 else if (orientationStatus == ORIENTATION_STATUS_PORTRAIT
404 || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
406 if (__pVolumePanel != null)
408 if (clientBounds.width > 1200)
410 __pVolumePanel->SetPosition(0, clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50);
414 __pVolumePanel->SetBounds( Rectangle(0
415 , clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
419 __pVolumePanel->Invalidate(true);
422 TogglePlayPauseImage(__pPlayerPresentationModel->GetPlayerState());
423 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
424 pContentsTableView->UpdateTableView();
425 __pContentsListViewPanel->Invalidate(true);
430 PlayerForm::OnTerminating(void)
432 AppLogDebug("ENTER");
433 ThumbnailBase::Stop();
434 if (__pAlbumArtElements)
436 __pAlbumArtElements->Destroy();
437 __pAlbumArtElements = null;
440 if (__isRunByAppControl == true)
442 __pPlayerPresentationModel->SetRepeatMode(__prevRepeatStateRunByAppControl);
443 __isRunByAppControl = false;
448 RemovePlayListPicker();
451 RemoveOrientationEventListener(*this);
452 RemoveKeyEventListener(*this);
454 delete __pSoundPathPopup;
455 __pSoundPathPopup = null;
457 if (__pAnimationFinishedTimer != null)
459 __pAnimationFinishedTimer->Cancel();
460 delete __pAnimationFinishedTimer;
463 if (__pContentPlayTimer != null)
465 __pContentPlayTimer->Cancel();
466 delete __pContentPlayTimer;
469 if (__pPlayerPresentationModel != null)
471 __pPlayerPresentationModel->RemoveMusicPlayerEventListener(*this);
472 __pPlayerPresentationModel->DestroyPlayerPresentationModel();
474 SettingPresentationModel::GetInstance()->DestroySettingPresentationModel();
480 PlayerForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
482 AppLogDebug("ENTER");
483 SceneManager* pSceneManager = SceneManager::GetInstance();
484 AppAssert(pSceneManager);
488 case IDA_BUTTON_CONTENTS_ALBUM_VIEW:
490 CancelAllThumbnailRequest();
491 __pContentsListViewPanel->SetShowState(false);
492 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
493 __pContentsAlbumViewPanel->SetShowState(true);
494 __pPanelRegisterBar->Invalidate(true);
498 case IDA_BUTTON_CONTENTS_LIST_VIEW:
500 __pContentsAlbumViewPanel->SetShowState(false);
501 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_ALBUM_VIEW);
502 __pContentsListViewPanel->SetShowState(true);
503 __pContentsListViewPanel->SetEnabled(true);
504 __pPanelRegisterBar->Invalidate(true);
506 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
507 pContentsTableView->UpdateTableView();
511 case IDA_PLAYER_CONTROLLER_VOLUME:
513 if (__pVolumePanel == null)
515 InitializeVolumeBar();
519 if (__pVolumePanel->GetShowState() == true)
521 __pVolumePanel->SetShowState(false);
525 int MediaSoundVolume = 0;
526 SettingInfo::GetValue(MEDIA_VOLUME, MediaSoundVolume);
527 __pPlayerPresentationModel->SetVolume(MediaSoundVolume);
528 __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
529 __pVolumeSlider->Invalidate(true);
530 __pVolumePanel->SetShowState(true);
536 case IDA_PLAYER_CONTROLLER_PLAY:
538 String* currentPlayConent = __pPlayerPresentationModel->GetPlayContentPath();
539 String* ContentPath = __pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetCurrentContentIndex());
541 if (currentPlayConent->Equals(*ContentPath))
543 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), __pPlayStateSlider->GetValue(), true);
547 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), __pPlayStateSlider->GetValue());
550 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
552 SetFileNotExistState(false);
557 case IDA_PLAYER_CONTROLLER_PAUSE:
559 __pPlayerPresentationModel->Pause();
563 case IDA_PLAYER_CONTROLLER_BACK:
565 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_DESTROY_OPTION_KEEP));
568 UiApp* pApp = UiApp::GetInstance();
571 __isRunByAppControl = false;
572 // else if (__isRunByAppControl)
574 // Tizen::App::UiApp::GetInstance()->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
579 case IDA_PLAYER_CONTROLLER_REPEAT:
581 switch (__pPlayerPresentationModel->GetRepeatState())
583 case IDA_TYPE_REPEAT_A:
585 SetRepeatButtonImage(IDA_TYPE_REPEAT_ONE);
589 case IDA_TYPE_REPEAT_ONE:
591 SetRepeatButtonImage(IDA_TYPE_REPEAT_ALL);
595 case IDA_TYPE_REPEAT_ALL:
597 SetRepeatButtonImage(IDA_TYPE_REPEAT_A);
607 case IDA_PLAYER_CONTROLLER_SHUFFLE:
609 if (__pPlayerPresentationModel->IsShuffleEnable() == false)
611 SetShuffleButtonImage(true);
615 SetShuffleButtonImage(false);
620 case IDA_PLAYER_CONTROLLER_MORE:
622 if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_NORMAL)
624 CreateContextMenuN(source);
625 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_SET_AS | CONTEXT_MENU_ITEM_STYLE_DETAILS | CONTEXT_MENU_ITEM_STYLE_SHARE_VIA
626 | CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST | CONTEXT_MENU_ITEM_STYLE_SETTINGS);
628 else if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_APP_CONTROL || GetPlayerScreenState() == PLAYER_SCREEN_STATE_INVALID_CONTENT_ID)
630 CreateContextMenuN(source);
631 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_SET_AS | CONTEXT_MENU_ITEM_STYLE_DETAILS | CONTEXT_MENU_ITEM_STYLE_SHARE_VIA);
636 case IDA_CONTEXT_MENU_ITEM_SHARE_VIA:
638 LanucherPicker(PICKER_TYPE_SHARE_PICKER);
642 case IDA_CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST:
644 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
648 case IDA_CONTEXT_MENU_ITEM_STYLE_SET_AS:
650 LanucherPicker(PICKER_TYPE_SET_AS_PICKER);
654 case IDA_CONTEXT_MENU_ITEM_STYLE_SOUND_PATH:
656 if (__pSoundPathPopup == null)
658 __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
659 __pSoundPathPopup->Initialize();
661 __pSoundPathPopup->ShowPopup(true);
665 case IDA_CONTEXT_MENU_ITEM_STYLE_DETAILS:
667 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTENT_DETAIL));
671 case IDA_CONTEXT_MENU_ITEM_SETTINGS:
673 SettingPresentationModel::GetInstance()->InitializeSettingValue();
674 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_MUSIC_SETTING));
682 TryRemoveContextMenu(actionId);
687 PlayerForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
689 AppLogDebug("ENTER");
694 if (__pVolumePanel == null)
696 InitializeVolumeBar();
699 __pVolumePanel->SetShowState(true);
700 __pPlayerPresentationModel->SetVolume(__pPlayerPresentationModel->GetVolume() + 1);
701 __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
702 __pVolumeSlider->Invalidate(true);
708 if (__pVolumePanel == null)
710 InitializeVolumeBar();
713 __pVolumePanel->SetShowState(true);
714 __pPlayerPresentationModel->SetVolume(__pPlayerPresentationModel->GetVolume() - 1);
715 __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
716 __pVolumeSlider->Invalidate(true);
727 PlayerForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
729 AppLogDebug("ENTER");
734 PlayerForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
736 AppLogDebug("ENTER");
741 PlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
743 AppLogDebug("ENTER");
744 if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
746 __isLongPressed = true;
747 if (source.Equals(*__pRewindButton) && (__pPlayStateSlider->IsEnabled()))
749 __pPlayerPresentationModel->SeekToRewind();
751 else if (__pPlayStateSlider->IsEnabled())
753 __pPlayerPresentationModel->SeekToForward();
760 PlayerForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
762 AppLogDebug("ENTER");
763 if (__isAnimationPerformed == true || __isContentMoveCompleted == true)
768 if (currentPosition.y < 0 || currentPosition.y > GetBounds().height - __pControllerPanel->GetBounds().height)
773 if (Tizen::Base::Utility::Math::Abs(touchInfo.GetStartPosition().y - currentPosition.y) > 100)
778 if (currentPosition.x > touchInfo.GetStartPosition().x + 100)
780 if (__pPlayerPresentationModel->GetContentListCount() > 1)
782 while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetPreviousContentIndex()) == false
783 && __pPlayerPresentationModel->GetContentListCount() > 0)
785 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetPreviousContentIndex()));
788 __flickDirection = FLICK_DIRECTION_RIGHT;
789 __isContentMoveCompleted = true;
790 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
792 MessageBox messageBox;
793 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
796 messageBox.ShowAndWait(modalResult);
803 else if (currentPosition.x < touchInfo.GetStartPosition().x - 100)
805 if (__pPlayerPresentationModel->GetContentListCount() > 1)
807 while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetNextContentIndex()) == false
808 && __pPlayerPresentationModel->GetContentListCount() > 0)
810 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetNextContentIndex()));
813 __flickDirection = FLICK_DIRECTION_LEFT;
814 __isContentMoveCompleted = true;
815 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
817 MessageBox messageBox;
818 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
821 messageBox.ShowAndWait(modalResult);
832 PlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
834 AppLogDebug("ENTER");
835 if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
837 __isLongPressed = false;
841 if (__pVolumePanel != null && __pVolumePanel->GetShowState())
843 __pVolumePanel->SetShowState(false);
850 PlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
852 AppLogDebug("ENTER");
853 __isContentMoveCompleted = false;
854 if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
856 if (__isLongPressed == true)
858 __pPlayerPresentationModel->StopForwardRewind();
862 if (source.Equals(*__pRewindButton))
864 if (__pPlayerPresentationModel->GetContentListCount() > 1)
866 while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetPreviousContentIndex()) == false
867 && __pPlayerPresentationModel->GetContentListCount() > 0)
869 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetPreviousContentIndex()));
872 __flickDirection = FLICK_DIRECTION_RIGHT;
874 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
876 MessageBox messageBox;
877 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
880 messageBox.ShowAndWait(modalResult);
889 if (__pPlayerPresentationModel->GetContentListCount() > 1)
891 while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetNextContentIndex()) == false
892 && __pPlayerPresentationModel->GetContentListCount() > 0)
894 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetNextContentIndex()));
897 __flickDirection = FLICK_DIRECTION_LEFT;
899 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
901 MessageBox messageBox;
902 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
905 messageBox.ShowAndWait(modalResult);
922 PlayerForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
924 AppLogDebug("ENTER");
925 __isContentMoveCompleted = false;
927 if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
929 if (__isLongPressed == true)
931 __pPlayerPresentationModel->StopForwardRewind();
932 __isLongPressed = false;
941 PlayerForm::PlayAnimation(void)
943 AppLogDebug("ENTER");
944 __isAnimationPerformed = true;
945 // if (AnimationTransaction::GetStatus(__transactionID) == ANIMATION_TRANSACTION_STATUS_STOPPED)
947 if (__flickDirection == FLICK_DIRECTION_RIGHT)
949 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(true);
951 AnimationTransaction::Begin(__transactionID);
952 AnimationTransaction::SetVisualElementAnimationDuration(200);
953 AnimationTransaction::SetCurrentTransactionEventListener(this);
955 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
956 pAnimation->SetPropertyName(L"bounds");
957 pAnimation->SetStartValue(Variant(rectanglePreviousElement));
958 pAnimation->SetEndValue(Variant(rectangleCurrentElement));
960 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->AddAnimation(*pAnimation);
963 pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
964 pAnimation->SetPropertyName(L"bounds");
965 pAnimation->SetStartValue(Variant(rectangleCurrentElement));
966 pAnimation->SetEndValue(Variant(rectangleNextElement));
968 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->AddAnimation(*pAnimation);
970 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(false);
973 AnimationTransaction::Commit();
975 else if (__flickDirection == FLICK_DIRECTION_LEFT)
977 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(true);
979 AnimationTransaction::Begin(__transactionID);
980 AnimationTransaction::SetVisualElementAnimationDuration(200);
981 AnimationTransaction::SetCurrentTransactionEventListener(this);
983 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
984 pAnimation->SetPropertyName(L"bounds");
985 pAnimation->SetStartValue(Variant(rectangleCurrentElement));
986 pAnimation->SetEndValue(Variant(rectanglePreviousElement));
988 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->AddAnimation(*pAnimation);
991 pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
992 pAnimation->SetPropertyName(L"bounds");
993 pAnimation->SetStartValue(Variant(rectangleNextElement));
994 pAnimation->SetEndValue(Variant(rectangleCurrentElement));
996 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->AddAnimation(*pAnimation);
997 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(false);
1000 AnimationTransaction::Commit();
1007 AppLogDebug("EXIT");
1011 PlayerForm::StopAnimation(void)
1013 AppLogDebug("ENTER");
1014 AppLogDebug("EXIT");
1018 PlayerForm::OnAnimationTransactionStarted(int transactionId)
1020 AppLogDebug("ENTER");
1021 __pContentPlayTimer->Cancel();
1022 AppLogDebug("EXIT");
1026 PlayerForm::OnAnimationTransactionStopped(int transactionId)
1028 AppLogDebug("ENTER");
1029 AppLogDebug("EXIT");
1033 PlayerForm::OnAnimationTransactionFinished(int transactionId)
1035 AppLogDebug("ENTER");
1036 __isAnimationPerformed = false;
1037 __pAnimationFinishedTimer->Start(1);
1038 __pContentPlayTimer->Start(700);
1039 AppLogDebug("EXIT");
1043 PlayerForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
1045 AppLogDebug("ENTER");
1046 if (source.Equals(*__pPlayStateSlider))
1050 __pPlayStateSlider->SetShowState(false);//To cancel touch event.
1052 __pPlayerPresentationModel->SetPlayPosition(value);
1053 __pPlayStateSlider->SetShowState(true);
1057 if (__pVolumePanel->GetShowState() == false)
1059 __pVolumePanel->SetShowState(true);
1061 __pPlayerPresentationModel->SetVolume(value);
1063 AppLogDebug("EXIT");
1067 PlayerForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1069 AppLogDebug("ENTER");
1070 if (&timer == __pAnimationFinishedTimer)
1072 if (__flickDirection == FLICK_DIRECTION_RIGHT)
1074 Tizen::Ui::Animations::VisualElement* pTempVisualElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT];
1075 pTempVisualElement->SetBounds(rectanglePreviousElement);
1077 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT] = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT];
1078 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT] = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS];
1079 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS] = pTempVisualElement;
1080 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(false);
1082 __pPlayerPresentationModel->MovePreviousContent(true);
1084 else if (__flickDirection == FLICK_DIRECTION_LEFT)
1086 Tizen::Ui::Animations::VisualElement* pTempVisualElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS];
1087 pTempVisualElement->SetBounds(rectangleNextElement);
1089 __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS] = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT];
1090 __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT] = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT];
1091 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT] = pTempVisualElement;
1092 __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(false);
1094 __pPlayerPresentationModel->MoveNextContent();
1096 __flickDirection = FLICK_DIRECTION_NONE;
1097 __transactionID = ANIMATION_TRANSACTION_STATUS_STOPPED;
1101 if ((__pPlayerPresentationModel->GetPlayerState() != PLAYER_STATE_PAUSED) && (__pPlayerPresentationModel->IsDuringCall() == false))
1103 __pPlayStateSlider->SetShowState(false);//To cancel touch event.
1104 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), MIN_PLAY_STATE_SLIDER_COUNT);
1105 __pPlayStateSlider->SetShowState(true);
1108 if(!__pPlayerPresentationModel->IsDuringCall())
1110 SetFileNotExistState(__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()));
1113 AppLogDebug("EXIT");
1117 PlayerForm::GetItemCount(void)
1119 AppLogDebug("ENTER");
1120 if (__pPlayerPresentationModel == null)
1124 AppLogDebug("EXIT");
1125 return __pPlayerPresentationModel->GetContentListCount();
1128 Tizen::Ui::Controls::TableViewItem*
1129 PlayerForm::CreateItem(int index, int itemWidth)
1131 AppLogDebug("ENTER");
1132 RelativeLayout layout;
1135 TableViewItem* pItem = new (std::nothrow) TableViewItem();
1136 ContentInformation* pContentInfo = __pPlayerPresentationModel->GetContentInfoN(index);
1138 result r = pItem->Construct(layout, Dimension(itemWidth, ITEM_HEIGHT), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1139 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
1140 TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
1142 r = CreateTableViewItem(*pItem, *pContentInfo);
1143 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
1145 RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(index)));
1146 delete pContentInfo;
1148 AppLogDebug("EXIT");
1152 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1153 delete pContentInfo;
1158 PlayerForm::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1160 AppLogDebug("ENTER");
1163 AppLogDebug("EXIT");
1168 PlayerForm::GetDefaultItemHeight(void)
1170 AppLogDebug("ENTER");
1171 AppLogDebug("EXIT");
1176 PlayerForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1178 AppLogDebug("ENTER");
1179 SceneManager* pSceneManager = SceneManager::GetInstance();
1180 AppAssert(pSceneManager);
1182 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1184 __pPlayerPresentationModel->Play(itemIndex, MIN_PLAY_STATE_SLIDER_COUNT);
1186 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1188 SetFileNotExistState(false);
1191 AppLogDebug("EXIT");
1195 PlayerForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1197 AppLogDebug("ENTER");
1198 AppLogDebug("EXIT");
1202 PlayerForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo)
1204 AppLogDebug("ENTER");
1205 AppLogDebug("EXIT");
1209 PlayerForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1211 AppLogDebug("ENTER");
1212 AppLogDebug("EXIT");
1216 PlayerForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1217 const Tizen::Ui::Scenes::SceneId& currentSceneId,
1218 Tizen::Base::Collection::IList* pArgs)
1220 AppLogDebug("ENTER");
1221 MusicPlayerApp* pMusicPlayerApp = static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance());
1222 TryReturnVoid(pMusicPlayerApp != null, "Unable to cast UiApp to MusicPlayerApp");
1223 /* Comment out this code temporarily in 2.0. This will be supported in 2.1.
1224 SetKeyCapture(KEY_SIDE_UP);
1225 SetKeyCapture(KEY_SIDE_DOWN);
1228 __pPlayerPresentationModel->AddMusicPlayerEventListener(*this);
1232 if (IsFailed(__pPlayerPresentationModel->SetContentList(pArgs)))
1234 AppLogDebug("__pPlayerPresentationModel->SetContentList failed(%s)", GetErrorMessage(GetLastResult()));
1235 SetPlayerScreenState(PLAYER_SCREEN_STATE_NO_CONTENT_LIST);
1242 __pPlayerPresentationModel->Play(static_cast<Integer*>(pArgs->GetAt(1))->ToInt(), MIN_PLAY_STATE_SLIDER_COUNT);
1243 SetFileNotExistState(__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()));
1244 SetRepeatButtonImage(__pPlayerPresentationModel->GetRepeatState());// 0 - 2 (OFF, ONE, ALL)
1245 SetShuffleButtonImage(__pPlayerPresentationModel->IsShuffleEnable());// 0 - 1 (OFF, ON)
1246 TogglePlayPauseImage(__pPlayerPresentationModel->GetPlayerState());
1249 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1250 if (pContentsTableView != null)
1252 pContentsTableView->UpdateTableView();
1255 __isAppControlDuringCall = false;
1256 __isRunByAppControl = false;
1258 if (!static_cast<String*>(pArgs->GetAt(0))->Equals(MUSIC, false))
1260 SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1264 if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_APP_CONTROL)
1266 if (__pPlayerPresentationModel->IsDuringCall())
1268 SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1272 SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1277 pArgs->RemoveAll(true);
1282 PlayerState playerState = __pPlayerPresentationModel->GetPlayerState();
1284 if (playerState != PLAYER_STATE_PAUSED
1285 && playerState != PLAYER_STATE_PLAYING
1286 && __pPlayerPresentationModel->GetContentListCount() == INIT_VALUE)
1288 playerState = PLAYER_STATE_ERROR;
1291 SetContentInfo( __pPlayerPresentationModel->GetCurrentContentIndex());
1292 OnPlayTimeChanged(__pPlayerPresentationModel->GetCurrentDuration(), __pPlayerPresentationModel->GetPlayPosition());
1293 OnPlayStateChanged(playerState);
1295 if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_DURING_CALL
1296 && playerState != PLAYER_STATE_ERROR
1297 && __pPlayerPresentationModel->IsDuringCall() == false)
1299 if(!__isAppControlDuringCall)
1301 SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1305 SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1310 if (__pContentsListViewPanel->IsEnabled() == true && __isRunByAppControl == false)
1312 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1313 pContentsTableView->UpdateTableView();
1317 AppLogDebug("EXIT");
1321 PlayerForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
1322 const Tizen::Ui::Scenes::SceneId& nextSceneId)
1324 AppLogDebug("ENTER");
1325 CancelAllThumbnailRequest();
1326 __pPlayerPresentationModel->RemoveMusicPlayerEventListener(*this);
1328 if (__pVolumePanel != null && __pVolumePanel->GetShowState())
1330 __pVolumePanel->SetShowState(false);
1332 AppLogDebug("EXIT");
1336 PlayerForm::OnChangedContentListByAppControlN(Tizen::Base::Collection::IList* pArgs)
1338 AppLogDebug("ENTER");
1339 MusicPlayerApp* pMusicPlayerApp = static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance());
1340 TryReturnVoid(pMusicPlayerApp != null, "Unable to cast UiApp to MusicPlayerApp");
1342 if (pArgs == null || static_cast<String*>(pArgs->GetAt(0))->Equals(MUSIC, false))
1344 AppLogDebug("EXIT(E_FAILURE)");
1353 result r = __pPlayerPresentationModel->SetContentList(pArgs);
1356 AppLogDebug("EXIT(%s)", GetErrorMessage(r));
1357 SetPlayerScreenState(PLAYER_SCREEN_STATE_NO_CONTENT_LIST);
1364 int playIndex = (static_cast<Integer*>(pArgs->GetAt(1)))->ToInt();
1365 __pPlayerPresentationModel->Play(playIndex, MIN_PLAY_STATE_SLIDER_COUNT);
1366 SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1368 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1369 if (pContentsTableView != null)
1371 pContentsTableView->UpdateTableView();
1378 AppLogDebug("EXIT");
1382 PlayerForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1384 AppLogDebug("ENTER");
1385 AppLogDebug("OnUserEventReceivedN %d", requestId);
1386 if (requestId == ID_DESTORY_PLAY_LIST_PICKER_POPUP || requestId == ID_DESTORY_SHARE_POPUP)
1388 RemovePlayListPicker();
1389 RemoveSharePicker();
1394 pArgs->RemoveAll(true);
1397 AppLogDebug("EXIT");
1401 PlayerForm::OnPlayStateChanged(PlayerState playerState)
1403 AppLogDebug("ENTER");
1404 AppLogDebug("%d", playerState);
1406 if (playerState == PLAYER_STATE_ERROR)
1408 MusicPlayerApp* pApp = static_cast<MusicPlayerApp*>(App::GetInstance());
1409 RemoveContextMenu();
1410 SetContentInfo( __pPlayerPresentationModel->GetCurrentContentIndex());
1412 if (__pPlayerPresentationModel->IsDuringCall())
1414 SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1418 SetPlayerScreenState(PLAYER_SCREEN_STATE_ERROR_CONTENT);
1420 ShowMessageBox(ResourceManager::GetString(L"IDS_MUSIC_POP_UNABLE_TO_PLAY_ERROR_OCCURRED"));
1422 if (pApp != null && pApp->GetRequestId() != null)
1424 AppControlProviderManager::GetInstance()->SendAppControlResult(pApp->GetRequestId(),APP_CTRL_RESULT_SUCCEEDED,null);
1425 pApp->ResetRequestId();
1429 else if (playerState == PLAYER_STATE_PAUSED)
1431 if (__pPlayerPresentationModel->IsDuringCall() == true)
1433 SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1436 TogglePlayPauseImage(playerState);
1437 AppLogDebug("EXIT");
1441 PlayerForm::OnPlayContentChanged(int currentContentIndex)
1443 AppLogDebug("ENTER");
1444 SetContentInfo(currentContentIndex);
1446 if ( __pPlayerPresentationModel->IsDuringCall())
1448 SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1450 else if (__playerScreenState == PLAYER_SCREEN_STATE_DURING_CALL || __playerScreenState == PLAYER_SCREEN_STATE_ERROR_CONTENT)
1452 if (__isAppControlDuringCall)
1454 SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1455 __isAppControlDuringCall = false;
1459 SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1462 AppLogDebug("EXIT");
1466 PlayerForm::OnPlayContentRemoved(int removedContentIndex)
1468 AppLogDebug("ENTER");
1469 int currentIndex = __pPlayerPresentationModel->GetCurrentContentIndex();
1470 int currentContentCount = __pPlayerPresentationModel->GetContentListCount();
1472 if ((removedContentIndex == currentIndex - 1)
1473 || (currentIndex == 0 && removedContentIndex == 0)
1474 || (currentIndex == removedContentIndex)
1475 || (currentIndex == __pPlayerPresentationModel->GetPreviousContentIndex()))
1477 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_PREVIOUS);
1479 else if ((removedContentIndex == currentIndex + 1)
1480 || (currentIndex == currentContentCount - 1 && removedContentIndex == 0))
1482 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_NEXT);
1484 AppLogDebug("EXIT");
1488 PlayerForm::OnPlayVolumeBarStateChanged(void)
1490 AppLogDebug("ENTER");
1491 if (__pVolumePanel->GetShowState() == true)
1493 __pVolumePanel->SetShowState(false);
1495 AppLogDebug("EXIT");
1499 PlayerForm::OnPlayTimeChanged(const Tizen::Base::String& currentDuration, int currentPosition)
1501 AppLogDebug("ENTER");
1502 __pCurrentTimeLabel->SetText(currentDuration);
1503 __pPlayStateSlider->SetValue(currentPosition);
1504 __pCurrentTimeLabel->Invalidate(true);
1505 __pPlayStateSlider->Invalidate(true);
1506 AppLogDebug("EXIT");
1510 PlayerForm::OnAutoOffTimeChanged(int autoOffTime)
1512 AppLogDebug("ENTER");
1513 __pPlayerPresentationModel->StartAutoOffTimer(autoOffTime);
1514 AppLogDebug("EXIT");
1518 PlayerForm::OnPlayPresentationModelDestroying(void)
1520 AppLogDebug("ENTER");
1521 if (__pPlayerPresentationModel != null)
1523 __pPlayerPresentationModel = null;
1525 AppLogDebug("EXIT");
1529 PlayerForm::ShowMessageBox(const Tizen::Base::String& showText)
1531 AppLogDebug("ENTER");
1532 MessageBox messageBox;
1533 messageBox.Construct(L"Error", showText, MSGBOX_STYLE_NONE, 3000);
1534 int modalResult = 0;
1535 messageBox.ShowAndWait(modalResult);
1537 SceneManager* pSceneManager = SceneManager::GetInstance();
1538 AppAssert(pSceneManager);
1539 // if (static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance())->GetOperationId().Equals(TIZEN_APPCONTROL_OPERATION_PLAY, true)
1540 // || static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance())->GetOperationId().Equals(TIZEN_APPCONTROL_OPERATION_VIEW, true))
1542 // UiApp* pApp = UiApp::GetInstance();
1543 // pApp->Terminate();
1547 // if (pSceneManager->IsSceneAlive(IDSCN_ALL_LIST))
1549 // pSceneManager->GoBackward(BackwardSceneTransition());
1553 // UiApp* pApp = UiApp::GetInstance();
1554 // pApp->Terminate();
1557 AppLogDebug("EXIT");
1562 PlayerForm::SetContentInfo(int currentContentIndex)
1564 AppLogDebug("ENTER");
1565 ContentInformation* pContentInfoStruct = __pPlayerPresentationModel->GetContentInfoN(currentContentIndex);
1566 TryReturnVoid(pContentInfoStruct != null, "The currentContentIndex is invalid");
1568 __pTitleName->SetText(pContentInfoStruct->TitleName);
1569 __pArtistName->SetText(pContentInfoStruct->ArtistName);
1571 __pPlayStateSlider->SetRange(MIN_PLAY_STATE_SLIDER_COUNT, MAX_PLAY_STATE_SLIDER_COUNT);
1573 String totalTime = CommonUtil::GetFormatDate(pContentInfoStruct->Duration);
1574 if (totalTime.Equals(INITIAL_TIME, true) != true)
1576 __pTotalTimeLabel->SetText(totalTime);
1580 __pTotalTimeLabel->SetText(INITIAL_TIME);
1583 if (pContentInfoStruct->contentId.ToString().Equals(INVALID_VALUE_OF_CONTENT_ID, true))
1585 SetPlayerScreenState(PLAYER_SCREEN_STATE_INVALID_CONTENT_ID);
1589 if (__pPlayerPresentationModel->GetPlayerState() != PLAYER_STATE_ERROR)
1591 if (__pPlayStateSlider->IsEnabled() != true)
1593 __pPlayStateSlider->SetEnabled(true);
1595 SetFileNotExistState(true);
1598 delete pContentInfoStruct;
1600 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_CURRENT);
1602 AppLogDebug("EXIT");
1606 PlayerForm::UpdateAnimationAlbumArt(AlbumArtImage position)
1608 AppLogDebug("ENTER");
1609 Bitmap* pAlbumArtBitmap[ALBUM_ART_IMAGE_COUNT] = {null, };
1610 FloatDimension floatDimension = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->GetSizeF();
1614 case ALBUM_ART_IMAGE_CURRENT:
1616 pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetCurrentContentIndex());
1618 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] != null)
1620 pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT]->Scale(floatDimension);
1622 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetPreviousContentIndex());
1624 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] != null)
1626 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]->Scale(floatDimension);
1628 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetNextContentIndex());
1630 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] != null)
1632 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]->Scale(floatDimension);
1637 case ALBUM_ART_IMAGE_PREVIOUS:
1639 pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = null;
1640 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetPreviousContentIndex());
1641 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] != null)
1643 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]->Scale(floatDimension);
1645 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = null;
1649 case ALBUM_ART_IMAGE_NEXT:
1651 pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = null;
1652 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = null;
1653 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetNextContentIndex());
1654 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] != null)
1656 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]->Scale(floatDimension);
1665 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] != null)
1667 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetCanvasN();
1671 Point point(INIT_VALUE, INIT_VALUE);
1672 pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT]);
1675 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT];
1678 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] != null)
1680 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetCanvasN();
1684 Point point(INIT_VALUE, INIT_VALUE);
1685 pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]);
1688 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS];
1691 if (pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] != null)
1693 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetCanvasN();
1697 Point point(INIT_VALUE, INIT_VALUE);
1698 pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]);
1701 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT];
1703 AppLogDebug("EXIT");
1708 PlayerForm::SetRepeatButtonImage(int repeatValue)// 0 - 2 (OFF, ONE, ALL)
1710 AppLogDebug("ENTER");
1711 Bitmap* pOptionRepeatBitmap;
1712 Bitmap* pOptionRepeatPressBitmap;
1714 switch (repeatValue)
1718 pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_A.png");
1719 pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_A_press.png");
1725 pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_1.png");
1726 pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_1_press.png");
1732 pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_all.png");
1733 pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_all_press.png");
1740 __pRepeatButton->SetNormalBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionRepeatBitmap);
1741 __pRepeatButton->SetPressedBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionRepeatPressBitmap);
1742 __pPlayerPresentationModel->SetRepeatMode(repeatValue);
1744 delete pOptionRepeatBitmap;
1745 pOptionRepeatBitmap = null;
1746 delete pOptionRepeatPressBitmap;
1747 pOptionRepeatPressBitmap = null;
1748 AppLogDebug("EXIT");
1752 PlayerForm::SetShuffleButtonImage(bool shuffleEnable)
1754 AppLogDebug("ENTER");
1755 Bitmap* pOptionShuffleBitmap;
1757 if (shuffleEnable == false)
1759 pOptionShuffleBitmap = ResourceManager::GetBitmapN(L"T02_option_shuffle_on_dim.png");
1763 pOptionShuffleBitmap = ResourceManager::GetBitmapN(L"T02_option_shuffle_on.png");
1766 __pShuffleButton->SetNormalBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionShuffleBitmap);
1767 __pPlayerPresentationModel->SetShuffleEnable(shuffleEnable);
1768 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_CURRENT);
1770 delete pOptionShuffleBitmap;
1771 pOptionShuffleBitmap = null;
1772 AppLogDebug("EXIT");
1776 PlayerForm::SetFileNotExistState(bool isFileExist)
1778 AppLogDebug("ENTER");
1779 RemoveContextMenu();
1781 if(GetPlayerScreenState() != PLAYER_SCREEN_STATE_DURING_CALL &&
1782 GetPlayerScreenState() != PLAYER_SCREEN_STATE_ERROR_CONTENT)
1784 __pMoreContextButton->SetEnabled(isFileExist);
1785 __pMoreContextButton->Invalidate(true);
1786 __pContentsViewToggleButton->SetEnabled(isFileExist);
1787 __pContentsViewToggleButton->Invalidate(true);
1788 __pShuffleButton->SetEnabled(isFileExist);
1789 __pShuffleButton->Invalidate(true);
1792 AppLogDebug("EXIT");
1796 PlayerForm::TogglePlayPauseImage(PlayerState playerState)
1798 AppLogDebug("ENTER");
1799 if (playerState == PLAYER_STATE_PLAYING)
1801 RelativeLayout* layout = dynamic_cast<RelativeLayout*>(__pContentsAlbumViewPanel->GetLayoutN());
1804 layout->ResetCenterAligned(*static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_THUMBANIL_BACKGROUND)), CENTER_ALIGN_HORIZONTAL);
1808 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_TURN_TABLE))->SetShowState(true);
1809 SetPauseButtonImage();
1813 RelativeLayout* layout = dynamic_cast<RelativeLayout*>(__pContentsAlbumViewPanel->GetLayoutN());
1816 layout->SetCenterAligned(*static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_THUMBANIL_BACKGROUND)), CENTER_ALIGN_HORIZONTAL);
1820 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_TURN_TABLE))->SetShowState(false);
1821 SetPlayButtonImage();
1824 if (__pContentsAlbumViewPanel->GetShowState() == true)
1826 __pContentsAlbumViewPanel->Invalidate(true);
1828 AppLogDebug("EXIT");
1831 PlayerForm::SetPlayButtonImage(void)
1833 AppLogDebug("ENTER");
1834 Point point(INIT_VALUE, INIT_VALUE);
1835 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_NORMAL);
1836 __pPlayPauseButton->SetNormalBitmap(point, *pBitmap);
1839 pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_PRESSED);
1840 __pPlayPauseButton->SetPressedBitmap(point, *pBitmap);
1843 pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_DISABLED);
1844 __pPlayPauseButton->SetDisabledBitmap(point, *pBitmap);
1847 __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PLAY);
1848 __pPlayPauseButton->Invalidate(true);
1849 AppLogDebug("EXIT");
1853 PlayerForm::SetPauseButtonImage(void)
1855 AppLogDebug("ENTER");
1856 Point point(INIT_VALUE, INIT_VALUE);
1857 Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_NORMAL);
1858 __pPlayPauseButton->SetNormalBitmap(point, *pBitmap);
1861 pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_PRESSED);
1862 __pPlayPauseButton->SetPressedBitmap(point, *pBitmap);
1865 pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_DISABLED);
1866 __pPlayPauseButton->SetDisabledBitmap(point, *pBitmap);
1869 __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PAUSE);
1870 __pPlayPauseButton->Invalidate(true);
1871 AppLogDebug("EXIT");
1875 PlayerForm::InitializeVolumeBar(void)
1877 AppLogDebug("ENTER");
1878 int MediaSoundVolume = 0;
1879 SettingInfo::GetValue(MEDIA_VOLUME, MediaSoundVolume);
1880 __pPlayerPresentationModel->SetVolume(MediaSoundVolume);
1882 __pVolumePanel = new (std::nothrow) Panel();
1883 __pVolumeSlider = new (std::nothrow) Slider();
1884 OrientationStatus orientationStatue = GetOrientationStatus();
1885 Rectangle clientBounds = GetClientAreaBounds();
1886 Rectangle bounds = GetBounds();
1887 RelativeLayout layout;
1890 if (orientationStatue == ORIENTATION_STATUS_LANDSCAPE
1891 || orientationStatue == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1893 AppLogDebug("CHECK %d", clientBounds.width);
1894 if (clientBounds.width > 1200)
1896 __pVolumePanel->Construct(layout, Rectangle(clientBounds.width - W_HORIZONTAL_PLAYER
1897 , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1898 , W_HORIZONTAL_PLAYER
1903 __pVolumePanel->Construct(layout, Rectangle(clientBounds.width - 670
1904 , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1909 else if (orientationStatue == ORIENTATION_STATUS_PORTRAIT
1910 || orientationStatue == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1912 __pVolumePanel->Construct(layout, Rectangle(0
1913 , clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1914 , clientBounds.width
1918 if (clientBounds.width > 1200)
1920 __pVolumeSlider->Construct(Rectangle(0
1921 , 0, W_HORIZONTAL_PLAYER, H_VOLUME_PANEL)
1922 , BACKGROUND_STYLE_NONE
1924 , MIN_VOLUME_SLIDER_COUNT
1925 , MAX_VOLUME_SLIDER_COUNT
1926 , GROUP_STYLE_NONE);
1930 __pVolumeSlider->Construct(Rectangle(0
1931 , 0, 680, H_VOLUME_PANEL)
1932 , BACKGROUND_STYLE_NONE
1934 , MIN_VOLUME_SLIDER_COUNT
1935 , MAX_VOLUME_SLIDER_COUNT
1936 , GROUP_STYLE_NONE);
1939 __pVolumeSlider->SetColor(TRANSPARENT_COLOR);
1940 AddControl(__pVolumePanel);
1941 __pVolumePanel->AddControl(__pVolumeSlider);
1942 CommonUtil::SetLayoutFitToContainer(*__pVolumePanel, *__pVolumeSlider);
1944 Bitmap* pVolumeLeftIconBitmap = ResourceManager::GetBitmapN(L"T02_volume_icon_01.png");
1945 Bitmap* pVolumeRightIconBitmap = ResourceManager::GetBitmapN(L"T02_volume_icon_02.png");
1947 __pVolumeSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *ResourceManager::GetBitmapN(L"T02_player_progress_handle.png"));
1948 __pVolumeSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *ResourceManager::GetBitmapN(L"T02_player_progress_handle_press.png"));
1949 __pVolumeSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL, Color(255, 255, 255, 0));
1950 __pVolumeSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED, Color(255, 255, 255, 0));
1952 __pVolumeSlider->SetIcon(ICON_POSITION_LEFT, *pVolumeLeftIconBitmap);
1953 __pVolumeSlider->SetIcon(ICON_POSITION_RIGHT, *pVolumeRightIconBitmap);
1954 __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
1955 __pVolumeSlider->AddSliderEventListener(*this);
1957 delete pVolumeLeftIconBitmap;
1958 pVolumeLeftIconBitmap = null;
1959 delete pVolumeRightIconBitmap;
1960 pVolumeRightIconBitmap = null;
1966 PlayerForm::CreateTableViewItem(Tizen::Ui::Container& parent,
1967 const ContentInformation& contentInfoStruct)
1969 AppLogDebug("ENTER");
1970 Panel* pTableViewItem = new (std::nothrow) Panel();
1971 if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL)))
1973 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
1977 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_TITLE_NAME))->SetText(contentInfoStruct.TitleName);
1978 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ARTIST_NAME))->SetText(contentInfoStruct.ArtistName);
1980 if(contentInfoStruct.contentId.ToString().Equals(INVALID_VALUE_OF_CONTENT_ID,true) && __playerScreenState == PLAYER_SCREEN_STATE_APP_CONTROL)
1982 Bitmap* pBmp = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetCurrentContentIndex());
1983 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pBmp);
1989 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
1993 parent.AddControl(pTableViewItem);
1994 CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
1996 AppLogDebug("EXIT");
2001 PlayerForm::UpdateSplitBarState(void)
2003 AppLogDebug("ENTER");
2004 Label* pSplitBar = static_cast<Label*>(GetControl(IDC_SPLIT_BAR));
2005 if ((GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT) || (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE))
2007 pSplitBar->SetSize(GetClientAreaBounds().width, 0);
2011 pSplitBar->SetSize(13, GetClientAreaBounds().height);
2013 AppLogDebug("EXIT");
2017 PlayerForm::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
2019 AppLogDebug("ENTER");
2020 __pThumbnail = pThumbnailInfo->GetBitmapN();
2021 Object* pParam = pThumbnailInfo->GetUserParamN();
2024 static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW))->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
2028 delete pThumbnailInfo;
2029 AppLogDebug("EXIT");
2033 PlayerForm::OnMusicContentUpdateCompleted(void)
2035 AppLogDebug("ENTER");
2036 RemoveContextMenu();
2037 RemoveSharePicker();
2038 RemovePlayListPicker();
2040 UiApp* pApp = UiApp::GetInstance();
2043 if (pApp->GetAppUiState() == APP_UI_STATE_FOREGROUND)
2045 RemoveSetAsPicker();
2048 bool isCurrentContentModified = false;
2049 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
2051 isCurrentContentModified = true;
2052 SetFileNotExistState(false);
2055 AllListPresentationModel* pPresentationModel = AllListPresentationModel::GetInstance();
2056 if (pPresentationModel == null)
2058 AppLogDebug("EXIT");
2062 pPresentationModel->UpdateContentList();
2063 IList* pList = pPresentationModel->GetContentListN();
2064 if (pList == null || pList->GetCount() == INIT_VALUE)
2066 AppLogDebug("EXIT");
2071 String* pPlayContentPath = __pPlayerPresentationModel->GetPlayContentPath();
2072 int iContentListCount = __pPlayerPresentationModel->GetContentListCount();
2073 for (int iCount = iContentListCount - 1; iCount >= 0; iCount--)
2075 bool isFind = false;
2076 String* pContentPath = __pPlayerPresentationModel->GetContentPath(iCount);
2077 if (pContentPath == null)
2081 IEnumerator* pIEnum = pList->GetEnumeratorN();
2082 while (pIEnum->MoveNext() == E_SUCCESS)
2084 String* pCurrentPath = static_cast<String*>(pIEnum->GetCurrent());
2085 if (pCurrentPath == null)
2090 if (pContentPath->Equals(*pCurrentPath, false))
2096 if (pPlayContentPath != null && pContentPath->Equals(*pPlayContentPath, false))
2104 if (isFind == false)
2106 __pPlayerPresentationModel->RemoveContent(*pContentPath);
2110 if (__pContentsListViewPanel->IsEnabled() == true)
2112 if (__pPlayerPresentationModel->GetContentListCount() != INIT_VALUE && isCurrentContentModified == false)
2114 static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW))->UpdateTableView();
2116 else if (__pContentsListViewPanel->GetShowState() == true)
2118 __pContentsListViewPanel->SetShowState(false);
2119 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
2120 __pContentsAlbumViewPanel->SetShowState(true);
2121 __pPanelRegisterBar->Invalidate(true);
2124 AppLogDebug("EXIT");
2128 PlayerForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
2130 AppLogDebug("ENTER");
2131 Panel* pItemPanel = static_cast<Panel*>(pItem->GetControl(IDL_CONTENTS_LIBARY_ITEM_PANEL));
2132 if (pItemPanel == null)
2134 AppLogDebug("pItemPanel is null");
2135 delete __pThumbnail;
2136 __pThumbnail = null;
2139 Label* pThumbnailLabel = static_cast<Label*>(pItemPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
2140 if (__pThumbnail == null || pThumbnailLabel == null)
2142 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
2143 delete __pThumbnail;
2144 __pThumbnail = null;
2147 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
2148 delete __pThumbnail;
2149 __pThumbnail = null;
2150 pThumbnailLabel->Invalidate(true);
2151 AppLogDebug("EXIT");
2155 PlayerForm::SetPlayerScreenState(unsigned int playerScreenState)
2157 AppLogDebug("ENTER %d",playerScreenState);
2159 if (__playerScreenState == playerScreenState||
2160 (playerScreenState != PLAYER_SCREEN_STATE_NORMAL &&
2161 (__playerScreenState == PLAYER_SCREEN_STATE_DURING_CALL && !__isAppControlDuringCall)))
2163 AppLogDebug("EXIT");
2167 switch (playerScreenState)
2169 case PLAYER_SCREEN_STATE_NORMAL:
2171 __pVolumeButton->SetEnabled(true);
2172 __pContentsViewToggleButton->SetEnabled(true);
2173 __pShuffleButton->SetShowState(true);
2174 __pRepeatButton->SetShowState(true);
2175 __pShuffleButton->SetEnabled(true);
2176 __pRepeatButton->SetEnabled(true);
2177 __pRewindButton->SetEnabled(true);
2178 __pPlayPauseButton->SetEnabled(true);
2179 __pForwardButton->SetEnabled(true);
2180 __pPlayStateSlider->SetEnabled(true);
2181 __pMoreContextButton->SetEnabled(true);
2183 if (__playerScreenState == PLAYER_SCREEN_STATE_INVALID_CONTENT_ID)
2185 // __pContentsViewToggleButton->SetEnabled(false);
2186 __pShuffleButton->SetEnabled(false);
2187 // __pMoreContextButton->SetEnabled(false);
2190 if (__isRunByAppControl == false)
2196 case PLAYER_SCREEN_STATE_APP_CONTROL:
2198 if(__isAppControlDuringCall)
2200 __pPlayPauseButton->SetEnabled(true);
2201 __pMoreContextButton->SetEnabled(true);
2202 __pContentsViewToggleButton->SetEnabled(true);
2203 __pPlayStateSlider->SetEnabled(true);
2206 RemoveContextMenu();
2207 __pShuffleButton->SetShowState(false);
2208 __pRepeatButton->SetShowState(false);
2209 __prevRepeatStateRunByAppControl = __pPlayerPresentationModel->GetRepeatState();
2210 // SetRepeatButtonImage(IDA_TYPE_REPEAT_A);
2212 if (__pContentsListViewPanel->GetShowState() == true)
2214 __pContentsListViewPanel->SetShowState(false);
2215 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
2216 __pContentsAlbumViewPanel->SetShowState(true);
2218 playerScreenState = PLAYER_SCREEN_STATE_APP_CONTROL;
2219 __isRunByAppControl = true;
2223 case PLAYER_SCREEN_STATE_INVALID_CONTENT_ID:
2225 // __pContentsViewToggleButton->SetEnabled(false);
2226 // __pContentsViewToggleButton->Invalidate(true);
2227 if (__playerScreenState != PLAYER_SCREEN_STATE_APP_CONTROL)
2229 __pRepeatButton->SetShowState(true);
2230 __pRepeatButton->SetEnabled(false);
2236 // __pMoreContextButton->SetEnabled(false);
2240 case PLAYER_SCREEN_STATE_NO_CONTENT_LIST:
2242 __pVolumeButton->SetEnabled(false);
2243 __pContentsViewToggleButton->SetEnabled(false);
2244 __pShuffleButton->SetShowState(true);
2245 __pRepeatButton->SetShowState(true);
2246 __pShuffleButton->SetEnabled(false);
2247 __pRepeatButton->SetEnabled(false);
2248 __pRewindButton->SetEnabled(false);
2249 __pPlayPauseButton->SetEnabled(false);
2250 __pForwardButton->SetEnabled(false);
2251 __pPlayStateSlider->SetEnabled(false);
2252 RemoveContextMenu();
2253 __pMoreContextButton->SetEnabled(false);
2255 Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2256 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2261 case PLAYER_SCREEN_STATE_ERROR_CONTENT:
2263 if (__pPlayerPresentationModel->IsDuringCall())
2265 if (__isRunByAppControl)
2267 SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
2271 SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
2277 __pPlayStateSlider->SetShowState(true);
2278 __pPlayStateSlider->SetValue(0);
2279 __pPlayPauseButton->SetEnabled(false);
2280 __pPlayStateSlider->SetEnabled(false);
2281 __pShuffleButton->SetEnabled(false);
2282 RemoveContextMenu();
2283 __pMoreContextButton->SetEnabled(false);
2284 __pPlayStateSlider->Invalidate(true);
2286 Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2287 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2293 case PLAYER_SCREEN_STATE_DURING_CALL:
2295 if(__playerScreenState == PLAYER_SCREEN_STATE_APP_CONTROL)
2297 __isAppControlDuringCall = true;
2300 __pPlayPauseButton->SetEnabled(false);
2301 RemoveContextMenu();
2302 __pMoreContextButton->SetEnabled(false);
2303 __pContentsViewToggleButton->SetEnabled(false);
2304 __pPlayStateSlider->SetEnabled(false);
2306 if (__pContentsListViewPanel->GetShowState() == true)
2308 __pContentsListViewPanel->SetShowState(false);
2309 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
2310 __pContentsAlbumViewPanel->SetShowState(true);
2313 Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2314 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2323 __playerScreenState = playerScreenState;
2325 AppLogDebug("EXIT");
2329 PlayerForm::GetPlayerScreenState(void)
2331 AppLogDebug("ENTER");
2332 AppLogDebug("EXIT");
2333 return __playerScreenState;
2337 PlayerForm::SetContextMenuItem(unsigned int contextMenuItemStyle, Tizen::Graphics::Point anchorPosition)
2339 AppLogDebug("ENTER");
2340 if (__pContextMenu == null)
2342 AppLogDebug("EXIT");
2346 CommonUtil::AddContextMenuItem(*__pContextMenu, contextMenuItemStyle);
2347 CommonUtil::ShowContextMenu(*__pContextMenu, true);
2349 if (anchorPosition.x != -1 && anchorPosition.y != -1)
2351 __pContextMenu->SetAnchorPosition(anchorPosition);
2353 AppLogDebug("EXIT");
2358 PlayerForm::CreateContextMenuN(const Tizen::Ui::Control& source)
2360 AppLogDebug("ENTER");
2361 RemoveContextMenu();
2362 __pContextMenu = CommonUtil::CreateContextMenuN(source, *this);
2363 if (__pContextMenu != null)
2367 AppLogDebug("EXIT");
2372 PlayerForm::RemoveContextMenu(void)
2374 AppLogDebug("ENTER");
2375 if (__pContextMenu != null)
2377 CommonUtil::SetShowStateControl(*__pContextMenu, false);
2378 delete __pContextMenu;
2379 __pContextMenu = null;
2381 AppLogDebug("EXIT");
2385 PlayerForm::TryRemoveContextMenu(int actionId)
2387 AppLogDebug("ENTER");
2388 result r = E_FAILURE;
2389 if (CommonUtil::IsVaildContextMenuItemActionId(actionId) == true)
2391 RemoveContextMenu();
2394 AppLogDebug("EXIT");
2399 PlayerForm::ShowSharePicker(Tizen::Base::Collection::IList* pIList)
2401 AppLogDebug("ENTER");
2402 RemoveSharePicker();
2404 __pSharePicker = new (std::nothrow) SharePopup();
2405 if (IsFailed(__pSharePicker->Initialize(this)))
2407 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2408 RemoveSharePicker();
2412 __pSharePicker->SetArguments(pIList);
2413 __pSharePicker->SetShowState(true);
2414 __pSharePicker->Show();
2416 AppLogDebug("EXIT");
2421 PlayerForm::RemoveSharePicker(void)
2423 AppLogDebug("ENTER");
2424 if (__pSharePicker != null)
2426 CommonUtil::SetShowStateControl(*__pSharePicker, false);
2427 delete __pSharePicker;
2428 __pSharePicker = null;
2430 AppLogDebug("EXIT");
2434 PlayerForm::ShowPlayListPicker(Tizen::Base::Collection::IList* pIList)
2436 AppLogDebug("ENTER");
2437 RemovePlayListPicker();
2439 __pPlayListPicker = new (std::nothrow) PlayListPickerPopup();
2440 if (IsFailed(__pPlayListPicker->Initialize(this, pIList)))
2442 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2443 RemovePlayListPicker();
2447 __pPlayListPicker->SetShowState(true);
2448 __pPlayListPicker->Show();
2450 AppLogDebug("EXIT");
2455 PlayerForm::RemovePlayListPicker(void)
2457 AppLogDebug("ENTER");
2458 if (__pPlayListPicker != null)
2460 CommonUtil::SetShowStateControl(*__pPlayListPicker, false);
2461 delete __pPlayListPicker;
2462 __pPlayListPicker = null;
2464 AppLogDebug("EXIT");
2468 PlayerForm::ShowSetAsPicker(Tizen::Base::Collection::IList* pIList)
2470 AppLogDebug("ENTER");
2471 RemoveSetAsPicker();
2473 __pSetAsPicker = new (std::nothrow) SetAsPopup();
2474 if (IsFailed(__pSetAsPicker->Initialize(this)))
2476 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2477 RemoveSetAsPicker();
2481 __pSetAsPicker->SetCurrentContentPath(new (std::nothrow) String(*static_cast<String*>(pIList->GetAt(0))));
2482 __pSetAsPicker->SetShowState(true);
2483 __pSetAsPicker->Show();
2485 pIList->RemoveAll(true);
2488 AppLogDebug("EXIT");
2493 PlayerForm::RemoveSetAsPicker(void)
2495 AppLogDebug("ENTER");
2496 if (__pSetAsPicker != null)
2498 CommonUtil::SetShowStateControl(*__pSetAsPicker, false);
2499 // delete __pSetAsPicker;
2500 // __pSetAsPicker = null;
2502 AppLogDebug("EXIT");
2506 PlayerForm::LanucherPicker(PickerType pickerType)
2508 AppLogDebug("ENTER");
2509 IList* pArgumentList = GetPickerArgumentListN(pickerType);
2510 if (pArgumentList == null)
2512 AppLogDebug("GetPickerArgumentListN is null");
2516 result r = E_FAILURE;
2517 if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER)
2519 r = ShowPlayListPicker(pArgumentList);
2521 else if (pickerType == PICKER_TYPE_SHARE_PICKER)
2523 r = ShowSharePicker(pArgumentList);
2525 else if (pickerType == PICKER_TYPE_SET_AS_PICKER)
2527 r = ShowSetAsPicker(pArgumentList);
2532 AppLogDebug("ShowPlayListPicker failed(%s)", GetErrorMessage(r));
2533 delete pArgumentList;
2535 AppLogDebug("EXIT");
2539 Tizen::Base::Collection::IList*
2540 PlayerForm::GetPickerArgumentListN(PickerType pickerType)
2542 AppLogDebug("ENTER");
2546 case PICKER_TYPE_SET_AS_PICKER:
2548 case PICKER_TYPE_PLAY_LIST_PICKER:
2550 case PICKER_TYPE_SHARE_PICKER:
2552 contentPath.Append(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetCurrentContentIndex()));
2558 AppLogDebug("EXIT");
2564 Tizen::Base::Collection::ArrayList* pDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2565 if (IsFailed(pDataList->Construct()))
2567 AppLogDebug("Construct failed(%s)", GetErrorMessage(GetLastResult()));
2572 pDataList->Add(*(new (std::nothrow) String(contentPath)));
2573 AppLogDebug("EXIT");