Fixed jira issues
[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.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
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_INVALID_CONTENT_ID,
94         PLAYER_SCREEN_STATE_ERROR_CONTENT,
95         PLAYER_SCREEN_STATE_DURING_CALL,
96         PLAYER_SCREEN_STATE_MAX
97 };
98
99 enum IDAPlayerController
100 {
101         IDA_PLAYER_CONTROLLER_BASE = 100,
102         IDA_PLAYER_CONTROLLER_REWIND = IDA_PLAYER_CONTROLLER_BASE,
103         IDA_PLAYER_CONTROLLER_PLAY,
104         IDA_PLAYER_CONTROLLER_PAUSE,
105         IDA_PLAYER_CONTROLLER_FORWARD,
106         IDA_PLAYER_CONTROLLER_VOLUME,
107         IDA_PLAYER_CONTROLLER_REPEAT,
108         IDA_PLAYER_CONTROLLER_SHUFFLE,
109         IDA_PLAYER_CONTROLLER_BACK,
110         IDA_PLAYER_CONTROLLER_MORE,
111         IDA_PLAYER_CONTROLLER_MAX
112 };
113
114 PlayerForm::PlayerForm(void)
115         : __pPlayerPresentationModel(null)
116         , __pAlbumArtElements(null)
117         , __pVolumePanel(null)
118         , __pControllerPanel(null)
119         , __pPanelRegisterBar(null)
120         , __pContentsAlbumViewPanel(null)
121         , __pContentsListViewPanel(null)
122         , __pCurrentTimeLabel(null)
123         , __pTotalTimeLabel(null)
124         , __pTitleName(null)
125         , __pArtistName(null)
126         , __pRewindButton(null)
127         , __pForwardButton(null)
128         , __pVolumeButton(null)
129         , __pPlayPauseButton(null)
130         , __pBackButton(null)
131         , __pRepeatButton(null)
132         , __pShuffleButton(null)
133         , __pContentsViewToggleButton(null)
134         , __pMoreContextButton(null)
135         , __pPlayStateSlider(null)
136         , __pVolumeSlider(null)
137         , __pThumbnail(null)
138         , __pPlayListPicker(null)
139         , __pSharePicker(null)
140         , __pSetAsPicker(null)
141         , __pSoundPathPopup(null)
142         , __isLongPressed(false)
143         , __isAppControlDuringCall(false)
144         , __flickDirection(FLICK_DIRECTION_NONE)
145         , __transactionID(ANIMATION_TRANSACTION_STATUS_STOPPED)
146         , __playerScreenState(PLAYER_SCREEN_STATE_NORMAL)
147         , __isAnimationPerformed(false)
148         , __isRunByAppControl(false)
149         , __isContentMoveCompleted(false)
150         , __prevRepeatStateRunByAppControl(0)
151         , __pAnimationFinishedTimer(null)
152         , __pContentPlayTimer(null)
153         , __pPreviousSceneId(null)
154         , __pPath(null)
155         , __pContextMenu(null)
156 {
157         AppLogDebug("ENTER");
158         AppLogDebug("EXIT");
159 }
160
161 PlayerForm::~PlayerForm(void)
162 {
163         AppLogDebug("ENTER");
164         AppLogDebug("EXIT");
165 }
166
167 result
168 PlayerForm::Initialize(void)
169 {
170         AppLogDebug("ENTER");
171         if (IsFailed(Form::Construct(IDL_MUSIC_PLAYER_FORM)))
172         {
173                 AppLogDebug("Form::Construct(IDL_MUSIC_PLAYER_FORM) failed(%s)", GetErrorMessage(GetLastResult()));
174                 return E_FAILURE;
175         }
176         AppLogDebug("EXIT");
177         return E_SUCCESS;
178 }
179
180 result
181 PlayerForm::OnInitializing(void)
182 {
183         AppLogDebug("ENTER");
184
185         __pControllerPanel = static_cast<Panel*>(GetControl(IDC_PLAYER_CONTROL_BAR));
186         __pTitleName = static_cast<Label*>(GetControl(IDC_CONTENTS_TITLE_NAME));
187         __pArtistName = static_cast<Label*>(GetControl(IDC_CONTENTS_ARTIST_NAME));
188
189         __pContentsViewToggleButton = static_cast<Button*>(GetControl(IDC_CONTENTS_VIEW_TOGGLE_BUTTON));
190         __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
191         Bitmap* pContentsViewToggleNormalBitmap = ResourceManager::GetBitmapN(L"T02_icon_play_list_web.png");
192
193         if (pContentsViewToggleNormalBitmap != null)
194         {
195                 __pContentsViewToggleButton->SetNormalBackgroundBitmap(*pContentsViewToggleNormalBitmap);
196                 delete pContentsViewToggleNormalBitmap;
197         }
198
199         Bitmap* pContentsViewTogglePressedBitmap = ResourceManager::GetBitmapN(L"T02_icon_play_list_web_press.png");
200
201         if (pContentsViewTogglePressedBitmap != null)
202         {
203                 __pContentsViewToggleButton->SetPressedBackgroundBitmap(*pContentsViewTogglePressedBitmap);
204                 delete pContentsViewTogglePressedBitmap;
205         }
206         Bitmap* pContentsViewToggleDisabledBitmap = ResourceManager::GetBitmapN(L"T02_icon_play_list_web_dim.png");
207
208         if (pContentsViewToggleDisabledBitmap)
209         {
210                 __pContentsViewToggleButton->SetDisabledBackgroundBitmap(*pContentsViewToggleDisabledBitmap);
211                 delete pContentsViewToggleDisabledBitmap;
212         }
213
214         __pContentsViewToggleButton->AddActionEventListener(*this);
215
216         __pVolumeButton = static_cast<Button*>(__pControllerPanel->GetControl(L"IDC_OPTION_VOLUMN"));
217         __pVolumeButton->SetActionId(IDA_PLAYER_CONTROLLER_VOLUME);
218         __pVolumeButton->AddActionEventListener(*this);
219         __pShuffleButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_SHUFFLE));
220         __pShuffleButton->SetActionId(IDA_PLAYER_CONTROLLER_SHUFFLE);
221         __pShuffleButton->AddActionEventListener(*this);
222         __pRepeatButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_REPEAT));
223         __pRepeatButton->SetActionId(IDA_PLAYER_CONTROLLER_REPEAT);
224         __pRepeatButton->AddActionEventListener(*this);
225
226         Button* pButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_OPTION_PLAY_LIST_ADD));
227         pButton->SetShowState(false);
228
229         __pRewindButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_PREVIOUS_CONTROL_BUTTON));
230         __pRewindButton->SetActionId(IDA_PLAYER_CONTROLLER_REWIND);
231         __pRewindButton->AddTouchEventListener(*this);
232
233         __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_PALY_TOGGLE_CONTROL_BUTTON));
234         __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PLAY);
235         __pPlayPauseButton->AddActionEventListener(*this);
236
237         __pForwardButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_NEXT_CONTROL_BUTTON));
238         __pForwardButton->SetActionId(IDA_PLAYER_CONTROLLER_FORWARD);
239         __pForwardButton->AddTouchEventListener(*this);
240
241         Bitmap* pBackNormalBitmap = ResourceManager::GetBitmapN(L"00_icon_Back_02_web.png");
242         Bitmap* pBackPressBitmap = ResourceManager::GetBitmapN(L"00_icon_Back_02_press_web.png");
243
244         __pBackButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BACK_BUTTON));
245
246         __pBackButton->SetNormalBitmap(__pBackButton->GetPosition(), *pBackNormalBitmap);
247         __pBackButton->SetPressedBitmap(__pBackButton->GetPosition(), *pBackPressBitmap);
248
249         __pBackButton->SetActionId(IDA_PLAYER_CONTROLLER_BACK);
250         __pBackButton->AddActionEventListener(*this);
251
252         delete pBackNormalBitmap;
253         delete pBackPressBitmap;
254
255         __pCurrentTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_CURRENT_PLAYING_TIME));
256         __pTotalTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_CONTENT_TOTAL_TIME));
257         __pPlayStateSlider = static_cast<Slider*>(__pControllerPanel->GetControl(IDC_SLIDER_BAR));
258         __pPlayStateSlider->AddSliderEventListener(*this);
259
260         __pPlayStateSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL, Color(255, 255, 255, 0));
261         __pPlayStateSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED, Color(255, 255, 255, 0));
262         __pPlayStateSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED, Color(255, 255, 255, 0));
263
264         __pMoreContextButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_MORE_CONTEXT_MENU_BUTTON));
265
266         Bitmap* pMoreContextNormalBitmap = ResourceManager::GetBitmapN(L"00_icon_more_web.png");
267         Bitmap* pMoreContextPressBitmap = ResourceManager::GetBitmapN(L"00_icon_more_press_web.png");
268         Bitmap* pMoreContextDisableBitmap = ResourceManager::GetBitmapN(L"00_icon_more_dim_web.png");
269
270 //      __pMoreContextButton->SetNormalBitmap(__pMoreContextButton->GetPosition(), *pMoreContextNormalBitmap);
271 //      __pMoreContextButton->SetPressedBitmap(__pMoreContextButton->GetPosition(), *pMoreContextPressBitmap);
272 //      __pMoreContextButton->SetDisabledBitmap(__pMoreContextButton->GetPosition(), *pMoreContextDisableBitmap);
273
274         __pMoreContextButton->SetNormalBackgroundBitmap(*pMoreContextNormalBitmap);
275         __pMoreContextButton->SetPressedBackgroundBitmap(*pMoreContextPressBitmap);
276         __pMoreContextButton->SetDisabledBackgroundBitmap(*pMoreContextDisableBitmap);
277
278         __pMoreContextButton->SetActionId(IDA_PLAYER_CONTROLLER_MORE);
279         __pMoreContextButton->AddActionEventListener(*this);
280
281         delete pMoreContextNormalBitmap;
282         delete pMoreContextPressBitmap;
283         delete pMoreContextDisableBitmap;
284
285         __pAnimationFinishedTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
286         __pAnimationFinishedTimer->Construct(*this);
287         __pContentPlayTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
288         __pContentPlayTimer->Construct(*this);
289         __pPlayerPresentationModel = PlayerPresentationModel::GetInstance();
290
291         __pContentsListViewPanel = new (std::nothrow) Panel();
292         if (IsFailed(__pContentsListViewPanel->Construct(IDL_MUSIC_PLAYER_CONTENTS_LIST_VIEW_PANEL)))
293         {
294                 AppLogDebug("Construct(IDL_MUSIC_PLAYER_CONTENTS_LIST_VIEW_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
295                 delete __pContentsListViewPanel;
296                 return E_FAILURE;
297         }
298
299         __pPanelRegisterBar = static_cast<Panel*>(GetControl(IDC_PANEL_REGISTER_BAR));
300         __pPanelRegisterBar->AddControl(__pContentsListViewPanel);
301         __pContentsListViewPanel->SetShowState(false);
302         __pContentsListViewPanel->SetEnabled(false);
303
304         CommonUtil::SetLayoutFitToContainer(*__pPanelRegisterBar, *__pContentsListViewPanel);
305         TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
306         pContentsTableView->AddTableViewItemEventListener(*this);
307         pContentsTableView->SetItemProvider(this);
308
309         __pContentsAlbumViewPanel = new (std::nothrow) Panel();
310         if (IsFailed(__pContentsAlbumViewPanel->Construct(IDL_MUSIC_PLAYER_CONTENTS_ALBUM_VIEW_PANEL)))
311         {
312                 AppLogDebug("Construct(IDL_MUSIC_PLAYER_CONTENTS_ALBUM_VIEW_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
313                 delete __pContentsAlbumViewPanel;
314                 return E_FAILURE;
315         }
316         __pPanelRegisterBar->AddControl(__pContentsAlbumViewPanel);
317         CommonUtil::SetLayoutFitToContainer(*__pPanelRegisterBar, *__pContentsAlbumViewPanel);
318
319         Label* pAlbumThumbnailLabel = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
320         __pContentsAlbumViewPanel->SetControlAlwaysOnTop(*pAlbumThumbnailLabel, true);
321         pAlbumThumbnailLabel->AddTouchEventListener(*this);
322
323         FloatDimension floatDimension = pAlbumThumbnailLabel->GetSizeF();
324         __pAlbumArtElements = new (std::nothrow) VisualElement();
325         __pAlbumArtElements->Construct();
326         __pAlbumArtElements->SetName(L"VisualElement");
327         __pAlbumArtElements->SetBounds(FloatRectangle(0.0f, 0.0f, floatDimension.width, floatDimension.height));
328         __pAlbumArtElements->SetClipChildrenEnabled(false);
329         __pAlbumArtElements->SetShowState(true);
330         pAlbumThumbnailLabel->GetVisualElement()->AttachChild(*__pAlbumArtElements);
331
332         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT] = new (std::nothrow) VisualElement();
333         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->Construct();
334         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->SetBounds(FloatRectangle(0.0f, 0.0f, floatDimension.width, floatDimension.height));
335         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->SetShowState(true);
336         __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]);
337
338         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS] = new (std::nothrow) VisualElement();
339         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->Construct();
340         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetBounds(FloatRectangle(-604.0, 0.0f, floatDimension.width, floatDimension.height));
341         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(true);
342         __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]);
343
344         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT] = new (std::nothrow) VisualElement();
345         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->Construct();
346         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetName(L"Rect3");
347         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetBounds(FloatRectangle(836.0, 0.0f, floatDimension.width, floatDimension.height));
348
349         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(true);
350         __pAlbumArtElements->AttachChild(*__pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]);
351
352         rectanglePreviousElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetBounds();
353         rectangleCurrentElement = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetBounds();
354         rectangleNextElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetBounds();
355
356         AddOrientationEventListener(*this);
357         AddKeyEventListener(*this);
358
359         UpdateSplitBarState();
360         TogglePlayPauseImage(PLAYER_STATE_CLOSED);
361         SetRepeatButtonImage(__pPlayerPresentationModel->GetRepeatState());
362
363         AppLogDebug("EXIT");
364         return ThumbnailBase::Construct();
365 }
366
367 void
368 PlayerForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
369 {
370         AppLogDebug("ENTER");
371         FloatDimension floatDimension = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->GetSizeF();
372
373         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->SetBounds(FloatRectangle(0.0f, 0.0f, floatDimension.width, floatDimension.height));
374         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetBounds(FloatRectangle(-604.0, 0.0f, floatDimension.width, floatDimension.height));
375         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetBounds(FloatRectangle(836.0, 0.0f, floatDimension.width, floatDimension.height));
376
377         rectanglePreviousElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetBounds();
378         rectangleCurrentElement = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetBounds();
379         rectangleNextElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetBounds();
380
381         UpdateSplitBarState();
382
383         Rectangle clientBounds = GetClientAreaBounds();
384         if (orientationStatus == ORIENTATION_STATUS_LANDSCAPE
385                 || orientationStatus == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
386         {
387                 if (__pVolumePanel != null)
388                 {
389                         if (clientBounds.width > 1200)
390                         {
391                                 __pVolumePanel->SetPosition(clientBounds.width - W_HORIZONTAL_PLAYER , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50);
392                         }
393                         else
394                         {
395                                 __pVolumePanel->SetBounds(Rectangle(clientBounds.width - 670
396                                                                                                         , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
397                                                                                                         , 680
398                                                                                                         , H_VOLUME_PANEL));
399                         }
400                         __pVolumePanel->Invalidate(true);
401                 }
402         }
403         else if (orientationStatus == ORIENTATION_STATUS_PORTRAIT
404                         || orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)
405         {
406                 if (__pVolumePanel != null)
407                 {
408                         if (clientBounds.width > 1200)
409                         {
410                                 __pVolumePanel->SetPosition(0, clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50);
411                         }
412                         else
413                         {
414                                 __pVolumePanel->SetBounds( Rectangle(0
415                                                                                                         , clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
416                                                                                                         , clientBounds.width
417                                                                                                         , H_VOLUME_PANEL));
418                         }
419                         __pVolumePanel->Invalidate(true);
420                 }
421         }
422         TogglePlayPauseImage(__pPlayerPresentationModel->GetPlayerState());
423         TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
424         pContentsTableView->UpdateTableView();
425         __pContentsListViewPanel->Invalidate(true);
426         AppLogDebug("EXIT");
427 }
428
429 result
430 PlayerForm::OnTerminating(void)
431 {
432         AppLogDebug("ENTER");
433         ThumbnailBase::Stop();
434         if (__pAlbumArtElements)
435         {
436                 __pAlbumArtElements->Destroy();
437                 __pAlbumArtElements = null;
438         }
439
440         if (__isRunByAppControl == true)
441         {
442                 __pPlayerPresentationModel->SetRepeatMode(__prevRepeatStateRunByAppControl);
443                 __isRunByAppControl = false;
444         }
445
446         RemoveContextMenu();
447         RemoveSharePicker();
448         RemovePlayListPicker();
449         RemoveSetAsPicker();
450
451         RemoveOrientationEventListener(*this);
452         RemoveKeyEventListener(*this);
453
454         delete __pSoundPathPopup;
455         __pSoundPathPopup = null;
456
457         if (__pAnimationFinishedTimer != null)
458         {
459                 __pAnimationFinishedTimer->Cancel();
460                 delete __pAnimationFinishedTimer;
461         }
462
463         if (__pContentPlayTimer != null)
464         {
465                 __pContentPlayTimer->Cancel();
466                 delete __pContentPlayTimer;
467         }
468
469         if (__pPlayerPresentationModel != null)
470         {
471                 __pPlayerPresentationModel->RemoveMusicPlayerEventListener(*this);
472                 __pPlayerPresentationModel->DestroyPlayerPresentationModel();
473         }
474         SettingPresentationModel::GetInstance()->DestroySettingPresentationModel();
475         AppLogDebug("EXIT");
476         return E_SUCCESS;
477 }
478
479 void
480 PlayerForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
481 {
482         AppLogDebug("ENTER");
483         SceneManager* pSceneManager = SceneManager::GetInstance();
484         AppAssert(pSceneManager);
485
486         switch (actionId)
487         {
488         case IDA_BUTTON_CONTENTS_ALBUM_VIEW:
489                 {
490                         CancelAllThumbnailRequest();
491                         __pContentsListViewPanel->SetShowState(false);
492                         __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
493                         __pContentsAlbumViewPanel->SetShowState(true);
494                         __pPanelRegisterBar->Invalidate(true);
495                 }
496                 break;
497
498         case IDA_BUTTON_CONTENTS_LIST_VIEW:
499                 {
500                         __pContentsAlbumViewPanel->SetShowState(false);
501                         __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_ALBUM_VIEW);
502                         __pContentsListViewPanel->SetShowState(true);
503                         __pContentsListViewPanel->SetEnabled(true);
504                         __pPanelRegisterBar->Invalidate(true);
505         
506                         TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
507                         pContentsTableView->UpdateTableView();
508                 }
509                 break;
510
511         case IDA_PLAYER_CONTROLLER_VOLUME:
512                 {
513                         if (__pVolumePanel == null)
514                         {
515                                 InitializeVolumeBar();
516                         }
517                         else
518                         {
519                                 if (__pVolumePanel->GetShowState() == true)
520                                 {
521                                         __pVolumePanel->SetShowState(false);
522                                 }
523                                 else
524                                 {
525                                         int MediaSoundVolume = 0;
526                                         SettingInfo::GetValue(MEDIA_VOLUME, MediaSoundVolume);
527                                         __pPlayerPresentationModel->SetVolume(MediaSoundVolume);
528                                         __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
529                                         __pVolumeSlider->Invalidate(true);
530                                         __pVolumePanel->SetShowState(true);
531                                 }
532                         }
533                 }
534                 break;
535
536         case IDA_PLAYER_CONTROLLER_PLAY:
537                 {
538                         String* currentPlayConent = __pPlayerPresentationModel->GetPlayContentPath();
539                         String* ContentPath = __pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetCurrentContentIndex());
540
541                         if (currentPlayConent->Equals(*ContentPath))
542                         {
543                                 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), __pPlayStateSlider->GetValue(), true);
544                         }
545                         else
546                         {
547                                 __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), __pPlayStateSlider->GetValue());
548                         }
549
550                         if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
551                         {
552                                 SetFileNotExistState(false);
553                         }
554                 }
555                 break;
556
557         case IDA_PLAYER_CONTROLLER_PAUSE:
558                 {
559                         __pPlayerPresentationModel->Pause();
560                 }
561                 break;
562
563         case IDA_PLAYER_CONTROLLER_BACK:
564                 {
565                         result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_DESTROY_OPTION_KEEP));
566                         if (IsFailed(r))
567                         {
568                                 UiApp* pApp = UiApp::GetInstance();
569                                 pApp->Terminate();
570                         }
571                         __isRunByAppControl = false;
572 //                      else if (__isRunByAppControl)
573 //                      {
574 //                              Tizen::App::UiApp::GetInstance()->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
575 //                      }
576                 }
577                 break;
578
579         case IDA_PLAYER_CONTROLLER_REPEAT:
580                 {
581                         switch (__pPlayerPresentationModel->GetRepeatState())
582                         {
583                         case IDA_TYPE_REPEAT_A:
584                                 {
585                                         SetRepeatButtonImage(IDA_TYPE_REPEAT_ONE);
586                                 }
587                                 break;
588
589                         case IDA_TYPE_REPEAT_ONE:
590                                 {
591                                         SetRepeatButtonImage(IDA_TYPE_REPEAT_ALL);
592                                 }
593                                 break;
594
595                         case IDA_TYPE_REPEAT_ALL:
596                                 {
597                                         SetRepeatButtonImage(IDA_TYPE_REPEAT_A);
598                                 }
599                                 break;
600
601                         default:
602                                 break;
603                         }
604                 }
605                 break;
606
607         case IDA_PLAYER_CONTROLLER_SHUFFLE:
608                 {
609                         if (__pPlayerPresentationModel->IsShuffleEnable() == false)
610                         {
611                                 SetShuffleButtonImage(true);
612                         }
613                         else
614                         {
615                                 SetShuffleButtonImage(false);
616                         }
617                 }
618                 break;
619
620         case IDA_PLAYER_CONTROLLER_MORE:
621                 {
622                         if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_NORMAL)
623                         {
624                                 CreateContextMenuN(source);
625                                 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_SET_AS | CONTEXT_MENU_ITEM_STYLE_DETAILS | CONTEXT_MENU_ITEM_STYLE_SHARE_VIA
626                                                                                                                                                                 | CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST | CONTEXT_MENU_ITEM_STYLE_SETTINGS);
627                         }
628                         else if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_APP_CONTROL || GetPlayerScreenState() == PLAYER_SCREEN_STATE_INVALID_CONTENT_ID)
629                         {
630                                 CreateContextMenuN(source);
631                                 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_SET_AS | CONTEXT_MENU_ITEM_STYLE_DETAILS | CONTEXT_MENU_ITEM_STYLE_SHARE_VIA);
632                         }
633                 }
634                 break;
635
636         case IDA_CONTEXT_MENU_ITEM_SHARE_VIA:
637                 {
638                         LanucherPicker(PICKER_TYPE_SHARE_PICKER);
639                 }
640                 break;
641
642         case IDA_CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST:
643                 {
644                         LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
645                 }
646                 break;
647
648         case IDA_CONTEXT_MENU_ITEM_STYLE_SET_AS:
649                 {
650                         LanucherPicker(PICKER_TYPE_SET_AS_PICKER);
651                 }
652                 break;
653
654         case IDA_CONTEXT_MENU_ITEM_STYLE_SOUND_PATH:
655                 {
656                         if (__pSoundPathPopup == null)
657                         {
658                                 __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
659                                 __pSoundPathPopup->Initialize();
660                         }
661                         __pSoundPathPopup->ShowPopup(true);
662                 }
663                 break;
664
665         case IDA_CONTEXT_MENU_ITEM_STYLE_DETAILS:
666                 {
667                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CONTENT_DETAIL));
668                 }
669                 break;
670
671         case IDA_CONTEXT_MENU_ITEM_SETTINGS:
672                 {
673                         SettingPresentationModel::GetInstance()->InitializeSettingValue();
674                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_MUSIC_SETTING));
675                 }
676                 break;
677
678         default:
679                 break;
680         }
681
682         TryRemoveContextMenu(actionId);
683         AppLogDebug("EXIT");
684 }
685
686 void
687 PlayerForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
688 {
689         AppLogDebug("ENTER");
690         switch (keyCode)
691         {
692         case KEY_SIDE_UP:
693                 {
694                         if (__pVolumePanel == null)
695                         {
696                                 InitializeVolumeBar();
697                         }
698
699                         __pVolumePanel->SetShowState(true);
700                         __pPlayerPresentationModel->SetVolume(__pPlayerPresentationModel->GetVolume() + 1);
701                         __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
702                         __pVolumeSlider->Invalidate(true);
703                 }
704                 break;
705
706         case KEY_SIDE_DOWN:
707                 {
708                         if (__pVolumePanel == null)
709                         {
710                                 InitializeVolumeBar();
711                         }
712
713                         __pVolumePanel->SetShowState(true);
714                         __pPlayerPresentationModel->SetVolume(__pPlayerPresentationModel->GetVolume() - 1);
715                         __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
716                         __pVolumeSlider->Invalidate(true);
717                 }
718                 break;
719
720         default:
721                 break;
722         }
723         AppLogDebug("EXIT");
724 }
725
726 void
727 PlayerForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
728 {
729         AppLogDebug("ENTER");
730         AppLogDebug("EXIT");
731 }
732
733 void
734 PlayerForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
735 {
736         AppLogDebug("ENTER");
737         AppLogDebug("EXIT");
738 }
739
740 void
741 PlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
742 {
743         AppLogDebug("ENTER");
744         if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
745         {
746                 __isLongPressed = true;
747                 if (source.Equals(*__pRewindButton) && (__pPlayStateSlider->IsEnabled()))
748                 {
749                         __pPlayerPresentationModel->SeekToRewind();
750                 }
751                 else if (__pPlayStateSlider->IsEnabled())
752                 {
753                         __pPlayerPresentationModel->SeekToForward();
754                 }
755         }
756         AppLogDebug("EXIT");
757 }
758
759 void
760 PlayerForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
761 {
762         AppLogDebug("ENTER");
763         if (__isAnimationPerformed == true || __isContentMoveCompleted == true)
764         {
765                 return;
766         }
767
768         if (currentPosition.y < 0 || currentPosition.y > GetBounds().height - __pControllerPanel->GetBounds().height)
769         {
770                 return;
771         }
772
773         if (Tizen::Base::Utility::Math::Abs(touchInfo.GetStartPosition().y - currentPosition.y) > 100)
774         {
775                 return;
776         }
777
778         if (currentPosition.x > touchInfo.GetStartPosition().x + 100)
779         {
780                 if (__pPlayerPresentationModel->GetContentListCount() > 1)
781                 {
782                         while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetPreviousContentIndex()) == false
783                                 && __pPlayerPresentationModel->GetContentListCount() > 0)
784                         {
785                                 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetPreviousContentIndex()));
786                         }
787                 }
788                 __flickDirection = FLICK_DIRECTION_RIGHT;
789                 __isContentMoveCompleted = true;
790                 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
791                 {
792                         MessageBox messageBox;
793                         messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
794
795                         int modalResult = 0;
796                         messageBox.ShowAndWait(modalResult);
797                 }
798                 else
799                 {
800                         PlayAnimation();
801                 }
802         }
803         else if (currentPosition.x < touchInfo.GetStartPosition().x - 100)
804         {
805                 if (__pPlayerPresentationModel->GetContentListCount() > 1)
806                 {
807                         while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetNextContentIndex()) == false
808                                 && __pPlayerPresentationModel->GetContentListCount() > 0)
809                         {
810                                 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetNextContentIndex()));
811                         }
812                 }
813                 __flickDirection = FLICK_DIRECTION_LEFT;
814                 __isContentMoveCompleted = true;
815                 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
816                 {
817                         MessageBox messageBox;
818                         messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
819
820                         int modalResult = 0;
821                         messageBox.ShowAndWait(modalResult);
822                 }
823                 else
824                 {
825                         PlayAnimation();
826                 }
827         }
828         AppLogDebug("EXIT");
829 }
830
831 void
832 PlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
833 {
834         AppLogDebug("ENTER");
835         if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
836         {
837                 __isLongPressed = false;
838         }
839         else
840         {
841                 if (__pVolumePanel != null && __pVolumePanel->GetShowState())
842                 {
843                         __pVolumePanel->SetShowState(false);
844                 }
845         }
846         AppLogDebug("EXIT");
847 }
848
849 void
850 PlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
851 {
852         AppLogDebug("ENTER");
853         __isContentMoveCompleted = false;
854         if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
855         {
856                 if (__isLongPressed == true)
857                 {
858                         __pPlayerPresentationModel->StopForwardRewind();
859                 }
860                 else
861                 {
862                         if (source.Equals(*__pRewindButton))
863                         {
864                                 if (__pPlayerPresentationModel->GetContentListCount() > 1)
865                                 {
866                                         while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetPreviousContentIndex()) == false
867                                                 && __pPlayerPresentationModel->GetContentListCount() > 0)
868                                         {
869                                                 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetPreviousContentIndex()));
870                                         }
871                                 }
872                                 __flickDirection = FLICK_DIRECTION_RIGHT;
873
874                                 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
875                                 {
876                                         MessageBox messageBox;
877                                         messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
878
879                                         int modalResult = 0;
880                                         messageBox.ShowAndWait(modalResult);
881                                 }
882                                 else
883                                 {
884                                         PlayAnimation();
885                                 }
886                         }
887                         else
888                         {
889                                 if (__pPlayerPresentationModel->GetContentListCount() > 1)
890                                 {
891                                         while (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetNextContentIndex()) == false
892                                                 && __pPlayerPresentationModel->GetContentListCount() > 0)
893                                         {
894                                                 __pPlayerPresentationModel->RemoveContent(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetNextContentIndex()));
895                                         }
896                                 }
897                                 __flickDirection = FLICK_DIRECTION_LEFT;
898
899                                 if (__pPlayerPresentationModel->GetContentListCount() <= 1)
900                                 {
901                                         MessageBox messageBox;
902                                         messageBox.Construct(L"", ResourceManager::GetString(L"IDS_MUSIC_HEADER_NO_SONGS"), MSGBOX_STYLE_NONE, 1000);
903
904                                         int modalResult = 0;
905                                         messageBox.ShowAndWait(modalResult);
906                                 }
907                                 else
908                                 {
909                                         PlayAnimation();
910                                 }
911                         }
912                 }
913         }
914         else
915         {
916                 // Empty statement
917         }
918         AppLogDebug("EXIT");
919 }
920
921 void
922 PlayerForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
923 {
924         AppLogDebug("ENTER");
925         __isContentMoveCompleted = false;
926
927         if (source.Equals(*__pForwardButton) || source.Equals(*__pRewindButton))
928         {
929                 if (__isLongPressed == true)
930                 {
931                         __pPlayerPresentationModel->StopForwardRewind();
932                         __isLongPressed = false;
933                 }
934         }
935
936         AppLogDebug("EXIT");
937
938 }
939
940 void
941 PlayerForm::PlayAnimation(void)
942 {
943         AppLogDebug("ENTER");
944         __isAnimationPerformed = true;
945 //      if (AnimationTransaction::GetStatus(__transactionID) == ANIMATION_TRANSACTION_STATUS_STOPPED)
946 //      {
947                 if (__flickDirection == FLICK_DIRECTION_RIGHT)
948                 {
949                         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(true);
950
951                         AnimationTransaction::Begin(__transactionID);
952                         AnimationTransaction::SetVisualElementAnimationDuration(200);
953                         AnimationTransaction::SetCurrentTransactionEventListener(this);
954
955                         VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
956                         pAnimation->SetPropertyName(L"bounds");
957                         pAnimation->SetStartValue(Variant(rectanglePreviousElement));
958                         pAnimation->SetEndValue(Variant(rectangleCurrentElement));
959
960                         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->AddAnimation(*pAnimation);
961                         delete pAnimation;
962
963                         pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
964                         pAnimation->SetPropertyName(L"bounds");
965                         pAnimation->SetStartValue(Variant(rectangleCurrentElement));
966                         pAnimation->SetEndValue(Variant(rectangleNextElement));
967
968                         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->AddAnimation(*pAnimation);
969
970                         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(false);
971                         delete pAnimation;
972
973                         AnimationTransaction::Commit();
974                 }
975                 else if (__flickDirection == FLICK_DIRECTION_LEFT)
976                 {
977                         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(true);
978
979                         AnimationTransaction::Begin(__transactionID);
980                         AnimationTransaction::SetVisualElementAnimationDuration(200);
981                         AnimationTransaction::SetCurrentTransactionEventListener(this);
982
983                         VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
984                         pAnimation->SetPropertyName(L"bounds");
985                         pAnimation->SetStartValue(Variant(rectangleCurrentElement));
986                         pAnimation->SetEndValue(Variant(rectanglePreviousElement));
987
988                         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->AddAnimation(*pAnimation);
989                         delete pAnimation;
990
991                         pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
992                         pAnimation->SetPropertyName(L"bounds");
993                         pAnimation->SetStartValue(Variant(rectangleNextElement));
994                         pAnimation->SetEndValue(Variant(rectangleCurrentElement));
995
996                         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->AddAnimation(*pAnimation);
997                         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(false);
998                         delete pAnimation;
999
1000                         AnimationTransaction::Commit();
1001                 }
1002                 else
1003                 {
1004                         // Empty statement
1005                 }
1006 //      }
1007         AppLogDebug("EXIT");
1008 }
1009
1010 void
1011 PlayerForm::StopAnimation(void)
1012 {
1013         AppLogDebug("ENTER");
1014         AppLogDebug("EXIT");
1015 }
1016
1017 void
1018 PlayerForm::OnAnimationTransactionStarted(int transactionId)
1019 {
1020         AppLogDebug("ENTER");
1021         __pContentPlayTimer->Cancel();
1022         AppLogDebug("EXIT");
1023 }
1024
1025 void
1026 PlayerForm::OnAnimationTransactionStopped(int transactionId)
1027 {
1028         AppLogDebug("ENTER");
1029         AppLogDebug("EXIT");
1030 }
1031
1032 void
1033 PlayerForm::OnAnimationTransactionFinished(int transactionId)
1034 {
1035         AppLogDebug("ENTER");
1036         __isAnimationPerformed = false;
1037         __pAnimationFinishedTimer->Start(1);
1038         __pContentPlayTimer->Start(700);
1039         AppLogDebug("EXIT");
1040 }
1041
1042 void
1043 PlayerForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
1044 {
1045         AppLogDebug("ENTER");
1046         if (source.Equals(*__pPlayStateSlider))
1047         {
1048                 if (value >= 100)
1049                 {
1050                         __pPlayStateSlider->SetShowState(false);//To cancel touch event.
1051                 }
1052                 __pPlayerPresentationModel->SetPlayPosition(value);
1053                 __pPlayStateSlider->SetShowState(true);
1054         }
1055         else
1056         {
1057                 if (__pVolumePanel->GetShowState() == false)
1058                 {
1059                         __pVolumePanel->SetShowState(true);
1060                 }
1061                 __pPlayerPresentationModel->SetVolume(value);
1062         }
1063         AppLogDebug("EXIT");
1064 }
1065
1066 void
1067 PlayerForm::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1068 {
1069         AppLogDebug("ENTER");
1070         if (&timer == __pAnimationFinishedTimer)
1071         {
1072                 if (__flickDirection == FLICK_DIRECTION_RIGHT)
1073                 {
1074                         Tizen::Ui::Animations::VisualElement* pTempVisualElement = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT];
1075                         pTempVisualElement->SetBounds(rectanglePreviousElement);
1076
1077                         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT] = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT];
1078                         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT] = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS];
1079                         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS] = pTempVisualElement;
1080                         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->SetShowState(false);
1081
1082                         __pPlayerPresentationModel->MovePreviousContent(true);
1083                 }
1084                 else if (__flickDirection == FLICK_DIRECTION_LEFT)
1085                 {
1086                         Tizen::Ui::Animations::VisualElement* pTempVisualElement = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS];
1087                         pTempVisualElement->SetBounds(rectangleNextElement);
1088
1089                         __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS] = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT];
1090                         __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT] = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT];
1091                         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT] = pTempVisualElement;
1092                         __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->SetShowState(false);
1093
1094                         __pPlayerPresentationModel->MoveNextContent();
1095                 }
1096                 __flickDirection = FLICK_DIRECTION_NONE;
1097                 __transactionID = ANIMATION_TRANSACTION_STATUS_STOPPED;
1098         }
1099         else
1100         {
1101                 if ((__pPlayerPresentationModel->GetPlayerState() != PLAYER_STATE_PAUSED) && (__pPlayerPresentationModel->IsDuringCall() == false))
1102                 {
1103                         __pPlayStateSlider->SetShowState(false);//To cancel touch event.
1104                         __pPlayerPresentationModel->Play(__pPlayerPresentationModel->GetCurrentContentIndex(), MIN_PLAY_STATE_SLIDER_COUNT);
1105                         __pPlayStateSlider->SetShowState(true);
1106                 }
1107
1108                 if(!__pPlayerPresentationModel->IsDuringCall())
1109                 {
1110                         SetFileNotExistState(__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()));
1111                 }
1112         }
1113         AppLogDebug("EXIT");
1114 }
1115
1116 int
1117 PlayerForm::GetItemCount(void)
1118 {
1119         AppLogDebug("ENTER");
1120         if (__pPlayerPresentationModel == null)
1121         {
1122                 return INIT_VALUE;
1123         }
1124         AppLogDebug("EXIT");
1125         return __pPlayerPresentationModel->GetContentListCount();
1126 }
1127
1128 Tizen::Ui::Controls::TableViewItem*
1129 PlayerForm::CreateItem(int index, int itemWidth)
1130 {
1131         AppLogDebug("ENTER");
1132         RelativeLayout layout;
1133         layout.Construct();
1134
1135         TableViewItem* pItem = new (std::nothrow) TableViewItem();
1136         ContentInformation* pContentInfo = __pPlayerPresentationModel->GetContentInfoN(index);
1137
1138         result r = pItem->Construct(layout, Dimension(itemWidth, ITEM_HEIGHT), TABLE_VIEW_ANNEX_STYLE_NORMAL);
1139         TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
1140         TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
1141
1142         r = CreateTableViewItem(*pItem, *pContentInfo);
1143         TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
1144
1145         RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(index)));
1146         delete pContentInfo;
1147
1148         AppLogDebug("EXIT");
1149         return pItem;
1150
1151 CATCH:
1152         AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1153         delete pContentInfo;
1154         return null;
1155 }
1156
1157 bool
1158 PlayerForm::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1159 {
1160         AppLogDebug("ENTER");
1161         delete pItem;
1162         pItem = null;
1163         AppLogDebug("EXIT");
1164         return true;
1165 }
1166
1167 int
1168 PlayerForm::GetDefaultItemHeight(void)
1169 {
1170         AppLogDebug("ENTER");
1171         AppLogDebug("EXIT");
1172         return ITEM_HEIGHT;
1173 }
1174
1175 void
1176 PlayerForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1177 {
1178         AppLogDebug("ENTER");
1179         SceneManager* pSceneManager = SceneManager::GetInstance();
1180         AppAssert(pSceneManager);
1181
1182         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
1183         {
1184                 __pPlayerPresentationModel->Play(itemIndex, MIN_PLAY_STATE_SLIDER_COUNT);
1185
1186                 if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
1187                 {
1188                         SetFileNotExistState(false);
1189                 }
1190         }
1191         AppLogDebug("EXIT");
1192 }
1193
1194 void
1195 PlayerForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1196 {
1197         AppLogDebug("ENTER");
1198         AppLogDebug("EXIT");
1199 }
1200
1201 void
1202 PlayerForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo)
1203 {
1204         AppLogDebug("ENTER");
1205         AppLogDebug("EXIT");
1206 }
1207
1208 void
1209 PlayerForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1210 {
1211         AppLogDebug("ENTER");
1212         AppLogDebug("EXIT");
1213 }
1214
1215 void
1216 PlayerForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1217                                         const Tizen::Ui::Scenes::SceneId& currentSceneId,
1218                                         Tizen::Base::Collection::IList* pArgs)
1219 {
1220         AppLogDebug("ENTER");
1221         MusicPlayerApp* pMusicPlayerApp = static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance());
1222         TryReturnVoid(pMusicPlayerApp != null, "Unable to cast UiApp to MusicPlayerApp");
1223         /* Comment out this code temporarily in 2.0. This will be supported in 2.1.
1224         SetKeyCapture(KEY_SIDE_UP);
1225         SetKeyCapture(KEY_SIDE_DOWN);
1226         */
1227
1228         __pPlayerPresentationModel->AddMusicPlayerEventListener(*this);
1229
1230         if (pArgs != null)
1231         {
1232                 if (IsFailed(__pPlayerPresentationModel->SetContentList(pArgs)))
1233                 {
1234                         AppLogDebug("__pPlayerPresentationModel->SetContentList failed(%s)", GetErrorMessage(GetLastResult()));
1235                         SetPlayerScreenState(PLAYER_SCREEN_STATE_NO_CONTENT_LIST);
1236
1237                         pArgs->RemoveAll();
1238                         delete pArgs;
1239                         return;
1240                 }
1241
1242                 __pPlayerPresentationModel->Play(static_cast<Integer*>(pArgs->GetAt(1))->ToInt(), MIN_PLAY_STATE_SLIDER_COUNT);
1243                 SetFileNotExistState(__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()));
1244                 SetRepeatButtonImage(__pPlayerPresentationModel->GetRepeatState());// 0 - 2 (OFF, ONE, ALL)
1245                 SetShuffleButtonImage(__pPlayerPresentationModel->IsShuffleEnable());// 0 - 1 (OFF, ON)
1246                 TogglePlayPauseImage(__pPlayerPresentationModel->GetPlayerState());
1247
1248
1249                 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1250                 if (pContentsTableView != null)
1251                 {
1252                         pContentsTableView->UpdateTableView();
1253                 }
1254
1255                 __isAppControlDuringCall = false;
1256                 __isRunByAppControl = false;
1257
1258                 if (!static_cast<String*>(pArgs->GetAt(0))->Equals(MUSIC, false))
1259                 {
1260                         SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1261                 }
1262                 else
1263                 {
1264                         if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_APP_CONTROL)
1265                         {
1266                                 if (__pPlayerPresentationModel->IsDuringCall())
1267                                 {
1268                                         SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1269                                 }
1270                                 else
1271                                 {
1272                                         SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1273                                 }
1274                         }
1275                 }
1276
1277                 pArgs->RemoveAll(true);
1278                 delete pArgs;
1279         }
1280         else
1281         {
1282                 PlayerState playerState = __pPlayerPresentationModel->GetPlayerState();
1283
1284                 if (playerState != PLAYER_STATE_PAUSED
1285                                 && playerState != PLAYER_STATE_PLAYING
1286                                 && __pPlayerPresentationModel->GetContentListCount() == INIT_VALUE)
1287                 {
1288                         playerState = PLAYER_STATE_ERROR;
1289                 }
1290
1291                 SetContentInfo( __pPlayerPresentationModel->GetCurrentContentIndex());
1292                 OnPlayTimeChanged(__pPlayerPresentationModel->GetCurrentDuration(), __pPlayerPresentationModel->GetPlayPosition());
1293                 OnPlayStateChanged(playerState);
1294
1295                 if (GetPlayerScreenState() == PLAYER_SCREEN_STATE_DURING_CALL
1296                         && playerState != PLAYER_STATE_ERROR
1297                         && __pPlayerPresentationModel->IsDuringCall() == false)
1298                 {
1299                         if(!__isAppControlDuringCall)
1300                         {
1301                                 SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1302                         }
1303                         else
1304                         {
1305                                 SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1306                         }
1307                 }
1308         }
1309
1310         if (__pContentsListViewPanel->IsEnabled() == true && __isRunByAppControl == false)
1311         {
1312                 TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1313                 pContentsTableView->UpdateTableView();
1314         }
1315
1316         Invalidate(true);
1317         AppLogDebug("EXIT");
1318 }
1319
1320 void
1321 PlayerForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
1322                                                                                         const Tizen::Ui::Scenes::SceneId& nextSceneId)
1323 {
1324         AppLogDebug("ENTER");
1325         CancelAllThumbnailRequest();
1326         __pPlayerPresentationModel->RemoveMusicPlayerEventListener(*this);
1327
1328         if (__pVolumePanel != null && __pVolumePanel->GetShowState())
1329         {
1330                 __pVolumePanel->SetShowState(false);
1331         }
1332         AppLogDebug("EXIT");
1333 }
1334
1335 void
1336 PlayerForm::OnChangedContentListByAppControlN(Tizen::Base::Collection::IList* pArgs)
1337 {
1338         AppLogDebug("ENTER");
1339         MusicPlayerApp* pMusicPlayerApp = static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance());
1340         TryReturnVoid(pMusicPlayerApp != null, "Unable to cast UiApp to MusicPlayerApp");
1341
1342         if (pArgs == null || static_cast<String*>(pArgs->GetAt(0))->Equals(MUSIC, false))
1343         {
1344                 AppLogDebug("EXIT(E_FAILURE)");
1345                 if (pArgs != null)
1346                 {
1347                         pArgs->RemoveAll();
1348                         delete pArgs;
1349                 }
1350                 return;
1351         }
1352
1353         result r = __pPlayerPresentationModel->SetContentList(pArgs);
1354         if (IsFailed(r))
1355         {
1356                 AppLogDebug("EXIT(%s)", GetErrorMessage(r));
1357                 SetPlayerScreenState(PLAYER_SCREEN_STATE_NO_CONTENT_LIST);
1358                 pArgs->RemoveAll();
1359                 delete pArgs;
1360
1361                 return;
1362         }
1363
1364         int playIndex = (static_cast<Integer*>(pArgs->GetAt(1)))->ToInt();
1365         __pPlayerPresentationModel->Play(playIndex, MIN_PLAY_STATE_SLIDER_COUNT);
1366         SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1367
1368         TableView* pContentsTableView = static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW));
1369         if (pContentsTableView != null)
1370         {
1371                 pContentsTableView->UpdateTableView();
1372         }
1373
1374         pArgs->RemoveAll();
1375         delete pArgs;
1376
1377         Invalidate(true);
1378         AppLogDebug("EXIT");
1379 }
1380
1381 void
1382 PlayerForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1383 {
1384         AppLogDebug("ENTER");
1385         AppLogDebug("OnUserEventReceivedN %d", requestId);
1386         if (requestId == ID_DESTORY_PLAY_LIST_PICKER_POPUP || requestId == ID_DESTORY_SHARE_POPUP)
1387         {
1388                 RemovePlayListPicker();
1389                 RemoveSharePicker();
1390         }
1391
1392         if (pArgs != null)
1393         {
1394                 pArgs->RemoveAll(true);
1395                 delete pArgs;
1396         }
1397         AppLogDebug("EXIT");
1398 }
1399
1400 void
1401 PlayerForm::OnPlayStateChanged(PlayerState playerState)
1402 {
1403         AppLogDebug("ENTER");
1404         AppLogDebug("%d", playerState);
1405
1406         if (playerState == PLAYER_STATE_ERROR)
1407         {
1408                 MusicPlayerApp* pApp = static_cast<MusicPlayerApp*>(App::GetInstance());
1409                 RemoveContextMenu();
1410                 SetContentInfo( __pPlayerPresentationModel->GetCurrentContentIndex());
1411
1412                 if (__pPlayerPresentationModel->IsDuringCall())
1413                 {
1414                         SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1415                 }
1416                 else
1417                 {
1418                         SetPlayerScreenState(PLAYER_SCREEN_STATE_ERROR_CONTENT);
1419                 }
1420                 ShowMessageBox(ResourceManager::GetString(L"IDS_MUSIC_POP_UNABLE_TO_PLAY_ERROR_OCCURRED"));
1421
1422                 if (pApp != null && pApp->GetRequestId() != null)
1423                 {
1424                         AppControlProviderManager::GetInstance()->SendAppControlResult(pApp->GetRequestId(),APP_CTRL_RESULT_SUCCEEDED,null);
1425                         pApp->ResetRequestId();
1426                 }
1427         }
1428
1429         else if (playerState == PLAYER_STATE_PAUSED)
1430         {
1431                 if (__pPlayerPresentationModel->IsDuringCall() == true)
1432                 {
1433                         SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1434                 }
1435         }
1436         TogglePlayPauseImage(playerState);
1437         AppLogDebug("EXIT");
1438 }
1439
1440 void
1441 PlayerForm::OnPlayContentChanged(int currentContentIndex)
1442 {
1443         AppLogDebug("ENTER");
1444         SetContentInfo(currentContentIndex);
1445
1446         if ( __pPlayerPresentationModel->IsDuringCall())
1447         {
1448                 SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
1449         }
1450         else if (__playerScreenState == PLAYER_SCREEN_STATE_DURING_CALL || __playerScreenState == PLAYER_SCREEN_STATE_ERROR_CONTENT)
1451         {
1452                 if (__isAppControlDuringCall)
1453                 {
1454                         SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
1455                         __isAppControlDuringCall = false;
1456                 }
1457                 else
1458                 {
1459                         SetPlayerScreenState(PLAYER_SCREEN_STATE_NORMAL);
1460                 }
1461         }
1462         AppLogDebug("EXIT");
1463 }
1464
1465 void
1466 PlayerForm::OnPlayContentRemoved(int removedContentIndex)
1467 {
1468         AppLogDebug("ENTER");
1469         int currentIndex = __pPlayerPresentationModel->GetCurrentContentIndex();
1470         int currentContentCount = __pPlayerPresentationModel->GetContentListCount();
1471
1472         if ((removedContentIndex == currentIndex - 1)
1473                 || (currentIndex == 0 && removedContentIndex == 0)
1474                 || (currentIndex == removedContentIndex)
1475                 || (currentIndex == __pPlayerPresentationModel->GetPreviousContentIndex()))
1476         {
1477                 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_PREVIOUS);
1478         }
1479         else if ((removedContentIndex == currentIndex + 1)
1480                         || (currentIndex == currentContentCount - 1 && removedContentIndex == 0))
1481         {
1482                 UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_NEXT);
1483         }
1484         AppLogDebug("EXIT");
1485 }
1486
1487 void
1488 PlayerForm::OnPlayVolumeBarStateChanged(void)
1489 {
1490         AppLogDebug("ENTER");
1491         if (__pVolumePanel->GetShowState() == true)
1492         {
1493                 __pVolumePanel->SetShowState(false);
1494         }
1495         AppLogDebug("EXIT");
1496 }
1497
1498 void
1499 PlayerForm::OnPlayTimeChanged(const Tizen::Base::String& currentDuration, int currentPosition)
1500 {
1501         AppLogDebug("ENTER");
1502         __pCurrentTimeLabel->SetText(currentDuration);
1503         __pPlayStateSlider->SetValue(currentPosition);
1504         __pCurrentTimeLabel->Invalidate(true);
1505         __pPlayStateSlider->Invalidate(true);
1506         AppLogDebug("EXIT");
1507 }
1508
1509 void
1510 PlayerForm::OnAutoOffTimeChanged(int autoOffTime)
1511 {
1512         AppLogDebug("ENTER");
1513         __pPlayerPresentationModel->StartAutoOffTimer(autoOffTime);
1514         AppLogDebug("EXIT");
1515 }
1516
1517 void
1518 PlayerForm::OnPlayPresentationModelDestroying(void)
1519 {
1520         AppLogDebug("ENTER");
1521         if (__pPlayerPresentationModel != null)
1522         {
1523                 __pPlayerPresentationModel = null;
1524         }
1525         AppLogDebug("EXIT");
1526 }
1527
1528 result
1529 PlayerForm::ShowMessageBox(const Tizen::Base::String& showText)
1530 {
1531         AppLogDebug("ENTER");
1532         MessageBox messageBox;
1533         messageBox.Construct(L"Error", showText, MSGBOX_STYLE_NONE, 3000);
1534         int modalResult = 0;
1535         messageBox.ShowAndWait(modalResult);
1536
1537         SceneManager* pSceneManager = SceneManager::GetInstance();
1538         AppAssert(pSceneManager);
1539 //      if (static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance())->GetOperationId().Equals(TIZEN_APPCONTROL_OPERATION_PLAY, true)
1540 //              || static_cast<MusicPlayerApp*>(MusicPlayerApp::GetInstance())->GetOperationId().Equals(TIZEN_APPCONTROL_OPERATION_VIEW, true))
1541 //      {
1542 //              UiApp* pApp = UiApp::GetInstance();
1543 //              pApp->Terminate();
1544 //      }
1545 //      else
1546         {
1547 //              if (pSceneManager->IsSceneAlive(IDSCN_ALL_LIST))
1548 //              {
1549 //                      pSceneManager->GoBackward(BackwardSceneTransition());
1550 //              }
1551 //              else
1552 //              {
1553 //                      UiApp* pApp = UiApp::GetInstance();
1554 //                      pApp->Terminate();
1555 //              }
1556         }
1557         AppLogDebug("EXIT");
1558         return E_SUCCESS;
1559 }
1560
1561 void
1562 PlayerForm::SetContentInfo(int currentContentIndex)
1563 {
1564         AppLogDebug("ENTER");
1565         ContentInformation* pContentInfoStruct = __pPlayerPresentationModel->GetContentInfoN(currentContentIndex);
1566         TryReturnVoid(pContentInfoStruct != null, "The currentContentIndex is invalid");
1567
1568         __pTitleName->SetText(pContentInfoStruct->TitleName);
1569         __pArtistName->SetText(pContentInfoStruct->ArtistName);
1570
1571         __pPlayStateSlider->SetRange(MIN_PLAY_STATE_SLIDER_COUNT, MAX_PLAY_STATE_SLIDER_COUNT);
1572
1573         String totalTime = CommonUtil::GetFormatDate(pContentInfoStruct->Duration);
1574         if (totalTime.Equals(INITIAL_TIME, true) != true)
1575         {
1576                 __pTotalTimeLabel->SetText(totalTime);
1577         }
1578         else
1579         {
1580                 __pTotalTimeLabel->SetText(INITIAL_TIME);
1581         }
1582
1583         if (pContentInfoStruct->contentId.ToString().Equals(INVALID_VALUE_OF_CONTENT_ID, true))
1584         {
1585                 SetPlayerScreenState(PLAYER_SCREEN_STATE_INVALID_CONTENT_ID);
1586         }
1587 /*      else
1588         {
1589                 if (__pPlayerPresentationModel->GetPlayerState() != PLAYER_STATE_ERROR)
1590                 {
1591                         if (__pPlayStateSlider->IsEnabled() != true)
1592                         {
1593                                 __pPlayStateSlider->SetEnabled(true);
1594                         }
1595                         SetFileNotExistState(true);
1596                 }
1597         }*/
1598         delete pContentInfoStruct;
1599
1600         UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_CURRENT);
1601         Invalidate(true);
1602         AppLogDebug("EXIT");
1603 }
1604
1605 void
1606 PlayerForm::UpdateAnimationAlbumArt(AlbumArtImage position)
1607 {
1608         AppLogDebug("ENTER");
1609         Bitmap* pAlbumArtBitmap[ALBUM_ART_IMAGE_COUNT] = {null, };
1610         FloatDimension floatDimension = static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->GetSizeF();
1611
1612         switch (position)
1613         {
1614         case ALBUM_ART_IMAGE_CURRENT:
1615                 {
1616                         pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetCurrentContentIndex());
1617
1618                         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] != null)
1619                         {
1620                                 pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT]->Scale(floatDimension);
1621                         }
1622                         pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetPreviousContentIndex());
1623
1624                         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] != null)
1625                         {
1626                                 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]->Scale(floatDimension);
1627                         }
1628                         pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetNextContentIndex());
1629
1630                         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] != null)
1631                         {
1632                                 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]->Scale(floatDimension);
1633                         }
1634                 }
1635                 break;
1636
1637         case ALBUM_ART_IMAGE_PREVIOUS:
1638                 {
1639                         pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = null;
1640                         pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetPreviousContentIndex());
1641                         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] != null)
1642                         {
1643                                 pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]->Scale(floatDimension);
1644                         }
1645                         pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = null;
1646                 }
1647                 break;
1648
1649         case ALBUM_ART_IMAGE_NEXT:
1650                 {
1651                         pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] = null;
1652                         pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] = null;
1653                         pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetNextContentIndex());
1654                         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] != null)
1655                         {
1656                                 pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]->Scale(floatDimension);
1657                         }
1658                 }
1659                 break;
1660
1661         default:
1662                 break;
1663         }
1664
1665         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT] != null)
1666         {
1667                 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_CURRENT]->GetCanvasN();
1668                 if (pCanvas)
1669                 {
1670                         pCanvas->Clear();
1671                         Point point(INIT_VALUE, INIT_VALUE);
1672                         pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT]);
1673                         delete pCanvas;
1674                 }
1675                 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_CURRENT];
1676         }
1677
1678         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS] != null)
1679         {
1680                 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_PREVIOUS]->GetCanvasN();
1681                 if (pCanvas)
1682                 {
1683                         pCanvas->Clear();
1684                         Point point(INIT_VALUE, INIT_VALUE);
1685                         pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS]);
1686                         delete pCanvas;
1687                 }
1688                 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_PREVIOUS];
1689         }
1690
1691         if (pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT] != null)
1692         {
1693                 Canvas* pCanvas = __pAlbumArtElement[ALBUM_ART_IMAGE_NEXT]->GetCanvasN();
1694                 if (pCanvas)
1695                 {
1696                         pCanvas->Clear();
1697                         Point point(INIT_VALUE, INIT_VALUE);
1698                         pCanvas->DrawBitmap(point, *pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT]);
1699                         delete pCanvas;
1700                 }
1701                 delete pAlbumArtBitmap[ALBUM_ART_IMAGE_NEXT];
1702         }
1703         AppLogDebug("EXIT");
1704         return;
1705 }
1706
1707 void
1708 PlayerForm::SetRepeatButtonImage(int repeatValue)// 0 - 2 (OFF, ONE, ALL)
1709 {
1710         AppLogDebug("ENTER");
1711         Bitmap* pOptionRepeatBitmap;
1712         Bitmap* pOptionRepeatPressBitmap;
1713
1714         switch (repeatValue)
1715         {
1716         case 0:
1717                 {
1718                         pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_A.png");
1719                         pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_A_press.png");
1720                 }
1721                 break;
1722
1723         case 1:
1724                 {
1725                         pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_1.png");
1726                         pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_1_press.png");
1727                 }
1728                 break;
1729
1730         case 2:
1731                 {
1732                         pOptionRepeatBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_all.png");
1733                         pOptionRepeatPressBitmap = ResourceManager::GetBitmapN(L"T02_option_rep_all_press.png");
1734                 }
1735                 break;
1736
1737         default:
1738                 break;
1739         }
1740         __pRepeatButton->SetNormalBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionRepeatBitmap);
1741         __pRepeatButton->SetPressedBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionRepeatPressBitmap);
1742         __pPlayerPresentationModel->SetRepeatMode(repeatValue);
1743
1744         delete pOptionRepeatBitmap;
1745         pOptionRepeatBitmap = null;
1746         delete pOptionRepeatPressBitmap;
1747         pOptionRepeatPressBitmap = null;
1748         AppLogDebug("EXIT");
1749 }
1750
1751 void
1752 PlayerForm::SetShuffleButtonImage(bool shuffleEnable)
1753 {
1754         AppLogDebug("ENTER");
1755         Bitmap* pOptionShuffleBitmap;
1756
1757         if (shuffleEnable == false)
1758         {
1759                 pOptionShuffleBitmap = ResourceManager::GetBitmapN(L"T02_option_shuffle_on_dim.png");
1760         }
1761         else
1762         {
1763                 pOptionShuffleBitmap = ResourceManager::GetBitmapN(L"T02_option_shuffle_on.png");
1764         }
1765
1766         __pShuffleButton->SetNormalBitmap(Point(INIT_VALUE, INIT_VALUE), *pOptionShuffleBitmap);
1767         __pPlayerPresentationModel->SetShuffleEnable(shuffleEnable);
1768         UpdateAnimationAlbumArt(ALBUM_ART_IMAGE_CURRENT);
1769
1770         delete pOptionShuffleBitmap;
1771         pOptionShuffleBitmap = null;
1772         AppLogDebug("EXIT");
1773 }
1774
1775 void
1776 PlayerForm::SetFileNotExistState(bool isFileExist)
1777 {
1778         AppLogDebug("ENTER");
1779         RemoveContextMenu();
1780
1781         if(GetPlayerScreenState() != PLAYER_SCREEN_STATE_DURING_CALL &&
1782                         GetPlayerScreenState() != PLAYER_SCREEN_STATE_ERROR_CONTENT)
1783         {
1784                 __pMoreContextButton->SetEnabled(isFileExist);
1785                 __pMoreContextButton->Invalidate(true);
1786                 __pContentsViewToggleButton->SetEnabled(isFileExist);
1787                 __pContentsViewToggleButton->Invalidate(true);
1788                 __pShuffleButton->SetEnabled(isFileExist);
1789                 __pShuffleButton->Invalidate(true);
1790         }
1791
1792         AppLogDebug("EXIT");
1793 }
1794
1795 void
1796 PlayerForm::TogglePlayPauseImage(PlayerState playerState)
1797 {
1798         AppLogDebug("ENTER");
1799         if (playerState == PLAYER_STATE_PLAYING)
1800         {
1801                 RelativeLayout* layout = dynamic_cast<RelativeLayout*>(__pContentsAlbumViewPanel->GetLayoutN());
1802                 if (layout != null)
1803                 {
1804                         layout->ResetCenterAligned(*static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_THUMBANIL_BACKGROUND)), CENTER_ALIGN_HORIZONTAL);
1805                         delete layout;
1806                 }
1807
1808                 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_TURN_TABLE))->SetShowState(true);
1809                 SetPauseButtonImage();
1810         }
1811         else
1812         {
1813                 RelativeLayout* layout = dynamic_cast<RelativeLayout*>(__pContentsAlbumViewPanel->GetLayoutN());
1814                 if (layout != null)
1815                 {
1816                         layout->SetCenterAligned(*static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_THUMBANIL_BACKGROUND)), CENTER_ALIGN_HORIZONTAL);
1817                         delete layout;
1818                 }
1819
1820                 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_ALBUM_TURN_TABLE))->SetShowState(false);
1821                 SetPlayButtonImage();
1822         }
1823
1824         if (__pContentsAlbumViewPanel->GetShowState() == true)
1825         {
1826                 __pContentsAlbumViewPanel->Invalidate(true);
1827         }
1828         AppLogDebug("EXIT");
1829 }
1830 void
1831 PlayerForm::SetPlayButtonImage(void)
1832 {
1833         AppLogDebug("ENTER");
1834         Point point(INIT_VALUE, INIT_VALUE);
1835         Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_NORMAL);
1836         __pPlayPauseButton->SetNormalBitmap(point, *pBitmap);
1837         delete pBitmap;
1838
1839         pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_PRESSED);
1840         __pPlayPauseButton->SetPressedBitmap(point, *pBitmap);
1841         delete pBitmap;
1842
1843         pBitmap = ResourceManager::GetBitmapN(IDB_PLAY_BUTTON_ICON_DISABLED);
1844         __pPlayPauseButton->SetDisabledBitmap(point, *pBitmap);
1845         delete pBitmap;
1846
1847         __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PLAY);
1848         __pPlayPauseButton->Invalidate(true);
1849         AppLogDebug("EXIT");
1850 }
1851
1852 void
1853 PlayerForm::SetPauseButtonImage(void)
1854 {
1855         AppLogDebug("ENTER");
1856         Point point(INIT_VALUE, INIT_VALUE);
1857         Bitmap* pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_NORMAL);
1858         __pPlayPauseButton->SetNormalBitmap(point, *pBitmap);
1859         delete pBitmap;
1860
1861         pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_PRESSED);
1862         __pPlayPauseButton->SetPressedBitmap(point, *pBitmap);
1863         delete pBitmap;
1864
1865         pBitmap = ResourceManager::GetBitmapN(IDB_PAUSE_BUTTON_ICON_DISABLED);
1866         __pPlayPauseButton->SetDisabledBitmap(point, *pBitmap);
1867         delete pBitmap;
1868
1869         __pPlayPauseButton->SetActionId(IDA_PLAYER_CONTROLLER_PAUSE);
1870         __pPlayPauseButton->Invalidate(true);
1871         AppLogDebug("EXIT");
1872 }
1873
1874 result
1875 PlayerForm::InitializeVolumeBar(void)
1876 {
1877         AppLogDebug("ENTER");
1878         int MediaSoundVolume = 0;
1879         SettingInfo::GetValue(MEDIA_VOLUME, MediaSoundVolume);
1880         __pPlayerPresentationModel->SetVolume(MediaSoundVolume);
1881
1882         __pVolumePanel = new (std::nothrow) Panel();
1883         __pVolumeSlider = new (std::nothrow) Slider();
1884         OrientationStatus orientationStatue = GetOrientationStatus();
1885         Rectangle clientBounds = GetClientAreaBounds();
1886         Rectangle bounds = GetBounds();
1887         RelativeLayout layout;
1888         layout.Construct();
1889
1890         if (orientationStatue == ORIENTATION_STATUS_LANDSCAPE
1891                 || orientationStatue == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1892         {
1893                 AppLogDebug("CHECK %d", clientBounds.width);
1894                 if (clientBounds.width > 1200)
1895                 {
1896                         __pVolumePanel->Construct(layout, Rectangle(clientBounds.width - W_HORIZONTAL_PLAYER
1897                                                                         , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1898                                                                         , W_HORIZONTAL_PLAYER
1899                                                                         , H_VOLUME_PANEL));
1900                 }
1901                 else
1902                 {
1903                         __pVolumePanel->Construct(layout, Rectangle(clientBounds.width - 670
1904                                                                         , GetClientAreaBounds().height - H_HORIZONTAL_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1905                                                                         , 680
1906                                                                         , H_VOLUME_PANEL));
1907                 }
1908         }
1909         else if (orientationStatue == ORIENTATION_STATUS_PORTRAIT
1910                         || orientationStatue == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1911         {
1912                 __pVolumePanel->Construct(layout, Rectangle(0
1913                                                                 , clientBounds.height - H_CONTROLLER_PANEL - H_VOLUME_PANEL - 50
1914                                                                 , clientBounds.width
1915                                                                 , H_VOLUME_PANEL));
1916         }
1917
1918         if (clientBounds.width > 1200)
1919         {
1920                 __pVolumeSlider->Construct(Rectangle(0
1921                                                                 , 0, W_HORIZONTAL_PLAYER, H_VOLUME_PANEL)
1922                                                                 , BACKGROUND_STYLE_NONE
1923                                                                 , false
1924                                                                 , MIN_VOLUME_SLIDER_COUNT
1925                                                                 , MAX_VOLUME_SLIDER_COUNT
1926                                                                 , GROUP_STYLE_NONE);
1927         }
1928         else
1929         {
1930                 __pVolumeSlider->Construct(Rectangle(0
1931                                                                 , 0, 680, H_VOLUME_PANEL)
1932                                                                 , BACKGROUND_STYLE_NONE
1933                                                                 , false
1934                                                                 , MIN_VOLUME_SLIDER_COUNT
1935                                                                 , MAX_VOLUME_SLIDER_COUNT
1936                                                                 , GROUP_STYLE_NONE);
1937         }
1938
1939         __pVolumeSlider->SetColor(TRANSPARENT_COLOR);
1940         AddControl(__pVolumePanel);
1941         __pVolumePanel->AddControl(__pVolumeSlider);
1942         CommonUtil::SetLayoutFitToContainer(*__pVolumePanel, *__pVolumeSlider);
1943
1944         Bitmap* pVolumeLeftIconBitmap = ResourceManager::GetBitmapN(L"T02_volume_icon_01.png");
1945         Bitmap* pVolumeRightIconBitmap = ResourceManager::GetBitmapN(L"T02_volume_icon_02.png");
1946
1947         __pVolumeSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *ResourceManager::GetBitmapN(L"T02_player_progress_handle.png"));
1948         __pVolumeSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *ResourceManager::GetBitmapN(L"T02_player_progress_handle_press.png"));
1949         __pVolumeSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL, Color(255, 255, 255, 0));
1950         __pVolumeSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED, Color(255, 255, 255, 0));
1951
1952         __pVolumeSlider->SetIcon(ICON_POSITION_LEFT, *pVolumeLeftIconBitmap);
1953         __pVolumeSlider->SetIcon(ICON_POSITION_RIGHT, *pVolumeRightIconBitmap);
1954         __pVolumeSlider->SetValue(__pPlayerPresentationModel->GetVolume());
1955         __pVolumeSlider->AddSliderEventListener(*this);
1956
1957         delete pVolumeLeftIconBitmap;
1958         pVolumeLeftIconBitmap = null;
1959         delete pVolumeRightIconBitmap;
1960         pVolumeRightIconBitmap = null;
1961
1962         return E_SUCCESS;
1963 }
1964
1965 result
1966 PlayerForm::CreateTableViewItem(Tizen::Ui::Container& parent,
1967                                                 const ContentInformation& contentInfoStruct)
1968 {
1969         AppLogDebug("ENTER");
1970         Panel* pTableViewItem = new (std::nothrow) Panel();
1971         if (IsFailed(pTableViewItem->Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL)))
1972         {
1973                 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
1974                 return E_FAILURE;
1975         }
1976
1977         static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_TITLE_NAME))->SetText(contentInfoStruct.TitleName);
1978         static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_ARTIST_NAME))->SetText(contentInfoStruct.ArtistName);
1979
1980         if(contentInfoStruct.contentId.ToString().Equals(INVALID_VALUE_OF_CONTENT_ID,true) && __playerScreenState == PLAYER_SCREEN_STATE_APP_CONTROL)
1981         {
1982                 Bitmap* pBmp = __pPlayerPresentationModel->GetContentAlbumArtN(__pPlayerPresentationModel->GetCurrentContentIndex());
1983                 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pBmp);
1984                 delete pBmp;
1985                 pBmp = null;
1986         }
1987         else
1988         {
1989                 static_cast<Label*>(pTableViewItem->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*GetDefaultThumbnail());
1990         }
1991
1992
1993         parent.AddControl(pTableViewItem);
1994         CommonUtil::SetLayoutFitToContainer(parent, *pTableViewItem);
1995
1996         AppLogDebug("EXIT");
1997         return E_SUCCESS;
1998 }
1999
2000 void
2001 PlayerForm::UpdateSplitBarState(void)
2002 {
2003         AppLogDebug("ENTER");
2004         Label* pSplitBar = static_cast<Label*>(GetControl(IDC_SPLIT_BAR));
2005         if ((GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT) || (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE))
2006         {
2007                 pSplitBar->SetSize(GetClientAreaBounds().width, 0);
2008         }
2009         else
2010         {
2011                 pSplitBar->SetSize(13,  GetClientAreaBounds().height);
2012         }
2013         AppLogDebug("EXIT");
2014 }
2015
2016 void
2017 PlayerForm::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
2018 {
2019         AppLogDebug("ENTER");
2020         __pThumbnail = pThumbnailInfo->GetBitmapN();
2021         Object* pParam = pThumbnailInfo->GetUserParamN();
2022         if (pParam != null)
2023         {
2024                 static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW))->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
2025                 delete pParam;
2026         }
2027
2028         delete pThumbnailInfo;
2029         AppLogDebug("EXIT");
2030 }
2031
2032 void
2033 PlayerForm::OnMusicContentUpdateCompleted(void)
2034 {
2035         AppLogDebug("ENTER");
2036         RemoveContextMenu();
2037         RemoveSharePicker();
2038         RemovePlayListPicker();
2039
2040         UiApp* pApp = UiApp::GetInstance();
2041         AppAssert(pApp);
2042
2043         if (pApp->GetAppUiState() == APP_UI_STATE_FOREGROUND)
2044         {
2045                 RemoveSetAsPicker();
2046         }
2047
2048         bool isCurrentContentModified = false;
2049         if (__pPlayerPresentationModel->IsFileExist(__pPlayerPresentationModel->GetCurrentContentIndex()) != true)
2050         {
2051                 isCurrentContentModified = true;
2052                 SetFileNotExistState(false);
2053         }
2054
2055         AllListPresentationModel* pPresentationModel = AllListPresentationModel::GetInstance();
2056         if (pPresentationModel == null)
2057         {
2058                 AppLogDebug("EXIT");
2059                 return;
2060         }
2061
2062         pPresentationModel->UpdateContentList();
2063         IList* pList = pPresentationModel->GetContentListN();
2064         if (pList == null || pList->GetCount() == INIT_VALUE)
2065         {
2066                 AppLogDebug("EXIT");
2067                 delete pList;
2068                 return;
2069         }
2070
2071         String* pPlayContentPath = __pPlayerPresentationModel->GetPlayContentPath();
2072         int iContentListCount = __pPlayerPresentationModel->GetContentListCount();
2073         for (int iCount =  iContentListCount - 1; iCount >= 0; iCount--)
2074         {
2075                 bool isFind = false;
2076                 String* pContentPath = __pPlayerPresentationModel->GetContentPath(iCount);
2077                 if (pContentPath == null)
2078                 {
2079                         continue;
2080                 }
2081                 IEnumerator* pIEnum = pList->GetEnumeratorN();
2082                 while (pIEnum->MoveNext() == E_SUCCESS)
2083                 {
2084                         String* pCurrentPath = static_cast<String*>(pIEnum->GetCurrent());
2085                         if (pCurrentPath == null)
2086                         {
2087                                 continue;
2088                         }
2089
2090                         if (pContentPath->Equals(*pCurrentPath, false))
2091                         {
2092                                 isFind = true;
2093                                 break;
2094                         }
2095
2096                         if (pPlayContentPath != null && pContentPath->Equals(*pPlayContentPath, false))
2097                         {
2098                                 isFind = true;
2099                                 break;
2100                         }
2101                 }
2102                 delete pIEnum;
2103
2104                 if (isFind == false)
2105                 {
2106                         __pPlayerPresentationModel->RemoveContent(*pContentPath);
2107                 }
2108         }
2109
2110         if (__pContentsListViewPanel->IsEnabled() == true)
2111         {
2112                 if (__pPlayerPresentationModel->GetContentListCount() != INIT_VALUE && isCurrentContentModified == false)
2113                 {
2114                         static_cast<TableView*>(__pContentsListViewPanel->GetControl(IDC_CONTENTS_TABLEVIEW))->UpdateTableView();
2115                 }
2116                 else if (__pContentsListViewPanel->GetShowState() == true)
2117                 {
2118                         __pContentsListViewPanel->SetShowState(false);
2119                         __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
2120                         __pContentsAlbumViewPanel->SetShowState(true);
2121                         __pPanelRegisterBar->Invalidate(true);
2122                 }
2123         }
2124         AppLogDebug("EXIT");
2125 }
2126
2127 void
2128 PlayerForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
2129 {
2130         AppLogDebug("ENTER");
2131         Panel* pItemPanel = static_cast<Panel*>(pItem->GetControl(IDL_CONTENTS_LIBARY_ITEM_PANEL));
2132         if (pItemPanel == null)
2133         {
2134                 AppLogDebug("pItemPanel is null");
2135                 delete __pThumbnail;
2136                 __pThumbnail = null;
2137                 return;
2138         }
2139         Label* pThumbnailLabel = static_cast<Label*>(pItemPanel->GetControl(IDC_CONTENTS_THUMBNAIL));
2140         if (__pThumbnail == null || pThumbnailLabel == null)
2141         {
2142                 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
2143                 delete __pThumbnail;
2144                 __pThumbnail = null;
2145                 return;
2146         }
2147         pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
2148         delete __pThumbnail;
2149         __pThumbnail = null;
2150         pThumbnailLabel->Invalidate(true);
2151         AppLogDebug("EXIT");
2152 }
2153
2154 void
2155 PlayerForm::SetPlayerScreenState(unsigned int playerScreenState)
2156 {
2157         AppLogDebug("ENTER %d",playerScreenState);
2158
2159         if (__playerScreenState == playerScreenState||
2160           (playerScreenState != PLAYER_SCREEN_STATE_NORMAL &&
2161         (__playerScreenState == PLAYER_SCREEN_STATE_DURING_CALL && !__isAppControlDuringCall)))
2162         {
2163                 AppLogDebug("EXIT");
2164                 return;
2165         }
2166
2167         switch (playerScreenState)
2168         {
2169         case PLAYER_SCREEN_STATE_NORMAL:
2170                 {
2171                         __pVolumeButton->SetEnabled(true);
2172                         __pContentsViewToggleButton->SetEnabled(true);
2173                         __pShuffleButton->SetShowState(true);
2174                         __pRepeatButton->SetShowState(true);
2175                         __pShuffleButton->SetEnabled(true);
2176                         __pRepeatButton->SetEnabled(true);
2177                         __pRewindButton->SetEnabled(true);
2178                         __pPlayPauseButton->SetEnabled(true);
2179                         __pForwardButton->SetEnabled(true);
2180                         __pPlayStateSlider->SetEnabled(true);
2181                         __pMoreContextButton->SetEnabled(true);
2182
2183                         if (__playerScreenState == PLAYER_SCREEN_STATE_INVALID_CONTENT_ID)
2184                         {
2185                         //      __pContentsViewToggleButton->SetEnabled(false);
2186                                 __pShuffleButton->SetEnabled(false);
2187 //                              __pMoreContextButton->SetEnabled(false);
2188                         }
2189
2190                         if (__isRunByAppControl == false)
2191                         {
2192                                 break;
2193                         }
2194                 }
2195                 // fall through
2196         case PLAYER_SCREEN_STATE_APP_CONTROL:
2197                 {
2198                         if(__isAppControlDuringCall)
2199                         {
2200                                 __pPlayPauseButton->SetEnabled(true);
2201                                 __pMoreContextButton->SetEnabled(true);
2202                                 __pContentsViewToggleButton->SetEnabled(true);
2203                                 __pPlayStateSlider->SetEnabled(true);
2204                         }
2205
2206                         RemoveContextMenu();
2207                         __pShuffleButton->SetShowState(false);
2208                         __pRepeatButton->SetShowState(false);
2209                         __prevRepeatStateRunByAppControl = __pPlayerPresentationModel->GetRepeatState();
2210 //                      SetRepeatButtonImage(IDA_TYPE_REPEAT_A);
2211
2212                         if (__pContentsListViewPanel->GetShowState() == true)
2213                         {
2214                                 __pContentsListViewPanel->SetShowState(false);
2215                                 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
2216                                 __pContentsAlbumViewPanel->SetShowState(true);
2217                         }
2218                         playerScreenState = PLAYER_SCREEN_STATE_APP_CONTROL;
2219                         __isRunByAppControl = true;
2220                 }
2221                 break;
2222
2223         case PLAYER_SCREEN_STATE_INVALID_CONTENT_ID:
2224                 {
2225                 //      __pContentsViewToggleButton->SetEnabled(false);
2226                 //      __pContentsViewToggleButton->Invalidate(true);
2227                         if (__playerScreenState != PLAYER_SCREEN_STATE_APP_CONTROL)
2228                         {
2229                                 __pRepeatButton->SetShowState(true);
2230                                 __pRepeatButton->SetEnabled(false);
2231                         }
2232                         else
2233                         {
2234                                 return;
2235                         }
2236 //                      __pMoreContextButton->SetEnabled(false);
2237                 }
2238                 break;
2239
2240         case PLAYER_SCREEN_STATE_NO_CONTENT_LIST:
2241                 {
2242                         __pVolumeButton->SetEnabled(false);
2243                         __pContentsViewToggleButton->SetEnabled(false);
2244                         __pShuffleButton->SetShowState(true);
2245                         __pRepeatButton->SetShowState(true);
2246                         __pShuffleButton->SetEnabled(false);
2247                         __pRepeatButton->SetEnabled(false);
2248                         __pRewindButton->SetEnabled(false);
2249                         __pPlayPauseButton->SetEnabled(false);
2250                         __pForwardButton->SetEnabled(false);
2251                         __pPlayStateSlider->SetEnabled(false);
2252                         RemoveContextMenu();
2253                         __pMoreContextButton->SetEnabled(false);
2254
2255                         Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2256                         static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2257                         delete pThumb;
2258                 }
2259                 break;
2260
2261         case PLAYER_SCREEN_STATE_ERROR_CONTENT:
2262                 {
2263                         if (__pPlayerPresentationModel->IsDuringCall())
2264                         {
2265                                 if (__isRunByAppControl)
2266                                 {
2267                                         SetPlayerScreenState(PLAYER_SCREEN_STATE_APP_CONTROL);
2268                                 }
2269                                 else
2270                                 {
2271                                         SetPlayerScreenState(PLAYER_SCREEN_STATE_DURING_CALL);
2272                                 }
2273                                 return;
2274                         }
2275                         else
2276                         {
2277                                 __pPlayStateSlider->SetShowState(true);
2278                                 __pPlayStateSlider->SetValue(0);
2279                                 __pPlayPauseButton->SetEnabled(false);
2280                                 __pPlayStateSlider->SetEnabled(false);
2281                                 __pShuffleButton->SetEnabled(false);
2282                                 RemoveContextMenu();
2283                                 __pMoreContextButton->SetEnabled(false);
2284                                 __pPlayStateSlider->Invalidate(true);
2285
2286                                 Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2287                                 static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2288                                 delete pThumb;
2289                         }
2290                 }
2291                 break;
2292
2293         case PLAYER_SCREEN_STATE_DURING_CALL:
2294                 {
2295                         if(__playerScreenState == PLAYER_SCREEN_STATE_APP_CONTROL)
2296                         {
2297                                 __isAppControlDuringCall = true;
2298                         }
2299
2300                         __pPlayPauseButton->SetEnabled(false);
2301                         RemoveContextMenu();
2302                         __pMoreContextButton->SetEnabled(false);
2303                         __pContentsViewToggleButton->SetEnabled(false);
2304                         __pPlayStateSlider->SetEnabled(false);
2305
2306                         if (__pContentsListViewPanel->GetShowState() == true)
2307                         {
2308                                 __pContentsListViewPanel->SetShowState(false);
2309                                 __pContentsViewToggleButton->SetActionId(IDA_BUTTON_CONTENTS_LIST_VIEW);
2310                                 __pContentsAlbumViewPanel->SetShowState(true);
2311                         }
2312
2313                         Bitmap* pThumb = ResourceManager::GetBitmapN(L"music_play_grid_thumb_loading.png");
2314                         static_cast<Label*>(__pContentsAlbumViewPanel->GetControl(IDC_CONTENTS_THUMBNAIL))->SetBackgroundBitmap(*pThumb);
2315                         delete pThumb;
2316                 }
2317                 break;
2318
2319         default:
2320                 break;
2321         }
2322
2323         __playerScreenState = playerScreenState;
2324         Invalidate(true);
2325         AppLogDebug("EXIT");
2326 }
2327
2328 unsigned int
2329 PlayerForm::GetPlayerScreenState(void)
2330 {
2331         AppLogDebug("ENTER");
2332         AppLogDebug("EXIT");
2333         return __playerScreenState;
2334 }
2335
2336 result
2337 PlayerForm::SetContextMenuItem(unsigned int contextMenuItemStyle, Tizen::Graphics::Point anchorPosition)
2338 {
2339         AppLogDebug("ENTER");
2340         if (__pContextMenu == null)
2341         {
2342                 AppLogDebug("EXIT");
2343                 return E_FAILURE;
2344         }
2345
2346         CommonUtil::AddContextMenuItem(*__pContextMenu, contextMenuItemStyle);
2347         CommonUtil::ShowContextMenu(*__pContextMenu, true);
2348
2349         if (anchorPosition.x != -1 && anchorPosition.y != -1)
2350         {
2351                 __pContextMenu->SetAnchorPosition(anchorPosition);
2352         }
2353         AppLogDebug("EXIT");
2354         return E_SUCCESS;
2355 }
2356
2357 result
2358 PlayerForm::CreateContextMenuN(const Tizen::Ui::Control& source)
2359 {
2360         AppLogDebug("ENTER");
2361         RemoveContextMenu();
2362         __pContextMenu = CommonUtil::CreateContextMenuN(source, *this);
2363         if (__pContextMenu != null)
2364         {
2365                 return E_SUCCESS;
2366         }
2367         AppLogDebug("EXIT");
2368         return E_FAILURE;
2369 }
2370
2371 void
2372 PlayerForm::RemoveContextMenu(void)
2373 {
2374         AppLogDebug("ENTER");
2375         if (__pContextMenu != null)
2376         {
2377                 CommonUtil::SetShowStateControl(*__pContextMenu, false);
2378                 delete __pContextMenu;
2379                 __pContextMenu = null;
2380         }
2381         AppLogDebug("EXIT");
2382 }
2383
2384 result
2385 PlayerForm::TryRemoveContextMenu(int actionId)
2386 {
2387         AppLogDebug("ENTER");
2388         result r = E_FAILURE;
2389         if (CommonUtil::IsVaildContextMenuItemActionId(actionId) == true)
2390         {
2391                 RemoveContextMenu();
2392                 r = E_SUCCESS;
2393         }
2394         AppLogDebug("EXIT");
2395         return r;
2396 }
2397
2398 result
2399 PlayerForm::ShowSharePicker(Tizen::Base::Collection::IList* pIList)
2400 {
2401         AppLogDebug("ENTER");
2402         RemoveSharePicker();
2403
2404         __pSharePicker = new (std::nothrow) SharePopup();
2405         if (IsFailed(__pSharePicker->Initialize(this)))
2406         {
2407                 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2408                 RemoveSharePicker();
2409                 return E_FAILURE;
2410         }
2411
2412         __pSharePicker->SetArguments(pIList);
2413         __pSharePicker->SetShowState(true);
2414         __pSharePicker->Show();
2415
2416         AppLogDebug("EXIT");
2417         return E_SUCCESS;
2418 }
2419
2420 void
2421 PlayerForm::RemoveSharePicker(void)
2422 {
2423         AppLogDebug("ENTER");
2424         if (__pSharePicker != null)
2425         {
2426                 CommonUtil::SetShowStateControl(*__pSharePicker, false);
2427                 delete __pSharePicker;
2428                 __pSharePicker = null;
2429         }
2430         AppLogDebug("EXIT");
2431 }
2432
2433 result
2434 PlayerForm::ShowPlayListPicker(Tizen::Base::Collection::IList* pIList)
2435 {
2436         AppLogDebug("ENTER");
2437         RemovePlayListPicker();
2438
2439         __pPlayListPicker = new (std::nothrow) PlayListPickerPopup();
2440         if (IsFailed(__pPlayListPicker->Initialize(this, pIList)))
2441         {
2442                 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2443                 RemovePlayListPicker();
2444                 return E_FAILURE;
2445         }
2446
2447         __pPlayListPicker->SetShowState(true);
2448         __pPlayListPicker->Show();
2449
2450         AppLogDebug("EXIT");
2451         return E_SUCCESS;
2452 }
2453
2454 void
2455 PlayerForm::RemovePlayListPicker(void)
2456 {
2457         AppLogDebug("ENTER");
2458         if (__pPlayListPicker != null)
2459         {
2460                 CommonUtil::SetShowStateControl(*__pPlayListPicker, false);
2461                 delete __pPlayListPicker;
2462                 __pPlayListPicker = null;
2463         }
2464         AppLogDebug("EXIT");
2465 }
2466
2467 result
2468 PlayerForm::ShowSetAsPicker(Tizen::Base::Collection::IList* pIList)
2469 {
2470         AppLogDebug("ENTER");
2471         RemoveSetAsPicker();
2472
2473         __pSetAsPicker = new (std::nothrow) SetAsPopup();
2474         if (IsFailed(__pSetAsPicker->Initialize(this)))
2475         {
2476                 AppLogDebug("__pSharePicker->Initialize failed(%s)", GetErrorMessage(E_FAILURE));
2477                 RemoveSetAsPicker();
2478                 return E_FAILURE;
2479         }
2480
2481         __pSetAsPicker->SetCurrentContentPath(new (std::nothrow) String(*static_cast<String*>(pIList->GetAt(0))));
2482         __pSetAsPicker->SetShowState(true);
2483         __pSetAsPicker->Show();
2484
2485         pIList->RemoveAll(true);
2486         delete pIList;
2487
2488         AppLogDebug("EXIT");
2489         return E_SUCCESS;
2490 }
2491
2492 void
2493 PlayerForm::RemoveSetAsPicker(void)
2494 {
2495         AppLogDebug("ENTER");
2496         if (__pSetAsPicker != null)
2497         {
2498                 CommonUtil::SetShowStateControl(*__pSetAsPicker, false);
2499 //              delete __pSetAsPicker;
2500 //              __pSetAsPicker = null;
2501         }
2502         AppLogDebug("EXIT");
2503 }
2504
2505 result
2506 PlayerForm::LanucherPicker(PickerType pickerType)
2507 {
2508         AppLogDebug("ENTER");
2509         IList* pArgumentList = GetPickerArgumentListN(pickerType);
2510         if (pArgumentList == null)
2511         {
2512                 AppLogDebug("GetPickerArgumentListN is null");
2513                 return E_FAILURE;
2514         }
2515
2516         result r = E_FAILURE;
2517         if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER)
2518         {
2519                 r = ShowPlayListPicker(pArgumentList);
2520         }
2521         else if (pickerType == PICKER_TYPE_SHARE_PICKER)
2522         {
2523                 r = ShowSharePicker(pArgumentList);
2524         }
2525         else if (pickerType == PICKER_TYPE_SET_AS_PICKER)
2526         {
2527                 r = ShowSetAsPicker(pArgumentList);
2528         }
2529
2530         if (IsFailed(r))
2531         {
2532                 AppLogDebug("ShowPlayListPicker failed(%s)", GetErrorMessage(r));
2533                 delete pArgumentList;
2534         }
2535         AppLogDebug("EXIT");
2536         return r;
2537 }
2538
2539 Tizen::Base::Collection::IList*
2540 PlayerForm::GetPickerArgumentListN(PickerType pickerType)
2541 {
2542         AppLogDebug("ENTER");
2543         String contentPath;
2544         switch (pickerType)
2545         {
2546         case PICKER_TYPE_SET_AS_PICKER:
2547                 // fall through
2548         case PICKER_TYPE_PLAY_LIST_PICKER:
2549                 // fall through
2550         case PICKER_TYPE_SHARE_PICKER:
2551                 {
2552                         contentPath.Append(*__pPlayerPresentationModel->GetContentPath(__pPlayerPresentationModel->GetCurrentContentIndex()));
2553                 }
2554                 break;
2555
2556         default:
2557                 {
2558                         AppLogDebug("EXIT");
2559                         return null;
2560                 }
2561                 break;
2562         }
2563
2564         Tizen::Base::Collection::ArrayList* pDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
2565         if (IsFailed(pDataList->Construct()))
2566         {
2567                 AppLogDebug("Construct failed(%s)", GetErrorMessage(GetLastResult()));
2568                 delete pDataList;
2569                 return null;
2570         }
2571
2572         pDataList->Add(*(new (std::nothrow) String(contentPath)));
2573         AppLogDebug("EXIT");
2574         return pDataList;
2575 }