Fixed jira issue and fixed prevent issue
[apps/osp/MusicPlayer.git] / src / MpMusicPlayerForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                MpMusicPlayerForm.h
19  * @brief               This is the implementation file for MusicPlayerForm class.
20  */
21
22 #include <FApp.h>
23 #include <FBase.h>
24 #include <FIo.h>
25 #include <FMedia.h>
26 #include <FUi.h>
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"
41
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;
53
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;
58
59 static const int TRANSPARENT_COLOR = 0x00000000;
60
61 static const int MIN_VOLUME_SLIDER_COUNT = 0;
62 static const int MAX_VOLUME_SLIDER_COUNT = 15;
63
64 static const int IDA_BUTTON_CONTENTS_LIST_VIEW = 200;
65 static const int IDA_BUTTON_CONTENTS_ALBUM_VIEW = 201;
66
67 static const Tizen::Base::String INVALID_VALUE_OF_CONTENT_ID = L"00000000-0000-0000-0000-000000000000";
68
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";
75
76 FloatRectangle rectanglePreviousElement;
77 FloatRectangle rectangleCurrentElement;
78 FloatRectangle rectangleNextElement;
79
80 enum RepeatType
81 {
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 */
85 };
86
87 enum PlayerScreenState
88 {
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
96 };
97
98 enum IDAPlayerController
99 {
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
111 };
112
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)
123         , __pTitleName(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)
136         , __pThumbnail(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)
150         , __pPath(null)
151         , __pContextMenu(null)
152 {
153         AppLogDebug("ENTER");
154         AppLogDebug("EXIT");
155 }
156
157 PlayerForm::~PlayerForm(void)
158 {
159         AppLogDebug("ENTER");
160         AppLogDebug("EXIT");
161 }
162
163 result
164 PlayerForm::Initialize(void)
165 {
166         AppLogDebug("ENTER");
167         if (IsFailed(Form::Construct(IDL_MUSIC_PLAYER_FORM)))
168         {
169                 AppLogDebug("Form::Construct(IDL_MUSIC_PLAYER_FORM) failed(%s)", GetErrorMessage(GetLastResult()));
170                 return E_FAILURE;
171         }
172         AppLogDebug("EXIT");
173         return E_SUCCESS;
174 }
175
176 result
177 PlayerForm::OnInitializing(void)
178 {
179         AppLogDebug("ENTER");
180
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));
184
185         __pContentsViewToggleButton = static_cast<Button*>(GetControl(IDC_CONTENTS_VIEW_TOGGLE_BUTTON));
186         __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
187         __pContentsViewToggleButton->AddActionEventListener(*this);
188
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);
198
199         Button* pButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_PLAY_LIST_ADD));
200         pButton->SetShowState(false);
201
202         __pRewindButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_PREVIOUS_CONTROL_BUTTON));
203         __pRewindButton->SetActionId(IDA_PLAYER_CONTROLLER_REWIND);
204         __pRewindButton->AddTouchEventListener(*this);
205
206         __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_PALY_TOGGLE_CONTROL_BUTTON));
207         __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PLAY);
208         __pPlayPauseButton->AddActionEventListener(*this);
209
210         __pForwardButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_NEXT_CONTROL_BUTTON));
211         __pForwardButton->SetActionId(IDA_PLAYER_CONTROLLER_FORWARD);
212         __pForwardButton->AddTouchEventListener(*this);
213
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");
216
217         __pBackButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BACK_BUTTON));
218
219         __pBackButton->SetNormalBitmap(__pBackButton->GetPosition(), *pBackNormalBitmap);
220         __pBackButton->SetPressedBitmap(__pBackButton->GetPosition(), *pBackPressBitmap);
221
222         __pBackButton->SetActionId(IDA_PLAYER_CONTROLLER_BACK);
223         __pBackButton->AddActionEventListener(*this);
224
225         delete pBackNormalBitmap;
226         delete pBackPressBitmap;
227
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);
232
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));
236
237         __pMoreContextButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_MORE_CONTEXT_MENU_BUTTON));
238
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");
242
243         __pMoreContextButton->SetNormalBitmap(__pMoreContextButton->GetPosition(), *pMoreContextNormalBitmap);
244         __pMoreContextButton->SetPressedBitmap(__pMoreContextButton->GetPosition(), *pMoreContextPressBitmap);
245         __pMoreContextButton->SetDisabledBitmap(__pMoreContextButton->GetPosition(), *pMoreContextDisableBitmap);
246
247         __pMoreContextButton->SetActionId(IDA_PLAYER_CONTROLLER_MORE);
248         __pMoreContextButton->AddActionEventListener(*this);
249
250         delete pMoreContextNormalBitmap;
251         delete pMoreContextPressBitmap;
252         delete pMoreContextDisableBitmap;
253
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();
259
260         __pContentsListViewPanel = new (std::nothrow) Panel();
261         if (IsFailed(__pContentsListViewPanel->Construct(IDL_MUSIC_PLAYER_CONTENTS_LIST_VIEW_PANEL)))
262         {
263                 AppLogDebug("Construct(IDL_MUSIC_PLAYER_CONTENTS_LIST_VIEW_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
264                 delete __pContentsListViewPanel;
265                 return E_FAILURE;
266         }
267
268         __pPanelRegisterBar = static_cast<Panel*>(GetControl(IDC_PANEL_REGISTER_BAR));
269         __pPanelRegisterBar->AddControl(*__pContentsListViewPanel);
270         __pContentsListViewPanel->SetShowState(false);
271         __pContentsListViewPanel->SetEnabled(false);
272
273         CommonUtil::SetLayoutFitToContainer(*__pPanelRegisterBar, *__pContentsListViewPanel);
274         TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
275         pContentsTableView->AddTableViewItemEventListener(*this);
276         pContentsTableView->SetItemProvider(this);
277
278         __pContentsAlbumViewPanel = new (std::nothrow) Panel();
279         if (IsFailed(__pContentsAlbumViewPanel->Construct(IDL_MUSIC_PLAYER_CONTENTS_ALBUM_VIEW_PANEL)))
280         {
281                 AppLogDebug("Construct(IDL_MUSIC_PLAYER_CONTENTS_ALBUM_VIEW_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
282                 delete __pContentsAlbumViewPanel;
283                 return E_FAILURE;
284         }
285         __pPanelRegisterBar->AddControl(*__pContentsAlbumViewPanel);
286         CommonUtil::SetLayoutFitToContainer(*__pPanelRegisterBar, *__pContentsAlbumViewPanel);
287
288         Label* pAlbumThumbnailLabel = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
289         __pContentsAlbumViewPanel->SetControlAlwaysOnTop(*pAlbumThumbnailLabel, true);
290         pAlbumThumbnailLabel->AddTouchEventListener(*this);
291
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);
300
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]);
306
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]);
312
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));
317
318         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(true);
319         __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]);
320
321         rectanglePreviousElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetBounds();
322         rectangleCurrentElement = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetBounds();
323         rectangleNextElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetBounds();
324
325         AddOrientationEventListener(*this);
326         AddKeyEventListener(*this);
327
328         UpdateSplitBarState();
329         TogglePlayPauseImage(PLAYER_STATE_CLOSED);
330
331         AppLogDebug("EXIT");
332         return ThumbnailBase::Construct();
333 }
334
335 void
336 PlayerForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
337 {
338         AppLogDebug("ENTER");
339         FloatDimension floatDimension = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->GetSizeF();
340
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));
344
345         rectanglePreviousElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetBounds();
346         rectangleCurrentElement = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetBounds();
347         rectangleNextElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetBounds();
348
349         UpdateSplitBarState();
350
351         Rectangle clientBounds = GetClientAreaBounds();
352         if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE
353                 || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
354         {
355                 if (__pVolumePanel != null)
356                 {
357                         if (clientBounds.width > 1200)
358                         {
359                                 __pVolumePanel->SetPosition(clientBounds.width - W_HORIZONTAL_PLAYER , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50);
360                         }
361                         else
362                         {
363                                 __pVolumePanel->SetBounds(Rectangle(clientBounds.width - 670
364                                                                                                         , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
365                                                                                                         , 680
366                                                                                                         , H_VOLUME_PANEL));
367                         }
368                         __pVolumePanel->Invalidate(true);
369                 }
370         }
371         else if (orientationStatus == ORIENTATION_STATUS_PORTRAIT
372                         || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
373         {
374                 if (__pVolumePanel != null)
375                 {
376                         if (clientBounds.width > 1200)
377                         {
378                                 __pVolumePanel->SetPosition(0, clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50);
379                         }
380                         else
381                         {
382                                 __pVolumePanel->SetBounds( Rectangle(0
383                                                                                                         , clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
384                                                                                                         , clientBounds.width
385                                                                                                         , H_VOLUME_PANEL));
386                         }
387                         __pVolumePanel->Invalidate(true);
388                 }
389         }
390
391         TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
392         pContentsTableView->UpdateTableView();
393         __pContentsListViewPanel->Invalidate(true);
394         AppLogDebug("EXIT");
395 }
396
397 result
398 PlayerForm::OnTerminating(void)
399 {
400         AppLogDebug("ENTER");
401         ThumbnailBase::Stop();
402         if (__pAlbumArtElements)
403         {
404                 __pAlbumArtElements->Destroy();
405                 __pAlbumArtElements = null;
406         }
407
408         __isRunByAppControl =  false;
409
410         RemoveContextMenu();
411         RemoveSharePicker();
412         RemovePlayListPicker();
413         RemoveSetAsPicker();
414
415         RemoveOrientationEventListener(*this);
416         RemoveKeyEventListener(*this);
417
418         delete __pSoundPathPopup;
419         __pSoundPathPopup = null;
420
421         if (__pAnimationFinishedTimer != null)
422         {
423                 __pAnimationFinishedTimer->Cancel();
424                 delete __pAnimationFinishedTimer;
425         }
426
427         if (__pContentPlayTimer != null)
428         {
429                 __pContentPlayTimer->Cancel();
430                 delete __pContentPlayTimer;
431         }
432
433         if (__pPlayerPresentationModel != null)
434         {
435                 __pPlayerPresentationModel->RemoveMusicPlayerEventListener(*this);
436                 __pPlayerPresentationModel->DestroyPlayerPresentationModel();
437         }
438         SettingPresentationModel::GetInstance()->DestroySettingPresentationModel();
439         AppLogDebug("EXIT");
440         return E_SUCCESS;
441 }
442
443 void
444 PlayerForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
445 {
446         AppLogDebug("ENTER");
447         SceneManager* pSceneManager = SceneManager::GetInstance();
448         AppAssert(pSceneManager);
449
450         switch (actionId)
451         {
452         case IDA_BUTTON_CONTENTS_ALBUM_VIEW:
453                 {
454                         CancelAllThumbnailRequest();
455                         __pContentsListViewPanel->SetShowState(false);
456                         __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
457                         __pContentsAlbumViewPanel->SetShowState(true);
458                         __pPanelRegisterBar->Invalidate(true);
459                 }
460                 break;
461
462         case IDA_BUTTON_CONTENTS_LIST_VIEW:
463                 {
464                         __pContentsAlbumViewPanel->SetShowState(false);
465                         __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_ALBUM_VIEW);
466
467                         if (__pContentsListViewPanel->IsEnabled() == false)
468                         {
469                                 __pContentsListViewPanel->SetEnabled(true);
470                                 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
471                                 pContentsTableView->UpdateTableView();
472                         }
473                         __pContentsListViewPanel->SetShowState(true);
474                         __pPanelRegisterBar->Invalidate(true);
475                 }
476                 break;
477
478         case IDA_PLAYER_CONTROLLER_VOLUME:
479                 {
480                         if (__pVolumePanel == null)
481                         {
482                                 InitializeVolumeBar();
483                         }
484                         else
485                         {
486                                 if (__pVolumePanel->GetShowState() == true)
487                                 {
488                                         __pVolumePanel->SetShowState(false);
489                                 }
490                                 else
491                                 {
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);
498                                 }
499                         }
500                 }
501                 break;
502
503         case IDA_PLAYER_CONTROLLER_PLAY:
504                 {
505                         String* currentPlayConent = __pPlayerPresentationModel->GetPlayContentPath();
506                         String* ContentPath = __pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetCurrentContentIndex());
507
508                         if (currentPlayConent->Equals(*ContentPath))
509                         {
510                                 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), __pPlayStateSlider->GetValue(), true);
511                         }
512                         else
513                         {
514                                 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), __pPlayStateSlider->GetValue());
515                         }
516
517                         if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
518                         {
519                                 SetFileNotExistState(false);
520                         }
521                 }
522                 break;
523
524         case IDA_PLAYER_CONTROLLER_PAUSE:
525                 {
526                         __pPlayerPresentationModel->Pause();
527                 }
528                 break;
529
530         case IDA_PLAYER_CONTROLLER_BACK:
531                 {
532                         result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_DESTROY_OPTION_KEEP));
533                         if (IsFailed(r))
534                         {
535                                 UiApp* pApp = UiApp::GetInstance();
536                                 pApp->Terminate();
537                         }
538                 }
539                 break;
540
541         case IDA_PLAYER_CONTROLLER_REPEAT:
542                 {
543                         switch (__pPlayerPresentationModel->GetRepeatState())
544                         {
545                         case IDA_TYPE_REPEAT_A:
546                                 {
547                                         SetRepeatButtonImage(IDA_TYPE_REPEAT_ONE);
548                                 }
549                                 break;
550
551                         case IDA_TYPE_REPEAT_ONE:
552                                 {
553                                         SetRepeatButtonImage(IDA_TYPE_REPEAT_ALL);
554                                 }
555                                 break;
556
557                         case IDA_TYPE_REPEAT_ALL:
558                                 {
559                                         SetRepeatButtonImage(IDA_TYPE_REPEAT_A);
560                                 }
561                                 break;
562
563                         default:
564                                 break;
565                         }
566                 }
567                 break;
568
569         case IDA_PLAYER_CONTROLLER_SHUFFLE:
570                 {
571                         if (__pPlayerPresentationModel->IsShuffleEnable() == false)
572                         {
573                                 SetShuffleButtonImage(true);
574                         }
575                         else
576                         {
577                                 SetShuffleButtonImage(false);
578                         }
579                 }
580                 break;
581
582         case IDA_PLAYER_CONTROLLER_MORE:
583                 {
584                         if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_NORMAL)
585                         {
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);
589                         }
590                         else if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_APP_CONTROL)
591                         {
592                                 CreateContextMenuN(source);
593                                 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_SET_AS | CONTEXT_MENU_ITEM_STYLE_DETAILS | CONTEXT_MENU_ITEM_STYLE_SHARE_VIA);
594                         }
595                 }
596                 break;
597
598         case IDA_CONTEXT_MENU_ITEM_SHARE_VIA:
599                 {
600                         LanucherPicker(PICKER_TYPE_SHARE_PICKER);
601                 }
602                 break;
603
604         case IDA_CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST:
605                 {
606                         LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
607                 }
608                 break;
609
610         case IDA_CONTEXT_MENU_ITEM_STYLE_SET_AS:
611                 {
612                         LanucherPicker(PICKER_TYPE_SET_AS_PICKER);
613                 }
614                 break;
615
616         case IDA_CONTEXT_MENU_ITEM_STYLE_SOUND_PATH:
617                 {
618                         if (__pSoundPathPopup == null)
619                         {
620                                 __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
621                                 __pSoundPathPopup->Initialize();
622                         }
623                         __pSoundPathPopup->ShowPopup(true);
624                 }
625                 break;
626
627         case IDA_CONTEXT_MENU_ITEM_STYLE_DETAILS:
628                 {
629                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTENT_DETAIL));
630                 }
631                 break;
632
633         case IDA_CONTEXT_MENU_ITEM_SETTINGS:
634                 {
635                         SettingPresentationModel::GetInstance()->InitializeSettingValue();
636                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_MUSIC_SETTING));
637                 }
638                 break;
639
640         default:
641                 break;
642         }
643
644         TryRemoveContextMenu(actionId);
645         AppLogDebug("EXIT");
646 }
647
648 void
649 PlayerForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
650 {
651         AppLogDebug("ENTER");
652         switch (keyCode)
653         {
654         case KEY_SIDE_UP:
655                 {
656                         if (__pVolumePanel == null)
657                         {
658                                 InitializeVolumeBar();
659                         }
660
661                         __pVolumePanel->SetShowState(true);
662                         __pPlayerPresentationModel->SetVolume(__pPlayerPresentationModel->GetVolume() + 1);
663                         __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
664                         __pVolumeSlider->Invalidate(true);
665                 }
666                 break;
667
668         case KEY_SIDE_DOWN:
669                 {
670                         if (__pVolumePanel == null)
671                         {
672                                 InitializeVolumeBar();
673                         }
674
675                         __pVolumePanel->SetShowState(true);
676                         __pPlayerPresentationModel->SetVolume(__pPlayerPresentationModel->GetVolume() - 1);
677                         __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
678                         __pVolumeSlider->Invalidate(true);
679                 }
680                 break;
681
682         default:
683                 break;
684         }
685         AppLogDebug("EXIT");
686 }
687
688 void
689 PlayerForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
690 {
691         AppLogDebug("ENTER");
692         AppLogDebug("EXIT");
693 }
694
695 void
696 PlayerForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
697 {
698         AppLogDebug("ENTER");
699         AppLogDebug("EXIT");
700 }
701
702 void
703 PlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
704 {
705         AppLogDebug("ENTER");
706         if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
707         {
708                 __isLongPressed = true;
709                 if (source.Equals(*__pRewindButton))
710                 {
711                         __pPlayerPresentationModel->SeekToRewind();
712                 }
713                 else
714                 {
715                         __pPlayerPresentationModel->SeekToForward();
716                 }
717         }
718         AppLogDebug("EXIT");
719 }
720
721 void
722 PlayerForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
723 {
724         AppLogDebug("ENTER");
725         if (__isAnimationPerformed == true)
726         {
727                 return;
728         }
729
730         if (currentPosition.y < 0 || currentPosition.y > GetBounds().height - __pControllerPanel->GetBounds().height)
731         {
732                 return;
733         }
734
735         if (Tizen::Base::Utility::Math::Abs(touchInfo.GetStartPosition().y - currentPosition.y) > 100)
736         {
737                 return;
738         }
739
740         if (currentPosition.x > touchInfo.GetStartPosition().x + 100)
741         {
742                 if (__pPlayerPresentationModel->GetContentListCount() > 1)
743                 {
744                         while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetPreviousContentIndex()) == false
745                                 && __pPlayerPresentationModel->GetContentListCount() > 0)
746                         {
747                                 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetPreviousContentIndex()));
748                         }
749                 }
750                 flickDirection = FLICK_DIRECTION_RIGHT;
751                 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
752                 {
753                         MessageBox messageBox;
754                         messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
755
756                         int modalResult = 0;
757                         messageBox.ShowAndWait(modalResult);
758                 }
759                 else
760                 {
761                         PlayAnimation();
762                         __isAnimationPerformed = true;
763                 }
764         }
765         else if (currentPosition.x < touchInfo.GetStartPosition().x - 100)
766         {
767                 if (__pPlayerPresentationModel->GetContentListCount() > 1)
768                 {
769                         while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetNextContentIndex()) == false
770                                 && __pPlayerPresentationModel->GetContentListCount() > 0)
771                         {
772                                 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetNextContentIndex()));
773                         }
774                 }
775                 flickDirection = FLICK_DIRECTION_LEFT;
776                 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
777                 {
778                         MessageBox messageBox;
779                         messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
780
781                         int modalResult = 0;
782                         messageBox.ShowAndWait(modalResult);
783                 }
784                 else
785                 {
786                         PlayAnimation();
787                         __isAnimationPerformed = true;
788                 }
789         }
790         AppLogDebug("EXIT");
791 }
792
793 void
794 PlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
795 {
796         AppLogDebug("ENTER");
797         if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
798         {
799                 __isLongPressed = false;
800         }
801         else
802         {
803                 if (!(currentPosition.y < 0 || currentPosition.y > GetBounds().height - __pControllerPanel->GetBounds().height))
804                 {
805                         __isAnimationPerformed = false;
806                 }
807
808                 if (__pVolumePanel != null && __pVolumePanel->GetShowState())
809                 {
810                         __pVolumePanel->SetShowState(false);
811                 }
812         }
813         AppLogDebug("EXIT");
814 }
815
816 void
817 PlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
818 {
819         AppLogDebug("ENTER");
820         if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
821         {
822                 if (__isLongPressed == true)
823                 {
824                         __pPlayerPresentationModel->StopForwardRewind();
825                 }
826                 else
827                 {
828                         if (source.Equals(*__pRewindButton))
829                         {
830                                 if (__pPlayerPresentationModel->GetContentListCount() > 1)
831                                 {
832                                         while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetPreviousContentIndex()) == false
833                                                 && __pPlayerPresentationModel->GetContentListCount() > 0)
834                                         {
835                                                 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetPreviousContentIndex()));
836                                         }
837                                 }
838                                 flickDirection = FLICK_DIRECTION_RIGHT;
839
840                                 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
841                                 {
842                                         MessageBox messageBox;
843                                         messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
844
845                                         int modalResult = 0;
846                                         messageBox.ShowAndWait(modalResult);
847                                 }
848                                 else
849                                 {
850                                         PlayAnimation();
851                                 }
852                         }
853                         else
854                         {
855                                 if (__pPlayerPresentationModel->GetContentListCount() > 1)
856                                 {
857                                         while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetNextContentIndex()) == false
858                                                 && __pPlayerPresentationModel->GetContentListCount() > 0)
859                                         {
860                                                 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetNextContentIndex()));
861                                         }
862                                 }
863                                 flickDirection = FLICK_DIRECTION_LEFT;
864
865                                 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
866                                 {
867                                         MessageBox messageBox;
868                                         messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
869
870                                         int modalResult = 0;
871                                         messageBox.ShowAndWait(modalResult);
872                                 }
873                                 else
874                                 {
875                                         PlayAnimation();
876                                 }
877                         }
878                 }
879         }
880         else
881         {
882                 // Empty statement
883         }
884         AppLogDebug("EXIT");
885 }
886
887 void
888 PlayerForm::PlayAnimation(void)
889 {
890         AppLogDebug("ENTER");
891         if (AnimationTransaction::GetStatus(__transactionID) == ANIMATION_TRANSACTION_STATUS_STOPPED)
892         {
893                 if (flickDirection == FLICK_DIRECTION_RIGHT)
894                 {
895                         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(true);
896
897                         AnimationTransaction::Begin(__transactionID);
898                         AnimationTransaction::SetVisualElementAnimationDuration(200);
899                         AnimationTransaction::SetCurrentTransactionEventListener(this);
900
901                         VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
902                         pAnimation->SetPropertyName(L"bounds");
903                         pAnimation->SetStartValue(Variant(rectanglePreviousElement));
904                         pAnimation->SetEndValue(Variant(rectangleCurrentElement));
905
906                         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->AddAnimation(*pAnimation);
907                         delete pAnimation;
908
909                         pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
910                         pAnimation->SetPropertyName(L"bounds");
911                         pAnimation->SetStartValue(Variant(rectangleCurrentElement));
912                         pAnimation->SetEndValue(Variant(rectangleNextElement));
913
914                         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->AddAnimation(*pAnimation);
915
916                         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(false);
917                         delete pAnimation;
918
919                         AnimationTransaction::Commit();
920                 }
921                 else if (flickDirection == FLICK_DIRECTION_LEFT)
922                 {
923                         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(true);
924
925                         AnimationTransaction::Begin(__transactionID);
926                         AnimationTransaction::SetVisualElementAnimationDuration(200);
927                         AnimationTransaction::SetCurrentTransactionEventListener(this);
928
929                         VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
930                         pAnimation->SetPropertyName(L"bounds");
931                         pAnimation->SetStartValue(Variant(rectangleCurrentElement));
932                         pAnimation->SetEndValue(Variant(rectanglePreviousElement));
933
934                         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->AddAnimation(*pAnimation);
935                         delete pAnimation;
936
937                         pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
938                         pAnimation->SetPropertyName(L"bounds");
939                         pAnimation->SetStartValue(Variant(rectangleNextElement));
940                         pAnimation->SetEndValue(Variant(rectangleCurrentElement));
941
942                         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->AddAnimation(*pAnimation);
943                         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(false);
944                         delete pAnimation;
945
946                         AnimationTransaction::Commit();
947                 }
948                 else
949                 {
950                         // Empty statement
951                 }
952         }
953         AppLogDebug("EXIT");
954 }
955
956 void
957 PlayerForm::StopAnimation(void)
958 {
959         AppLogDebug("ENTER");
960         AppLogDebug("EXIT");
961 }
962
963 void
964 PlayerForm::OnAnimationTransactionStarted(int transactionId)
965 {
966         AppLogDebug("ENTER");
967         __pContentPlayTimer->Cancel();
968         AppLogDebug("EXIT");
969 }
970
971 void
972 PlayerForm::OnAnimationTransactionStopped(int transactionId)
973 {
974         AppLogDebug("ENTER");
975         AppLogDebug("EXIT");
976 }
977
978 void
979 PlayerForm::OnAnimationTransactionFinished(int transactionId)
980 {
981         AppLogDebug("ENTER");
982         __pAnimationFinishedTimer->Start(1);
983         __pContentPlayTimer->Start(700);
984         AppLogDebug("EXIT");
985 }
986
987 void
988 PlayerForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
989 {
990         AppLogDebug("ENTER");
991         if (source.Equals(*__pPlayStateSlider))
992         {
993                 __pPlayerPresentationModel->SetPlayPosition(value);
994         }
995         else
996         {
997                 __pPlayerPresentationModel->SetVolume(value);
998         }
999         AppLogDebug("EXIT");
1000 }
1001
1002 void
1003 PlayerForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1004 {
1005         AppLogDebug("ENTER");
1006         if (&timer == __pAnimationFinishedTimer)
1007         {
1008                 if (flickDirection == FLICK_DIRECTION_RIGHT)
1009                 {
1010                         Tizen::Ui::Animations::VisualElement* pTempVisualElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT];
1011                         pTempVisualElement->SetBounds(rectanglePreviousElement);
1012
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);
1017
1018                         __pPlayerPresentationModel->MovePreviousContent(true);
1019                 }
1020                 else if (flickDirection == FLICK_DIRECTION_LEFT)
1021                 {
1022                         Tizen::Ui::Animations::VisualElement* pTempVisualElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS];
1023                         pTempVisualElement->SetBounds(rectangleNextElement);
1024
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);
1029
1030                         __pPlayerPresentationModel->MoveNextContent();
1031                 }
1032                 flickDirection = FLICK_DIRECTION_NONE;
1033                 __transactionID = ANIMATION_TRANSACTION_STATUS_STOPPED;
1034         }
1035         else
1036         {
1037                 if ((__pPlayerPresentationModel->GetPlayerState() != PLAYER_STATE_PAUSED) && (__pPlayerPresentationModel->IsDuringCall() == false))
1038                 {
1039                         __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), MIN_PLAY_STATE_SLIDER_COUNT);
1040                 }
1041                 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1042                 {
1043                         SetFileNotExistState(false);
1044                 }
1045         }
1046         AppLogDebug("EXIT");
1047 }
1048
1049 int
1050 PlayerForm::GetItemCount(void)
1051 {
1052         AppLogDebug("ENTER");
1053         if (__pPlayerPresentationModel == null)
1054         {
1055                 return INIT_VALUE;
1056         }
1057         AppLogDebug("EXIT");
1058         return __pPlayerPresentationModel->GetContentListCount();
1059 }
1060
1061 Tizen::Ui::Controls::TableViewItem*
1062 PlayerForm::CreateItem(int index, int itemWidth)
1063 {
1064         AppLogDebug("ENTER");
1065         RelativeLayout layout;
1066         layout.Construct();
1067
1068         TableViewItem* pItem = new (std::nothrow) TableViewItem();
1069         ContentInformation* pContentInfo = __pPlayerPresentationModel->GetContentInfoN(index);
1070
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()));
1074
1075         r = CreateTableViewItem(*pItem, *pContentInfo);
1076         TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
1077
1078         RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(index)));
1079         delete pContentInfo;
1080
1081         AppLogDebug("EXIT");
1082         return pItem;
1083
1084 CATCH:
1085         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1086         delete pContentInfo;
1087         return null;
1088 }
1089
1090 bool
1091 PlayerForm::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1092 {
1093         AppLogDebug("ENTER");
1094         delete pItem;
1095         pItem = null;
1096         AppLogDebug("EXIT");
1097         return true;
1098 }
1099
1100 int
1101 PlayerForm::GetDefaultItemHeight(void)
1102 {
1103         AppLogDebug("ENTER");
1104         AppLogDebug("EXIT");
1105         return ITEM_HEIGHT;
1106 }
1107
1108 void
1109 PlayerForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1110 {
1111         AppLogDebug("ENTER");
1112         SceneManager* pSceneManager = SceneManager::GetInstance();
1113         AppAssert(pSceneManager);
1114
1115         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1116         {
1117                 __pPlayerPresentationModel->Play(itemIndex, MIN_PLAY_STATE_SLIDER_COUNT);
1118
1119                 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1120                 {
1121                         SetFileNotExistState(false);
1122                 }
1123         }
1124         AppLogDebug("EXIT");
1125 }
1126
1127 void
1128 PlayerForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1129 {
1130         AppLogDebug("ENTER");
1131         AppLogDebug("EXIT");
1132 }
1133
1134 void
1135 PlayerForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo)
1136 {
1137         AppLogDebug("ENTER");
1138         AppLogDebug("EXIT");
1139 }
1140
1141 void
1142 PlayerForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1143 {
1144         AppLogDebug("ENTER");
1145         AppLogDebug("EXIT");
1146 }
1147
1148 void
1149 PlayerForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1150                                         const Tizen::Ui::Scenes::SceneId& currentSceneId,
1151                                         Tizen::Base::Collection::IList* pArgs)
1152 {
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);
1159         */
1160
1161         __pPlayerPresentationModel->AddMusicPlayerEventListener(*this);
1162         if (pArgs != null)
1163         {
1164                 if (IsFailed(__pPlayerPresentationModel->SetContentList(pArgs)))
1165                 {
1166                         AppLogDebug("__pPlayerPresentationModel->SetContentList failed(%s)", GetErrorMessage(GetLastResult()));
1167                         SetPlayerScreenState(PLAYER_SCREEN_STATE_NO_CONTENT_LIST);
1168                         return;
1169                 }
1170
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());
1175
1176                 if (!static_cast<String*>(pArgs->GetAt(0))->Equals(MUSIC, false))
1177                 {
1178                         SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1179                 }
1180
1181                 pArgs->RemoveAll(true);
1182                 delete pArgs;
1183         }
1184         else
1185         {
1186                 if (__pPlayerPresentationModel->GetContentListCount() == INIT_VALUE)
1187                 {
1188                         AppLogDebug("__pPlayerPresentationModel->GetContentListCount() is 0");
1189                         SetPlayerScreenState(PLAYER_SCREEN_STATE_NO_CONTENT_LIST);
1190                         return;
1191                 }
1192
1193                 SetContentInfo( __pPlayerPresentationModel->GetCurrentContentIndex());
1194                 OnPlayStateChanged(__pPlayerPresentationModel->GetPlayerState());
1195                 OnPlayTimeChanged(__pPlayerPresentationModel->GetCurrentDuration(), __pPlayerPresentationModel->GetPlayPosition());
1196
1197                 if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_DURING_CALL)
1198                 {
1199                         SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1200                 }
1201         }
1202
1203         if (__pContentsListViewPanel->IsEnabled() == true && __isRunByAppControl == false)
1204         {
1205                 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1206                 pContentsTableView->UpdateTableView();
1207         }
1208
1209         if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1210         {
1211                 SetFileNotExistState(false);
1212         }
1213
1214         Invalidate(true);
1215         AppLogDebug("EXIT");
1216 }
1217
1218 void
1219 PlayerForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
1220                                                                                         const Tizen::Ui::Scenes::SceneId& nextSceneId)
1221 {
1222         AppLogDebug("ENTER");
1223         CancelAllThumbnailRequest();
1224         __pPlayerPresentationModel->RemoveMusicPlayerEventListener(*this);
1225
1226         if (__pVolumePanel != null && __pVolumePanel->GetShowState())
1227         {
1228                 __pVolumePanel->SetShowState(false);
1229         }
1230         AppLogDebug("EXIT");
1231 }
1232
1233 void
1234 PlayerForm::OnChangedContentList(Tizen::Base::Collection::IList* pArgs)
1235 {
1236         AppLogDebug("ENTER");
1237         MusicPlayerApp* pMusicPlayerApp = static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance());
1238         TryReturnVoid(pMusicPlayerApp != null, "Unable to cast UiApp to MusicPlayerApp");
1239
1240         if (pArgs != null)
1241         {
1242                 AppLogDebug("%d", pArgs->GetCount());
1243                 __pPlayerPresentationModel->SetContentList(pArgs);
1244
1245                 int playIndex = (static_cast<Integer*>(pArgs->GetAt(1)))->ToInt();
1246                 __pPlayerPresentationModel->Play(playIndex, MIN_PLAY_STATE_SLIDER_COUNT);
1247         }
1248
1249         if (__pContentsListViewPanel->GetShowState() == true)
1250         {
1251                 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1252                 pContentsTableView->UpdateTableView();
1253         }
1254
1255         if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1256         {
1257                 SetFileNotExistState(false);
1258         }
1259         Invalidate(true);
1260         AppLogDebug("EXIT");
1261 }
1262
1263 void
1264 PlayerForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1265 {
1266         AppLogDebug("ENTER");
1267         AppLogDebug("OnUserEventReceivedN %d", requestId);
1268         if (requestId == ID_DESTORY_PLAY_LIST_PICKER_POPUP || requestId == ID_DESTORY_SHARE_POPUP)
1269         {
1270                 RemovePlayListPicker();
1271                 RemoveSharePicker();
1272         }
1273
1274         if (pArgs != null)
1275         {
1276                 pArgs->RemoveAll(true);
1277                 delete pArgs;
1278         }
1279         AppLogDebug("EXIT");
1280 }
1281
1282 void
1283 PlayerForm::OnPlayStateChanged(PlayerState playerState)
1284 {
1285         AppLogDebug("ENTER");
1286         AppLogDebug("%d", playerState);
1287         if (playerState == PLAYER_STATE_ERROR)
1288         {
1289                 RemoveContextMenu();
1290                 SetContentInfo( __pPlayerPresentationModel->GetCurrentContentIndex());
1291                 SetPlayerScreenState(PLAYER_SCREEN_STATE_ERROR_CONTENT);
1292                 ShowMessageBox(L"file play failed");
1293         }
1294
1295         if (playerState == PLAYER_STATE_PAUSED)
1296         {
1297                 if (__pPlayerPresentationModel->IsDuringCall() == true)
1298                 {
1299                         SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1300                 }
1301         }
1302         TogglePlayPauseImage(playerState);
1303         AppLogDebug("EXIT");
1304 }
1305
1306 void
1307 PlayerForm::OnPlayContentChanged(int currentContentIndex)
1308 {
1309         AppLogDebug("ENTER");
1310         SetContentInfo(currentContentIndex);
1311         if ( __pPlayerPresentationModel->IsDuringCall() == false)
1312         {
1313                 SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1314         }
1315         else
1316         {
1317                 SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1318         }
1319         AppLogDebug("EXIT");
1320 }
1321
1322 void
1323 PlayerForm::OnPlayContentRemoved(int removedContentIndex)
1324 {
1325         AppLogDebug("ENTER");
1326         int currentIndex = __pPlayerPresentationModel->GetCurrentContentIndex();
1327         int currentContentCount = __pPlayerPresentationModel->GetContentListCount();
1328
1329         if ((removedContentIndex == currentIndex - 1)
1330                 || (currentIndex == 0 && removedContentIndex == 0)
1331                 || (currentIndex == removedContentIndex)
1332                 || (currentIndex == __pPlayerPresentationModel->GetPreviousContentIndex()))
1333         {
1334                 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_PREVIOUS);
1335         }
1336         else if ((removedContentIndex == currentIndex + 1)
1337                         || (currentIndex == currentContentCount - 1 && removedContentIndex == 0))
1338         {
1339                 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_NEXT);
1340         }
1341         AppLogDebug("EXIT");
1342 }
1343
1344 void
1345 PlayerForm::OnPlayVolumeBarStateChanged(void)
1346 {
1347         AppLogDebug("ENTER");
1348         if (__pVolumePanel->GetShowState() == true)
1349         {
1350                 __pVolumePanel->SetShowState(false);
1351         }
1352         AppLogDebug("EXIT");
1353 }
1354
1355 void
1356 PlayerForm::OnPlayTimeChanged(const Tizen::Base::String& currentDuration, int currentPosition)
1357 {
1358         AppLogDebug("ENTER");
1359         __pCurrentTimeLabel->SetText(currentDuration);
1360         __pPlayStateSlider->SetValue(currentPosition);
1361         __pCurrentTimeLabel->Invalidate(true);
1362         __pPlayStateSlider->Invalidate(true);
1363         AppLogDebug("EXIT");
1364 }
1365
1366 void
1367 PlayerForm::OnAutoOffTimeChanged(int autoOffTime)
1368 {
1369         AppLogDebug("ENTER");
1370         __pPlayerPresentationModel->StartAutoOffTimer(autoOffTime);
1371         AppLogDebug("EXIT");
1372 }
1373
1374 void
1375 PlayerForm::OnPlayPresentationModelDestroying(void)
1376 {
1377         AppLogDebug("ENTER");
1378         if (__pPlayerPresentationModel != null)
1379         {
1380                 __pPlayerPresentationModel = null;
1381         }
1382         AppLogDebug("EXIT");
1383 }
1384
1385 result
1386 PlayerForm::ShowMessageBox(const Tizen::Base::String& showText)
1387 {
1388         AppLogDebug("ENTER");
1389         MessageBox messageBox;
1390         messageBox.Construct(L"Error", showText, MSGBOX_STYLE_NONE, 3000);
1391         int modalResult = 0;
1392         messageBox.ShowAndWait(modalResult);
1393
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))
1398 //      {
1399 //              UiApp* pApp = UiApp::GetInstance();
1400 //              pApp->Terminate();
1401 //      }
1402 //      else
1403         {
1404 //              if (pSceneManager->IsSceneAlive(IDSCN_ALL_LIST))
1405 //              {
1406 //                      pSceneManager->GoBackward(BackwardSceneTransition());
1407 //              }
1408 //              else
1409 //              {
1410 //                      UiApp* pApp = UiApp::GetInstance();
1411 //                      pApp->Terminate();
1412 //              }
1413         }
1414         AppLogDebug("EXIT");
1415         return E_SUCCESS;
1416 }
1417
1418 void
1419 PlayerForm::SetContentInfo(int currentContentIndex)
1420 {
1421         AppLogDebug("ENTER");
1422         ContentInformation* pContentInfoStruct = __pPlayerPresentationModel->GetContentInfoN(currentContentIndex);
1423         TryReturnVoid(pContentInfoStruct != null, "The currentContentIndex is invalid");
1424
1425         __pTitleName->SetText(pContentInfoStruct->TitleName);
1426         __pArtistName->SetText(pContentInfoStruct->ArtistName);
1427
1428         __pPlayStateSlider->SetRange(MIN_PLAY_STATE_SLIDER_COUNT, MAX_PLAY_STATE_SLIDER_COUNT);
1429
1430         String totalTime = CommonUtil::GetFormatDate(pContentInfoStruct->Duration);
1431         if (totalTime.Equals(INITIAL_TIME, true) != true)
1432         {
1433                 __pTotalTimeLabel->SetText(totalTime);
1434         }
1435         else
1436         {
1437                 __pTotalTimeLabel->SetText(INITIAL_TIME);
1438         }
1439
1440         if (pContentInfoStruct->contentId.ToString().Equals(INVALID_VALUE_OF_CONTENT_ID, true))
1441         {
1442                 SetFileNotExistState(false);
1443         }
1444         else
1445         {
1446                 if (__pPlayerPresentationModel->GetPlayerState() != PLAYER_STATE_ERROR)
1447                 {
1448                         if (__pPlayStateSlider->IsEnabled() != true)
1449                         {
1450                                 __pPlayStateSlider->SetEnabled(true);
1451                         }
1452                         SetFileNotExistState(true);
1453                 }
1454         }
1455         delete pContentInfoStruct;
1456
1457         UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_CURRENT);
1458         Invalidate(true);
1459         AppLogDebug("EXIT");
1460 }
1461
1462 void
1463 PlayerForm::UpdateAnimationAlbumArt(AlbumArtImage position)
1464 {
1465         AppLogDebug("ENTER");
1466         Bitmap* pAlbumArtBitmap[ALBUM_ART_IMAGE_COUNT] = {null, };
1467         FloatDimension floatDimension = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->GetSizeF();
1468
1469         switch (position)
1470         {
1471         case ALBUM_ART_IMAGE_CURRENT:
1472                 {
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());
1476
1477                         pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT]->Scale(floatDimension);
1478                         pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]->Scale(floatDimension);
1479                         pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]->Scale(floatDimension);
1480                 }
1481                 break;
1482
1483         case ALBUM_ART_IMAGE_PREVIOUS:
1484                 {
1485                         pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = null;
1486                         pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetPreviousContentIndex());
1487                         pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = null;
1488
1489                         pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]->Scale(floatDimension);
1490                 }
1491                 break;
1492
1493         case ALBUM_ART_IMAGE_NEXT:
1494                 {
1495                         pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = null;
1496                         pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = null;
1497                         pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetNextContentIndex());
1498
1499                         pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]->Scale(floatDimension);
1500                 }
1501                 break;
1502
1503         default:
1504                 break;
1505         }
1506
1507         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] != null)
1508         {
1509                 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetCanvasN();
1510                 if (pCanvas)
1511                 {
1512                         Point point(INIT_VALUE, INIT_VALUE);
1513                         pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT]);
1514                         delete pCanvas;
1515                 }
1516                 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT];
1517         }
1518
1519         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] != null)
1520         {
1521                 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetCanvasN();
1522                 if (pCanvas)
1523                 {
1524                         Point point(INIT_VALUE, INIT_VALUE);
1525                         pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]);
1526                         delete pCanvas;
1527                 }
1528                 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS];
1529         }
1530
1531         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] != null)
1532         {
1533                 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetCanvasN();
1534                 if (pCanvas)
1535                 {
1536                         Point point(INIT_VALUE, INIT_VALUE);
1537                         pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]);
1538                         delete pCanvas;
1539                 }
1540                 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT];
1541         }
1542         AppLogDebug("EXIT");
1543         return;
1544 }
1545
1546 void
1547 PlayerForm::SetRepeatButtonImage(int repeatValue)// 0 - 2 (OFF, ONE, ALL)
1548 {
1549         AppLogDebug("ENTER");
1550         Bitmap* pOptionRepeatBitmap;
1551         Bitmap* pOptionRepeatPressBitmap;
1552
1553         switch (repeatValue)
1554         {
1555         case 0:
1556                 {
1557                         pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_A.png");
1558                         pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_A_press.png");
1559                 }
1560                 break;
1561
1562         case 1:
1563                 {
1564                         pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_1.png");
1565                         pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_1_press.png");
1566                 }
1567                 break;
1568
1569         case 2:
1570                 {
1571                         pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_all.png");
1572                         pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_all_press.png");
1573                 }
1574                 break;
1575
1576         default:
1577                 break;
1578         }
1579         __pRepeatButton->SetNormalBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionRepeatBitmap);
1580         __pRepeatButton->SetPressedBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionRepeatPressBitmap);
1581         __pPlayerPresentationModel->SetRepeatMode(repeatValue);
1582
1583         delete pOptionRepeatBitmap;
1584         pOptionRepeatBitmap = null;
1585         delete pOptionRepeatPressBitmap;
1586         pOptionRepeatPressBitmap = null;
1587         AppLogDebug("EXIT");
1588 }
1589
1590 void
1591 PlayerForm::SetShuffleButtonImage(bool shuffleEnable)
1592 {
1593         AppLogDebug("ENTER");
1594         Bitmap* pOptionShuffleBitmap;
1595
1596         if (shuffleEnable == false)
1597         {
1598                 pOptionShuffleBitmap = ResourceManager::GetBitmapN(L"T02_option_shuffle_on_dim.png");
1599         }
1600         else
1601         {
1602                 pOptionShuffleBitmap = ResourceManager::GetBitmapN(L"T02_option_shuffle_on.png");
1603         }
1604
1605         __pShuffleButton->SetNormalBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionShuffleBitmap);
1606         __pPlayerPresentationModel->SetShuffleEnable(shuffleEnable);
1607         UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_CURRENT);
1608
1609         delete pOptionShuffleBitmap;
1610         pOptionShuffleBitmap = null;
1611         AppLogDebug("EXIT");
1612 }
1613
1614 void
1615 PlayerForm::SetFileNotExistState(bool isFileExist)
1616 {
1617         AppLogDebug("ENTER");
1618         RemoveContextMenu();
1619         __pMoreContextButton->SetEnabled(isFileExist);
1620         __pMoreContextButton->Invalidate(true);
1621
1622         if (__isRunByAppControl == false)
1623         {
1624                 __pContentsViewToggleButton->SetEnabled(isFileExist);
1625                 __pContentsViewToggleButton->Invalidate(true);
1626         }
1627         AppLogDebug("EXIT");
1628 }
1629
1630 void
1631 PlayerForm::TogglePlayPauseImage(PlayerState playerState)
1632 {
1633         AppLogDebug("ENTER");
1634         if (playerState == PLAYER_STATE_PLAYING)
1635         {
1636                 RelativeLayout* layout = dynamic_cast<RelativeLayout*>(__pContentsAlbumViewPanel->GetLayoutN());
1637                 layout->ResetCenterAligned(*static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_THUMBANIL_BACKGROUND)), CENTER_ALIGN_HORIZONTAL);
1638                 delete layout;
1639
1640                 Label* pAlbumTurnTable = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_TURN_TABLE));
1641                 pAlbumTurnTable->SetShowState(true);
1642                 SetPauseButtonImage();
1643         }
1644         else
1645         {
1646                 RelativeLayout* layout = dynamic_cast<RelativeLayout*>(__pContentsAlbumViewPanel->GetLayoutN());
1647                 layout->SetCenterAligned(*static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_THUMBANIL_BACKGROUND)), CENTER_ALIGN_HORIZONTAL);
1648                 delete layout;
1649                 Label* pAlbumTurnTable = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_TURN_TABLE));
1650                 pAlbumTurnTable->SetShowState(false);
1651                 SetPlayButtonImage();
1652         }
1653
1654         if (__pContentsAlbumViewPanel->GetShowState() == true)
1655         {
1656                 __pContentsAlbumViewPanel->Invalidate(true);
1657         }
1658         AppLogDebug("EXIT");
1659 }
1660 void
1661 PlayerForm::SetPlayButtonImage(void)
1662 {
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);
1667         delete pBitmap;
1668
1669         pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_PRESSED);
1670         __pPlayPauseButton->SetPressedBitmap(point, *pBitmap);
1671         delete pBitmap;
1672
1673         pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_DISABLED);
1674         __pPlayPauseButton->SetDisabledBitmap(point, *pBitmap);
1675         delete pBitmap;
1676
1677         __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PLAY);
1678         __pPlayPauseButton->Invalidate(true);
1679         AppLogDebug("EXIT");
1680 }
1681
1682 void
1683 PlayerForm::SetPauseButtonImage(void)
1684 {
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);
1689         delete pBitmap;
1690
1691         pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_PRESSED);
1692         __pPlayPauseButton->SetPressedBitmap(point, *pBitmap);
1693         delete pBitmap;
1694
1695         pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_DISABLED);
1696         __pPlayPauseButton->SetDisabledBitmap(point, *pBitmap);
1697         delete pBitmap;
1698
1699         __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PAUSE);
1700         __pPlayPauseButton->Invalidate(true);
1701         AppLogDebug("EXIT");
1702 }
1703
1704 result
1705 PlayerForm::InitializeVolumeBar(void)
1706 {
1707         AppLogDebug("ENTER");
1708         int MediaSoundVolume = 0;
1709         SettingInfo::GetValue(MEDIA_VOLUME, MediaSoundVolume);
1710         __pPlayerPresentationModel->SetVolume(MediaSoundVolume);
1711
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;
1718         layout.Construct();
1719
1720         if (orientationStatue == ORIENTATION_STATUS_LANDSCAPE
1721                 || orientationStatue == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1722         {
1723                 AppLogDebug("CHECK %d", clientBounds.width);
1724                 if (clientBounds.width > 1200)
1725                 {
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
1729                                                                         , H_VOLUME_PANEL));
1730                 }
1731                 else
1732                 {
1733                         __pVolumePanel->Construct(layout, Rectangle(clientBounds.width - 670
1734                                                                         , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1735                                                                         , 680
1736                                                                         , H_VOLUME_PANEL));
1737                 }
1738         }
1739         else if (orientationStatue == ORIENTATION_STATUS_PORTRAIT
1740                         || orientationStatue == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1741         {
1742                 __pVolumePanel->Construct(layout, Rectangle(0
1743                                                                 , clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1744                                                                 , clientBounds.width
1745                                                                 , H_VOLUME_PANEL));
1746         }
1747
1748         if (clientBounds.width > 1200)
1749         {
1750                 __pVolumeSlider->Construct(Rectangle(0
1751                                                                 , 0, W_HORIZONTAL_PLAYER, H_VOLUME_PANEL)
1752                                                                 , BACKGROUND_STYLE_NONE
1753                                                                 , false
1754                                                                 , MIN_VOLUME_SLIDER_COUNT
1755                                                                 , MAX_VOLUME_SLIDER_COUNT
1756                                                                 , GROUP_STYLE_NONE);
1757         }
1758         else
1759         {
1760                 __pVolumeSlider->Construct(Rectangle(0
1761                                                                 , 0, 680, H_VOLUME_PANEL)
1762                                                                 , BACKGROUND_STYLE_NONE
1763                                                                 , false
1764                                                                 , MIN_VOLUME_SLIDER_COUNT
1765                                                                 , MAX_VOLUME_SLIDER_COUNT
1766                                                                 , GROUP_STYLE_NONE);
1767         }
1768
1769         __pVolumeSlider->SetColor(TRANSPARENT_COLOR);
1770         AddControl(*__pVolumePanel);
1771         __pVolumePanel->AddControl(*__pVolumeSlider);
1772         CommonUtil::SetLayoutFitToContainer(*__pVolumePanel, *__pVolumeSlider);
1773
1774         Bitmap* pVolumeLeftIconBitmap = ResourceManager::GetBitmapN(L"T02_volume_icon_01.png");
1775         Bitmap* pVolumeRightIconBitmap = ResourceManager::GetBitmapN(L"T02_volume_icon_02.png");
1776
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));
1781
1782         __pVolumeSlider->SetIcon(ICON_POSITION_LEFT, *pVolumeLeftIconBitmap);
1783         __pVolumeSlider->SetIcon(ICON_POSITION_RIGHT, *pVolumeRightIconBitmap);
1784         __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
1785         __pVolumeSlider->AddSliderEventListener(*this);
1786
1787         delete pVolumeLeftIconBitmap;
1788         pVolumeLeftIconBitmap = null;
1789         delete pVolumeRightIconBitmap;
1790         pVolumeRightIconBitmap = null;
1791
1792         return E_SUCCESS;
1793 }
1794
1795 result
1796 PlayerForm::CreateTableViewItem(Tizen::Ui::Container& parent,
1797                                                 const ContentInformation& contentInfoStruct)
1798 {
1799         AppLogDebug("ENTER");
1800         Panel* pTableViewItem = new (std::nothrow) Panel();
1801         if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL)))
1802         {
1803                 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
1804                 return E_FAILURE;
1805         }
1806
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());
1810
1811         parent.AddControl(*pTableViewItem);
1812         CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
1813
1814         AppLogDebug("EXIT");
1815         return E_SUCCESS;
1816 }
1817
1818 void
1819 PlayerForm::UpdateSplitBarState(void)
1820 {
1821         AppLogDebug("ENTER");
1822         Label* pSplitBar = static_cast<Label*>(GetControl(IDC_SPLIT_BAR));
1823         if ((GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT) || (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE))
1824         {
1825                 pSplitBar->SetSize(GetClientAreaBounds().width, 0);
1826         }
1827         else
1828         {
1829                 pSplitBar->SetSize(13,  GetClientAreaBounds().height);
1830         }
1831         AppLogDebug("EXIT");
1832 }
1833
1834 void
1835 PlayerForm::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
1836 {
1837         AppLogDebug("ENTER");
1838         __pThumbnail = pThumbnailInfo->GetBitmapN();
1839         Object* pParam = pThumbnailInfo->GetUserParamN();
1840         if (pParam != null)
1841         {
1842                 static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW))->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1843                 delete pParam;
1844         }
1845
1846         delete pThumbnailInfo;
1847         AppLogDebug("EXIT");
1848 }
1849
1850 void
1851 PlayerForm::OnMusicContentUpdateCompleted(void)
1852 {
1853         AppLogDebug("ENTER");
1854         RemoveContextMenu();
1855         RemoveSharePicker();
1856         RemovePlayListPicker();
1857         RemoveSetAsPicker();
1858
1859         AllListPresentationModel* pPresentationModel = AllListPresentationModel::GetInstance();
1860         if (pPresentationModel == null)
1861         {
1862                 AppLogDebug("EXIT");
1863                 return;
1864         }
1865
1866         IList* pList = pPresentationModel->GetContentListN();
1867         if (pList == null || pList->GetCount() == INIT_VALUE)
1868         {
1869                 AppLogDebug("EXIT");
1870                 delete pList;
1871                 return;
1872         }
1873
1874         int iContentListCount = __pPlayerPresentationModel->GetContentListCount();
1875         for (int iCount =  iContentListCount - 1; iCount >= 0; iCount--)
1876         {
1877                 bool isFind = false;
1878                 String* pContentPath = __pPlayerPresentationModel->GetContentPath(iCount);
1879                 if (pContentPath == null)
1880                 {
1881                         continue;
1882                 }
1883                 IEnumerator* pIEnum = pList->GetEnumeratorN();
1884                 while (pIEnum->MoveNext() == E_SUCCESS)
1885                 {
1886                         String* pCurrentPath = static_cast<String*>(pIEnum->GetCurrent());
1887                         if (pCurrentPath == null)
1888                         {
1889                                 continue;
1890                         }
1891
1892                         if (pContentPath->Equals(*pCurrentPath, false))
1893                         {
1894                                 isFind = true;
1895                                 break;
1896                         }
1897                 }
1898                 delete pIEnum;
1899
1900                 if (isFind == false)
1901                 {
1902                         __pPlayerPresentationModel->RemoveContent(*pContentPath);
1903                 }
1904         }
1905
1906         if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1907         {
1908                 SetFileNotExistState(false);
1909         }
1910
1911         if (__pContentsListViewPanel->IsEnabled() == true)
1912         {
1913                 if (__pPlayerPresentationModel->GetContentListCount() != INIT_VALUE)
1914                 {
1915                         static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW))->UpdateTableView();
1916                 }
1917                 else if (__pContentsListViewPanel->GetShowState() == true)
1918                 {
1919                         __pContentsListViewPanel->SetShowState(false);
1920                         __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
1921                         __pContentsAlbumViewPanel->SetShowState(true);
1922                         __pPanelRegisterBar->Invalidate(true);
1923                 }
1924         }
1925         AppLogDebug("EXIT");
1926 }
1927
1928 void
1929 PlayerForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1930 {
1931         AppLogDebug("ENTER");
1932         Panel* pItemPanel = static_cast<Panel*>(pItem->GetControl(IDL_CONTENTS_LIBARY_ITEM_PANEL));
1933         if (pItemPanel == null)
1934         {
1935                 AppLogDebug("pItemPanel is null");
1936                 delete __pThumbnail;
1937                 __pThumbnail = null;
1938                 return;
1939         }
1940         Label* pThumbnailLabel = static_cast<Label*>(pItemPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
1941         if (__pThumbnail == null || pThumbnailLabel == null)
1942         {
1943                 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
1944                 delete __pThumbnail;
1945                 __pThumbnail = null;
1946                 return;
1947         }
1948         pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
1949         delete __pThumbnail;
1950         __pThumbnail = null;
1951         pThumbnailLabel->Invalidate(true);
1952         AppLogDebug("EXIT");
1953 }
1954
1955 void
1956 PlayerForm::SetPlayerScreenState(unsigned int playerScreenState)
1957 {
1958         AppLogDebug("ENTER");
1959         if (__playerScreenState == playerScreenState)
1960         {
1961                 AppLogDebug("EXIT");
1962                 return;
1963         }
1964
1965         switch (playerScreenState)
1966         {
1967         case PLAYER_SCREEN_STATE_NORMAL:
1968                 {
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);
1978
1979                         if (__isRunByAppControl == false)
1980                         {
1981                                 break;
1982                         }
1983                 }
1984                 // fall through
1985         case PLAYER_SCREEN_STATE_APP_CONTROL:
1986                 {
1987                         __pContentsViewToggleButton->SetEnabled(false);
1988                         __pContentsViewToggleButton->Invalidate(true);
1989                         __pShuffleButton->SetEnabled(false);
1990                         __pRepeatButton->SetEnabled(false);
1991
1992                         __isRunByAppControl = true;
1993                 }
1994                 break;
1995
1996         case PLAYER_SCREEN_STATE_NO_CONTENT_LIST:
1997                 {
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);
2007
2008                         Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2009                         static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2010                         delete pThumb;
2011                 }
2012                 break;
2013
2014         case PLAYER_SCREEN_STATE_ERROR_CONTENT:
2015                 {
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);
2021                         delete pThumb;
2022                 }
2023                 break;
2024
2025         case PLAYER_SCREEN_STATE_DURING_CALL:
2026                 {
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);
2031                         delete pThumb;
2032                 }
2033                 break;
2034
2035         default:
2036                 break;
2037         }
2038
2039         __playerScreenState = playerScreenState;
2040         Invalidate(true);
2041         AppLogDebug("EXIT");
2042 }
2043
2044 unsigned int
2045 PlayerForm::GetPlayerScreenState(void)
2046 {
2047         AppLogDebug("ENTER");
2048         AppLogDebug("EXIT");
2049         return __playerScreenState;
2050 }
2051
2052 result
2053 PlayerForm::SetContextMenuItem(unsigned int contextMenuItemStyle, Tizen::Graphics::Point anchorPosition)
2054 {
2055         AppLogDebug("ENTER");
2056         if (__pContextMenu == null)
2057         {
2058                 AppLogDebug("EXIT");
2059                 return E_FAILURE;
2060         }
2061
2062         CommonUtil::AddContextMenuItem(*__pContextMenu, contextMenuItemStyle);
2063         CommonUtil::ShowContextMenu(*__pContextMenu, true);
2064
2065         if (anchorPosition.x != -1 && anchorPosition.y != -1)
2066         {
2067                 __pContextMenu->SetAnchorPosition(anchorPosition);
2068         }
2069         AppLogDebug("EXIT");
2070         return E_SUCCESS;
2071 }
2072
2073 result
2074 PlayerForm::CreateContextMenuN(const Tizen::Ui::Control& source)
2075 {
2076         AppLogDebug("ENTER");
2077         RemoveContextMenu();
2078         __pContextMenu = CommonUtil::CreateContextMenuN(source, *this);
2079         if (__pContextMenu != null)
2080         {
2081                 return E_SUCCESS;
2082         }
2083         AppLogDebug("EXIT");
2084         return E_FAILURE;
2085 }
2086
2087 void
2088 PlayerForm::RemoveContextMenu(void)
2089 {
2090         AppLogDebug("ENTER");
2091         if (__pContextMenu != null)
2092         {
2093                 CommonUtil::SetShowStateControl(*__pContextMenu, false);
2094                 delete __pContextMenu;
2095                 __pContextMenu = null;
2096         }
2097         AppLogDebug("EXIT");
2098 }
2099
2100 result
2101 PlayerForm::TryRemoveContextMenu(int actionId)
2102 {
2103         AppLogDebug("ENTER");
2104         result r = E_FAILURE;
2105         if (CommonUtil::IsVaildContextMenuItemActionId(actionId) == true)
2106         {
2107                 RemoveContextMenu();
2108                 r = E_SUCCESS;
2109         }
2110         AppLogDebug("EXIT");
2111         return r;
2112 }
2113
2114 result
2115 PlayerForm::ShowSharePicker(Tizen::Base::Collection::IList* pIList)
2116 {
2117         AppLogDebug("ENTER");
2118         RemoveSharePicker();
2119
2120         __pSharePicker = new (std::nothrow) SharePopup();
2121         if (IsFailed(__pSharePicker->Initialize(this)))
2122         {
2123                 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2124                 RemoveSharePicker();
2125                 return E_FAILURE;
2126         }
2127
2128         __pSharePicker->SetArguments(pIList);
2129         __pSharePicker->SetShowState(true);
2130         __pSharePicker->Show();
2131
2132         AppLogDebug("EXIT");
2133         return E_SUCCESS;
2134 }
2135
2136 void
2137 PlayerForm::RemoveSharePicker(void)
2138 {
2139         AppLogDebug("ENTER");
2140         if (__pSharePicker != null)
2141         {
2142                 CommonUtil::SetShowStateControl(*__pSharePicker, false);
2143                 delete __pSharePicker;
2144                 __pSharePicker = null;
2145         }
2146         AppLogDebug("EXIT");
2147 }
2148
2149 result
2150 PlayerForm::ShowPlayListPicker(Tizen::Base::Collection::IList* pIList)
2151 {
2152         AppLogDebug("ENTER");
2153         RemovePlayListPicker();
2154
2155         __pPlayListPicker = new (std::nothrow) PlayListPickerPopup();
2156         if (IsFailed(__pPlayListPicker->Initialize(this, pIList)))
2157         {
2158                 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2159                 RemovePlayListPicker();
2160                 return E_FAILURE;
2161         }
2162
2163         __pPlayListPicker->SetShowState(true);
2164         __pPlayListPicker->Show();
2165
2166         AppLogDebug("EXIT");
2167         return E_SUCCESS;
2168 }
2169
2170 void
2171 PlayerForm::RemovePlayListPicker(void)
2172 {
2173         AppLogDebug("ENTER");
2174         if (__pPlayListPicker != null)
2175         {
2176                 CommonUtil::SetShowStateControl(*__pPlayListPicker, false);
2177                 delete __pPlayListPicker;
2178                 __pPlayListPicker = null;
2179         }
2180         AppLogDebug("EXIT");
2181 }
2182
2183 result
2184 PlayerForm::ShowSetAsPicker(Tizen::Base::Collection::IList* pIList)
2185 {
2186         AppLogDebug("ENTER");
2187         RemoveSetAsPicker();
2188
2189         __pSetAsPicker = new (std::nothrow) SetAsPopup();
2190         if (IsFailed(__pSetAsPicker->Initialize(this)))
2191         {
2192                 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2193                 RemoveSetAsPicker();
2194                 return E_FAILURE;
2195         }
2196
2197         __pSetAsPicker->SetCurrentContentPath(new (std::nothrow) String(*static_cast<String*>(pIList->GetAt(0))));
2198         __pSetAsPicker->SetShowState(true);
2199         __pSetAsPicker->Show();
2200
2201         pIList->RemoveAll(true);
2202         delete pIList;
2203
2204         AppLogDebug("EXIT");
2205         return E_SUCCESS;
2206 }
2207
2208 void
2209 PlayerForm::RemoveSetAsPicker(void)
2210 {
2211         AppLogDebug("ENTER");
2212         if (__pSetAsPicker != null)
2213         {
2214                 CommonUtil::SetShowStateControl(*__pSetAsPicker, false);
2215                 delete __pSetAsPicker;
2216                 __pSetAsPicker = null;
2217         }
2218         AppLogDebug("EXIT");
2219 }
2220
2221 result
2222 PlayerForm::LanucherPicker(PickerType pickerType)
2223 {
2224         AppLogDebug("ENTER");
2225         IList* pArgumentList = GetPickerArgumentListN(pickerType);
2226         if (pArgumentList == null)
2227         {
2228                 AppLogDebug("GetPickerArgumentListN is null");
2229                 return E_FAILURE;
2230         }
2231
2232         result r = E_FAILURE;
2233         if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER)
2234         {
2235                 r = ShowPlayListPicker(pArgumentList);
2236         }
2237         else if (pickerType == PICKER_TYPE_SHARE_PICKER)
2238         {
2239                 r = ShowSharePicker(pArgumentList);
2240         }
2241         else if (pickerType == PICKER_TYPE_SET_AS_PICKER)
2242         {
2243                 r = ShowSetAsPicker(pArgumentList);
2244         }
2245
2246         if (IsFailed(r))
2247         {
2248                 AppLogDebug("ShowPlayListPicker failed(%s)", GetErrorMessage(r));
2249                 delete pArgumentList;
2250         }
2251         AppLogDebug("EXIT");
2252         return r;
2253 }
2254
2255 Tizen::Base::Collection::IList*
2256 PlayerForm::GetPickerArgumentListN(PickerType pickerType)
2257 {
2258         AppLogDebug("ENTER");
2259         String contentPath;
2260         switch (pickerType)
2261         {
2262         case PICKER_TYPE_SET_AS_PICKER:
2263                 // fall through
2264         case PICKER_TYPE_PLAY_LIST_PICKER:
2265                 // fall through
2266         case PICKER_TYPE_SHARE_PICKER:
2267                 {
2268                         contentPath.Append(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetCurrentContentIndex()));
2269                 }
2270                 break;
2271
2272         default:
2273                 {
2274                         AppLogDebug("EXIT");
2275                         return null;
2276                 }
2277                 break;
2278         }
2279
2280         Tizen::Base::Collection::ArrayList* pDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2281         if (IsFailed(pDataList->Construct()))
2282         {
2283                 AppLogDebug("Construct failed(%s)", GetErrorMessage(GetLastResult()));
2284                 delete pDataList;
2285                 return null;
2286         }
2287
2288         pDataList->Add(*(new (std::nothrow) String(contentPath)));
2289         AppLogDebug("EXIT");
2290         return pDataList;
2291 }