19a82bd4e491d3b2b481555d6b3a010f2fbe834d
[apps/osp/VideoPlayer.git] / src / VpVideoPlayerForm.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                VpVideoPlayerForm.cpp
19  * @brief               This is the implementation file for VideoPlayerForm class.
20  */
21
22 #include <FSystem.h>
23 #include <FTelephony.h>
24 #include "VpAppResourceId.h"
25 #include "VpSoundPathPopup.h"
26 #include "VpTypes.h"
27 #include "VpVideoPlayerApp.h"
28 #include "VpVideoPlayerForm.h"
29 #include "VpVideoPlayerPresentationModel.h"
30
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Base::Runtime;
35 using namespace Tizen::Base::Utility;
36 using namespace Tizen::Content;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Media;
39 using namespace Tizen::System;
40 using namespace Tizen::Telephony;
41 using namespace Tizen::Ui;
42 using namespace Tizen::Ui::Controls;
43 using namespace Tizen::Ui::Scenes;
44
45 static const int MIN_PROGRESS_RANGE = 0;
46 static const int MAX_PROGRESS_RANGE = 100;
47
48 static const int SHOW_CONTROL_DURATION = 5000;
49
50 static const int MILLISECOND = 1000;
51 static const int SLIDER_START_VALUE = 0;
52 static const int SEEK_TIME_NONE = -1;
53
54 static const int X_BASE = 0;
55 static const int Y_BASE = 0;
56 static const int DIVIDE_BY_TWO = 2;
57
58 static const int X_NORMAL = 0;
59 static const int Y_NORMAL = 310;
60 static const int W_NORMAL = 720;
61 static const int H_NORMAL = 432;
62
63 static const int COLOR_THUMB_RED = 0;
64 static const int COLOR_THUMB_GREEN = 0;
65 static const int COLOR_THUMB_BLUE = 0;
66 static const int COLOR_THUMB_ALPHA = 0;
67
68 static const int MULTI_CONTENT_COUNT = 2;
69
70 static const int MESSAGEBOX_DISPLAY_TIMEOUT = 3000;
71
72 static const wchar_t* SLIDER_INIT_TIME = L"00:00:00";
73
74 static const RequestId REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU = 111;
75 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU = 112;
76 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU = 113;
77 static const RequestId REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED = 114;
78
79 void DestroyPresentationModelInstance(void)
80 {
81         VideoPlayerPresentationModel::DestroyInstance();
82 }
83
84 VideoPlayerForm::VideoPlayerForm(void)
85         : __pOverlayPanel(null)
86         , __screenMode(SCREEN_MODE_NORMAL)
87         , __pSoundPathPopup(null)
88         , __pUiControlTimer(null)
89         , __pAudioRouteManager(null)
90         , __pHeader(null)
91         , __pFunctionPanel(null)
92         , __pControllerPanel(null)
93         , __pPlayPauseButton(null)
94         , __pFastForwardButton(null)
95         , __pFastRewindButton(null)
96         , __pShareButton(null)
97         , __pScreenModeButton(null)
98         , __pRepeatModeButton(null)
99         , __pCurrenTimeLabel(null)
100         , __pTotalTimeLabel(null)
101         , __pSlider(null)
102         , __pShareContextMenu(null)
103         , __actionTouchLongPressed(false)
104         , __setPauseState(false)
105         , __isControlVisibleState(true)
106         , __sliderMoved(false)
107         , __playingBeforeSlide(false)
108         , __frameActivated(false)
109         , __audioRouteMode(0)
110         , __timeToSeek(SEEK_TIME_NONE)
111         , __pVideoPlayerPresentationModel(null)
112 {
113         for (int count = 0; count < OUTPUT_AUDIO_ROUTE_MAX; ++count)
114         {
115                 __availableAudioRoute[count] = false;
116         }
117 }
118
119 VideoPlayerForm::~VideoPlayerForm(void)
120 {
121 }
122
123 void
124 VideoPlayerForm::Initialize(void)
125 {
126         AppLogDebug("Initialize");
127
128         Construct(L"IDL_MAIN_FORM");
129         AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
130         pAccessibilityElement->Construct(GetBounds(), L"IDL_MAIN_FORM");
131
132         AccessibilityContainer* pContainer = GetAccessibilityContainer();
133         if (pContainer != null)
134         {
135                 pContainer->AddElement(*pAccessibilityElement);
136         }
137 }
138
139 result
140 VideoPlayerForm::SetScreenMode(const ScreenMode mode, bool destroyOverlay)
141 {
142         result r = E_SUCCESS;
143
144         Rectangle clientRect = GetClientAreaBounds();
145
146         AccessibilityContainer* pContainer = null;
147
148         RecordingRotation recRotation = RECORDING_ROTATION_NONE;
149         VideoFrameExtractor extractor;
150         r = extractor.Construct(__pVideoPlayerPresentationModel->GetMediaPathName(), MEDIA_PIXEL_FORMAT_RGB565LE);
151         if (r == E_SUCCESS)
152         {
153                 recRotation = extractor.GetRecordingRotation();
154         }
155
156         switch (mode)
157         {
158         case SCREEN_MODE_NORMAL:
159                 {
160                         Rectangle rect = Rectangle(X_NORMAL, Y_NORMAL, W_NORMAL, H_NORMAL);
161
162                         if (recRotation == RECORDING_ROTATION_90 || recRotation == RECORDING_ROTATION_270)
163                         {
164                                 rect.width = H_NORMAL;
165                                 rect.height = W_NORMAL;
166                         }
167
168                         if ((clientRect.width - rect.width) <= X_BASE)
169                         {
170                                 rect.x = X_BASE;
171                         }
172                         else
173                         {
174                                 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
175                         }
176
177                         if ((clientRect.height - rect.height) <= Y_BASE)
178                         {
179                                 rect.y = Y_BASE;
180                         }
181                         else
182                         {
183                                 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
184                         }
185
186                         AppLogDebug("SCREEN_MODE_NORMAL : [%d][%d][%d][%d][rotation:%d]", rect.x, rect.y, rect.width, rect.height, recRotation);
187
188                         if (destroyOverlay == true)
189                         {
190                                 if (__pOverlayPanel != null)
191                                 {
192                                         __pOverlayPanel->RemoveTouchEventListener(*this);
193                                         RemoveControl(__pOverlayPanel);
194                                         __pOverlayPanel = null;
195                                 }
196
197                                 __pOverlayPanel = new (std::nothrow) OverlayPanel();
198                                 r = __pOverlayPanel->Construct(rect);
199                                 TryCatch(r == E_SUCCESS,, "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
200                                 __pOverlayPanel->SetFocusable(false);
201
202                                 r = AddControl(__pOverlayPanel);
203                                 TryCatch(r == E_SUCCESS,, "AddControl(__pOverlayPanel) failed:%s", GetErrorMessage(r));
204
205                                 __pOverlayPanel->AddTouchEventListener(*this);
206
207                                 AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
208                                 r = pAccessibilityElement->Construct(GetBounds(), L"Overlay Panel");
209
210                                 pContainer = __pOverlayPanel->GetAccessibilityContainer();
211                                 if (pContainer != null)
212                                 {
213                                         pContainer->AddElement(*pAccessibilityElement);
214                                 }
215                         }
216                         else
217                         {
218                                 __pOverlayPanel->SetBounds(rect);
219                         }
220
221                         SetControlAlwaysAtBottom(*__pOverlayPanel, true);
222
223                         __screenMode = SCREEN_MODE_NORMAL;
224                 }
225                 break;
226
227         case SCREEN_MODE_FULL:
228                 {
229                         Rectangle rect = Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height);
230
231                         AppLogDebug("SCREEN_MODE_FULL : [%d][%d][%d][%d][rotation:%d]", rect.x, rect.y, rect.width, rect.height, recRotation);
232
233                         if (destroyOverlay == true)
234                         {
235                                 if (__pOverlayPanel != null)
236                                 {
237                                         __pOverlayPanel->RemoveTouchEventListener(*this);
238                                         RemoveControl(__pOverlayPanel);
239                                         __pOverlayPanel = null;
240                                 }
241
242                                 __pOverlayPanel = new (std::nothrow) OverlayPanel();
243                                 r = __pOverlayPanel->Construct(rect);
244                                 TryCatch(r == E_SUCCESS,, "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
245                                 __pOverlayPanel->SetFocusable(false);
246
247                                 r = AddControl(__pOverlayPanel);
248                                 TryCatch(r == E_SUCCESS,, "AddControl(__pOverlayPanel) failed:%s", GetErrorMessage(r));
249
250                                 __pOverlayPanel->AddTouchEventListener(*this);
251
252                                 AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
253                                 r = pAccessibilityElement->Construct(GetBounds(), L"Overlay Panel");
254
255                                 pContainer = __pOverlayPanel->GetAccessibilityContainer();
256                                 if (pContainer != null)
257                                 {
258                                         pContainer->AddElement(*pAccessibilityElement);
259                                 }
260                         }
261                         else
262                         {
263                                 __pOverlayPanel->SetBounds(rect);
264
265                                 Dimension renderSize = __pOverlayPanel->GetSize();
266                                 __pOverlayPanel->SetRenderSize(renderSize);
267                         }
268
269                         SetControlAlwaysAtBottom(*__pOverlayPanel, true);
270
271                         __screenMode = SCREEN_MODE_FULL;
272                 }
273                 break;
274
275         case SCREEN_MODE_FIT:
276                 {
277                         Rectangle videoRect = __pVideoPlayerPresentationModel->GetVideoInfoN(__pVideoPlayerPresentationModel->GetMediaPathName());
278
279                         Rectangle rect(0, 0, videoRect.width, videoRect.height);
280
281                         if (recRotation == RECORDING_ROTATION_90 || recRotation == RECORDING_ROTATION_270)
282                         {
283                                 rect.width = videoRect.height;
284                                 rect.height = videoRect.width;
285                         }
286
287                         if ((clientRect.width - rect.width) <= X_BASE)
288                         {
289                                 rect.x = X_BASE;
290                         }
291                         else
292                         {
293                                 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
294                         }
295
296                         if ((clientRect.height - rect.height) <= Y_BASE)
297                         {
298                                 rect.y = Y_BASE;
299                         }
300                         else
301                         {
302                                 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
303                         }
304
305                         AppLogDebug("SCREEN_MODE_FIT : [%d][%d][%d][%d][rotation:%d]", rect.x, rect.y, rect.width, rect.height, recRotation);
306
307                         if (destroyOverlay == true)
308                         {
309                                 if (__pOverlayPanel != null)
310                                 {
311                                         __pOverlayPanel->RemoveTouchEventListener(*this);
312                                         RemoveControl(__pOverlayPanel);
313                                         __pOverlayPanel = null;
314                                 }
315
316                                 __pOverlayPanel = new (std::nothrow) OverlayPanel();
317                                 r = __pOverlayPanel->Construct(rect);
318                                 TryCatch(r == E_SUCCESS,, "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
319                                 __pOverlayPanel->SetFocusable(false);
320
321                                 r = AddControl(__pOverlayPanel);
322                                 TryCatch(r == E_SUCCESS,, "AddControl(__pOverlayPanel) failed:%s", GetErrorMessage(r));
323
324                                 __pOverlayPanel->AddTouchEventListener(*this);
325
326                                 AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
327                                 r = pAccessibilityElement->Construct(GetBounds(), L"Overlay Panel");
328
329                                 pContainer = __pOverlayPanel->GetAccessibilityContainer();
330                                 if (pContainer != null)
331                                 {
332                                         pContainer->AddElement(*pAccessibilityElement);
333                                 }
334                         }
335                         else
336                         {
337                                 __pOverlayPanel->SetBounds(rect);
338                         }
339                         SetControlAlwaysAtBottom(*__pOverlayPanel, true);
340
341                         __screenMode = SCREEN_MODE_FIT;
342                 }
343                 break;
344
345         default:
346                 break;
347         }
348
349         return r;
350
351 CATCH:
352         if (__pOverlayPanel != null)
353         {
354                 RemoveControl(__pOverlayPanel);
355                 __pOverlayPanel = null;
356         }
357
358         __screenMode = SCREEN_MODE_NORMAL;
359
360         return r;
361 }
362
363 result
364 VideoPlayerForm::OnInitializing(void)
365 {
366         result r = E_FAILURE;
367
368         AppLogDebug("OnInitializing");
369
370         AddOrientationEventListener(*this);
371         AddTouchEventListener(*this);
372         AddKeyEventListener(*this);
373
374         __pAudioRouteManager = AudioRouteManager::GetInstance();
375         __pAudioRouteManager->SetAudioRouteEventListener(this);
376
377         __pVideoPlayerPresentationModel = VideoPlayerPresentationModel::GetInstance();
378         TryCatch(__pVideoPlayerPresentationModel != null, r = E_SYSTEM, "__pVideoPlayerPresentationModel is null");
379
380         r = SetScreenMode(SCREEN_MODE_NORMAL, true);
381         TryCatch(r == E_SUCCESS,, "SetScreenMode() failed:%s", GetErrorMessage(r));
382
383         __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
384
385         r = __pVideoPlayerPresentationModel->InitializePlayer();
386
387         __pVideoPlayerPresentationModel->SetVideoPlayerEventListener(this);
388
389         InitTimer();
390         InitAudioRouteList();
391
392         r = InitializeHeader();
393         TryCatch(r == E_SUCCESS,, "InitializeHeader() failed : %s", GetErrorMessage(r));
394         r = InitializeFuncPanel();
395         TryCatch(r == E_SUCCESS,, "InitializeFuncPanel() failed : %s", GetErrorMessage(r));
396         r = InitializeController();
397         TryCatch(r == E_SUCCESS,, "InitializeController() failed : %s", GetErrorMessage(r));
398
399         Invalidate(true);
400
401         return r;
402
403 CATCH:
404         DestroyPresentationModelInstance();
405
406         return r;
407 }
408
409 result
410 VideoPlayerForm::InitializeHeader(void)
411 {
412         result r = E_FAILURE;
413
414         AppLogDebug("InitializeHeader");
415
416         __pHeader = GetHeader();
417         TryCatch(__pHeader != null, r = E_SYSTEM, "__pHeader is null");
418
419         __pHeader->AddTouchEventListener(*this);
420
421         return E_SUCCESS;
422
423 CATCH:
424         return r;
425 }
426
427 result
428 VideoPlayerForm::InitializeFuncPanel(void)
429 {
430         result r = E_FAILURE;
431         String launchType;
432
433         AppLogDebug("InitializeFuncPanel");
434
435         __pFunctionPanel = static_cast<Panel*>(GetControl(IDC_PANEL_FUNCTION));
436         TryCatch(__pFunctionPanel != null, r = E_SYSTEM, "__pFunctionPanel is null");
437
438         __pScreenModeButton = static_cast<Button*>(__pFunctionPanel->GetControl(IDC_BUTTON_SCREENMODE));
439         TryCatch(__pScreenModeButton != null, r = E_SYSTEM, "__pScreenModeButton is null");
440         __pScreenModeButton->SetActionId(IDA_BUTTON_FULLSCREEN);
441         __pScreenModeButton->AddActionEventListener(*this);
442         __pScreenModeButton->AddTouchEventListener(*this);
443         __pScreenModeButton->AddKeyEventListener(*this);
444
445         __pShareButton = static_cast<Button*>(__pFunctionPanel->GetControl(IDC_BUTTON_SHARE));
446         TryCatch(__pShareButton != null, r = E_SYSTEM, "__pShareButton is null");
447         __pShareButton->SetActionId(IDA_BUTTON_SHARE);
448         __pShareButton->AddActionEventListener(*this);
449         __pShareButton->AddTouchEventListener(*this);
450         __pShareButton->AddKeyEventListener(*this);
451         
452         launchType = __pVideoPlayerPresentationModel->GetLaunchType();
453         if (launchType == APPCONTROL_DATA_MESSAGE || launchType == APPCONTROL_DATA_EMAIL)
454         {
455                 __pShareButton->SetShowState(false);
456         }
457
458         return E_SUCCESS;
459
460 CATCH:
461         return r;
462 }
463
464 result
465 VideoPlayerForm::InitializeController(void)
466 {
467         result r = E_FAILURE;
468
469         Bitmap* pSliderThumbNormalBitmap = null;
470         Bitmap* pSliderThumbPressedBitmap = null;
471         Bitmap* pSliderThumbDisableBitmap = null;
472
473         AppLogDebug("InitializeController");
474
475         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
476
477         __pControllerPanel = static_cast<Panel*>(GetControl(IDC_PANEL_CONTROLLER));
478         TryCatch(__pControllerPanel != null, r = E_SYSTEM, "__pControllerPanel is null");
479
480         __pRepeatModeButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_REPEATMODE));
481         TryCatch(__pRepeatModeButton != null, r = E_SYSTEM, "__pRepeatModeButton is null");
482         __pRepeatModeButton->SetActionId(IDA_BUTTON_REPEATMODE);
483         __pRepeatModeButton->AddActionEventListener(*this);
484         __pRepeatModeButton->AddTouchEventListener(*this);
485         __pRepeatModeButton->AddKeyEventListener(*this);
486
487         __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_PLAY));
488         TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
489         __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
490         __pPlayPauseButton->AddActionEventListener(*this);
491         __pPlayPauseButton->AddTouchEventListener(*this);
492         __pPlayPauseButton->AddKeyEventListener(*this);
493
494         __pFastRewindButton  = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_FASTREWIND));
495         TryCatch(__pFastRewindButton != null, r = E_SYSTEM, "__pFastRewindButton is null");
496         __pFastRewindButton ->SetActionId(IDA_BUTTON_FASTREWIND);
497         __pFastRewindButton ->AddActionEventListener(*this);
498         __pFastRewindButton->AddTouchEventListener(*this);
499         __pFastRewindButton->AddKeyEventListener(*this);
500
501         __pFastForwardButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_FASTFORWARD));
502         TryCatch(__pFastForwardButton != null, r = E_SYSTEM, "__pFastForwardButton is null");
503         __pFastForwardButton->SetActionId(IDA_BUTTON_FASTFORWARD);
504         __pFastForwardButton->AddActionEventListener(*this);
505         __pFastForwardButton->AddTouchEventListener(*this);
506         __pFastForwardButton->AddKeyEventListener(*this);
507
508         SetFormBackEventListener(this);
509
510         __pCurrenTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_LABEL_CURRENTTIME));
511         TryCatch(__pCurrenTimeLabel != null, r = E_SYSTEM, "__pCurrenTimeLabel is null");
512         __pCurrenTimeLabel->AddTouchEventListener(*this);
513
514         __pTotalTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_LABEL_FULLTIME));
515         TryCatch(__pTotalTimeLabel != null, r = E_SYSTEM, "__pTotalTimeLabel is null");
516         __pTotalTimeLabel->AddTouchEventListener(*this);
517
518         __pSlider = static_cast<Slider*>(__pControllerPanel->GetControl(IDC_SLIDER));
519         TryCatch(__pSlider != null, r = E_SYSTEM, "__pSlider is null");
520         __pSlider->SetEnabled(true);
521         __pSlider->SetRange(MIN_PROGRESS_RANGE, MAX_PROGRESS_RANGE);
522         __pSlider->SetValue(MIN_PROGRESS_RANGE);
523         __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL,
524                         Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
525         __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED,
526                         Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
527         __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED,
528                         Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
529
530         pSliderThumbNormalBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle.png");
531         r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *pSliderThumbNormalBitmap);
532         TryCatch(r == E_SUCCESS,, "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
533
534         pSliderThumbPressedBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle_press.png");
535         r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *pSliderThumbPressedBitmap);
536         TryCatch(r == E_SUCCESS,, "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
537
538         pSliderThumbDisableBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle.png");
539         r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_DISABLED, *pSliderThumbDisableBitmap);
540         TryCatch(r == E_SUCCESS,, "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
541
542         __pSlider->AddAdjustmentEventListener(*this);
543         __pSlider->AddTouchEventListener(*this);
544         __pSlider->AddSliderEventListener(*this);
545         __pSlider->AddKeyEventListener(*this);
546
547 CATCH:
548         delete pSliderThumbNormalBitmap;
549         delete pSliderThumbPressedBitmap;
550         delete pSliderThumbDisableBitmap;
551
552         return r;
553 }
554
555 result
556 VideoPlayerForm::OnTerminating(void)
557 {
558         AppLogDebug("OnTerminating");
559
560         AccessibilityContainer* pContainer = null;
561
562         DeleteTimer();
563         DestroyPresentationModelInstance();
564
565         __pVideoPlayerPresentationModel = null;
566
567         if (__pOverlayPanel != null)
568         {
569                 pContainer = __pOverlayPanel->GetAccessibilityContainer();
570                 pContainer->RemoveAllElements();
571                 RemoveControl(__pOverlayPanel);
572                 __pOverlayPanel = null;
573         }
574
575         delete __pSoundPathPopup;
576         __pSoundPathPopup = null;
577
578         delete __pShareContextMenu;
579         __pShareContextMenu = null;
580
581         pContainer = GetAccessibilityContainer();
582         pContainer->RemoveAllElements();
583
584         return E_SUCCESS;
585 }
586
587 void
588 VideoPlayerForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
589 {
590         AppLogDebug("OnSceneActivatedN");
591
592         TryReturnVoid(__pVideoPlayerPresentationModel != null, "__pVideoPlayerPresentationModel is null");
593
594         SetScreenModeButtonImage();
595 }
596
597 void
598 VideoPlayerForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
599 {
600         result r = E_FAILURE;
601
602         AppLogDebug("OnSceneDeactivated");
603
604         r = __pVideoPlayerPresentationModel->PausePlay();
605         TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
606 }
607
608 void
609 VideoPlayerForm::OnPlayOpened(result r)
610 {
611         AppLogDebug("OnPlayOpened");
612 }
613
614 void
615 VideoPlayerForm::OnPlayEndOfClip(bool playNextContent, int repeatMode, int mediaCount)
616 {
617         result r = E_FAILURE;
618         Rectangle rect;
619         Point point(X_BASE, Y_BASE);
620         Bitmap* pPlayBitmap = null;
621
622         AppLogDebug("OnPlayEndOfClip : %d", playNextContent);
623
624         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
625
626         if (__pSoundPathPopup != null)
627         {
628                 if (__pSoundPathPopup->GetShowState() == true)
629                 {
630                         __pSoundPathPopup->SetShowState(false);
631                 }
632         }
633
634         __pUiControlTimer->Cancel();
635         ShowControl(true);
636         UpdateProgressBar(SLIDER_START_VALUE);
637
638         __pCurrenTimeLabel->SetText(SLIDER_INIT_TIME);
639         __pCurrenTimeLabel->Invalidate(true);
640
641         pPlayBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_play.png");
642         TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
643
644         __pPlayPauseButton->SetNormalBitmap(point, *pPlayBitmap);
645         __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
646         Invalidate(true);
647
648         __pSlider->SetEnabled(false);
649
650         if (__pScreenModeButton->GetShowState() == true)
651         {
652                 __pScreenModeButton->SetShowState(false);
653         }
654
655         switch (repeatMode)
656         {
657         case REPEAT_TYPE_OFF:
658                 {
659                         if (mediaCount < MULTI_CONTENT_COUNT)
660                         {
661                                 r = PowerManager::KeepScreenOnState(false);
662                                 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
663                         }
664                         else
665                         {
666                                 if (playNextContent == true && __setPauseState == false)
667                                 {
668                                         SetScreenMode(SCREEN_MODE_NORMAL, true);
669                                         __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
670
671                                         r = __pVideoPlayerPresentationModel->StartPlay();
672                                         TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
673
674                                         SetScreenModeButtonImage();
675
676                                         __pSlider->SetEnabled(true);
677
678                                         if (__pScreenModeButton->GetShowState() == false)
679                                         {
680                                                 __pScreenModeButton->SetShowState(true);
681                                         }
682
683                                         r = PowerManager::KeepScreenOnState(true, false);
684                                         TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
685                                 }
686                         }
687                 }
688                 break;
689
690         case REPEAT_TYPE_ONE:
691                 {
692                         if (__setPauseState == false)
693                         {
694                                 r = __pVideoPlayerPresentationModel->StartPlay();
695                                 TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
696
697                                 __pSlider->SetEnabled(true);
698
699                                 SetScreenModeButtonImage();
700                                 if (__pScreenModeButton->GetShowState() == false)
701                                 {
702                                         __pScreenModeButton->SetShowState(true);
703                                 }
704
705                                 r = PowerManager::KeepScreenOnState(true, false);
706                                 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
707                         }
708                 }
709                 break;
710
711         case REPEAT_TYPE_ALL:
712                 {
713                         if ( __setPauseState == false)
714                         {
715                                 if (mediaCount < MULTI_CONTENT_COUNT)
716                                 {
717                                         r = __pVideoPlayerPresentationModel->StartPlay();
718                                         TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
719                                 }
720                                 else
721                                 {
722                                         SetScreenMode(SCREEN_MODE_NORMAL, true);
723                                         __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
724
725                                         r = __pVideoPlayerPresentationModel->StartPlay();
726                                         TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
727                                 }
728
729                                 __pSlider->SetEnabled(true);
730
731                                 SetScreenModeButtonImage();
732                                 if (__pScreenModeButton->GetShowState() == false)
733                                 {
734                                         __pScreenModeButton->SetShowState(true);
735                                 }
736
737                                 r = PowerManager::KeepScreenOnState(true, false);
738                                 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
739                         }
740                 }
741                 break;
742
743         default:
744                 break;
745         }
746
747 CATCH:
748         delete pPlayBitmap;
749 }
750
751 void
752 VideoPlayerForm::OnPlayBuffering(int percent)
753 {
754         AppLogDebug("OnPlayBuffering");
755 }
756
757 void
758 VideoPlayerForm::OnPlayErrorOccurred(PlayerErrorReason r)
759 {
760         MessageBox messageBox;
761         String messageBoxString;
762         int modalResult = 0;
763         AppResource* pAppResource = null;
764
765         AppLogDebug("OnPlayErrorOccurred [%d]", r);
766
767         switch (r)
768         {
769         case PLAYER_ERROR_INVALID_DATA:
770                 {
771                         __pVideoPlayerPresentationModel->StopPlay();
772
773                         pAppResource = Application::GetInstance()->GetAppResource();
774                         pAppResource->GetString(IDS_COM_POP_UNSUPPORTED_FILE_TYPE, messageBoxString);
775
776                         messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
777                         messageBox.ShowAndWait(modalResult);
778
779                         UiApp* pApp = UiApp::GetInstance();
780                         TryReturnVoid(pApp != null, "pApp is null");
781                         pApp->Terminate();
782                 }
783                 break;
784
785         case PLAYER_ERROR_DEVICE_FAILED:
786                 {
787                         __pVideoPlayerPresentationModel->StopPlay();
788
789                         pAppResource = Application::GetInstance()->GetAppResource();
790                         pAppResource->GetString(IDS_VPL_POP_UNABLE_TO_PLAY_VIDEO_ERROR_OCCURRED, messageBoxString);
791
792                         messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
793                         messageBox.ShowAndWait(modalResult);
794
795                         UiApp* pApp = UiApp::GetInstance();
796                         TryReturnVoid(pApp != null, "pApp is null");
797                         pApp->Terminate();
798                 }
799                 break;
800
801         default:
802                 break;
803         }
804 }
805
806 void
807 VideoPlayerForm::OnPlayInterrupted(void)
808 {
809         AppLogDebug("OnPlayInterrupted");
810 }
811
812 void
813 VideoPlayerForm::OnPlayReleased(void)
814 {
815         AppLogDebug("OnPlayReleased");
816 }
817
818 void
819 VideoPlayerForm::OnActionPerformed(const Control& source, int actionId)
820 {
821         result r = E_FAILURE;
822
823         String currentTime;
824         String totalTime;
825         Rectangle rect;
826         Point point(X_BASE, Y_BASE);
827
828         PlayerState playState = PLAYER_STATE_ERROR;
829         AppLogDebug("OnActionPerformed : %d", actionId);
830
831         playState = __pVideoPlayerPresentationModel->GetState();
832
833         Rectangle clientRect = GetClientAreaBounds();
834
835         switch (actionId)
836         {
837         case IDA_BUTTON_PLAY:
838                 {
839                         __setPauseState = false;
840
841                         if (playState == PLAYER_STATE_ENDOFCLIP)
842                         {
843                                 if (__pVideoPlayerPresentationModel->GetMediaCount() >= MULTI_CONTENT_COUNT)
844                                 {
845                                         int repeatMode = __pVideoPlayerPresentationModel->GetRepeatMode();
846
847                                         if (repeatMode == REPEAT_TYPE_OFF || repeatMode == REPEAT_TYPE_ALL)
848                                         {
849                                                 SetScreenMode(SCREEN_MODE_NORMAL, true);
850                                                 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
851                                         }
852                                 }
853                         }
854
855                         r = __pVideoPlayerPresentationModel->StartPlay();
856                         TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
857
858                         __pSlider->SetEnabled(true);
859
860                         SetScreenModeButtonImage();
861
862                         if (__pScreenModeButton->GetShowState() == false)
863                         {
864                                 __pScreenModeButton->SetShowState(true);
865                         }
866
867                         r = PowerManager::KeepScreenOnState(true, false);
868                         TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
869                 }
870                 break;
871
872         case IDA_BUTTON_PAUSE:
873                 {
874                         __setPauseState = true;
875
876                         r = __pVideoPlayerPresentationModel->PausePlay();
877                         TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
878
879                         if (__pScreenModeButton->GetShowState() == true)
880                         {
881                                 __pScreenModeButton->SetShowState(false);
882                         }
883
884                         r = PowerManager::KeepScreenOnState(false);
885                         TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
886                 }
887                 break;
888
889         case IDA_BUTTON_FULLSCREEN:
890                 {
891                         if (playState == PLAYER_STATE_PLAYING)
892                         {
893                                 __pUiControlTimer->Cancel();
894                                 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
895                         }
896                         else
897                         {
898                                 return;
899                         }
900
901                         rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
902                                         __pVideoPlayerPresentationModel->GetMediaPathName());
903
904                         if (rect.width == 0 || rect.height == 0)
905                         {
906                                 return;
907                         }
908
909                         switch (__screenMode)
910                         {
911                         case SCREEN_MODE_FIT:
912                                 {
913                                         r = SetScreenMode(SCREEN_MODE_FULL, true);
914                                         TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
915
916                                         __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
917                                         __pVideoPlayerPresentationModel->SetRenderingBuffer();
918
919                                         SetScreenModeButtonImage();
920                                 }
921                                 break;
922
923                         case SCREEN_MODE_FULL:
924                                 {
925                                         r = SetScreenMode(SCREEN_MODE_NORMAL, true);
926                                         TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
927
928                                         __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
929                                         __pVideoPlayerPresentationModel->SetRenderingBuffer();
930
931                                         SetScreenModeButtonImage();
932                                 }
933                                 break;
934
935                         case SCREEN_MODE_NORMAL:
936                                 {
937                                         if (rect.width > W_NORMAL || rect.height > W_NORMAL)
938                                         {
939                                                 r = SetScreenMode(SCREEN_MODE_FULL, true);
940                                                 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
941
942                                                 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
943                                                 __pVideoPlayerPresentationModel->SetRenderingBuffer();
944                                         }
945                                         else
946                                         {
947                                                 r = SetScreenMode(SCREEN_MODE_FIT, true);
948                                                 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
949
950                                                 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
951                                                 __pVideoPlayerPresentationModel->SetRenderingBuffer();
952                                         }
953                                         SetScreenModeButtonImage();
954                                 }
955                                 break;
956
957                         default:
958                                 break;
959                         }
960                 }
961                 break;
962
963         case IDA_BUTTON_SOUNDPATH:
964                 {
965                         if (__pSoundPathPopup == null)
966                         {
967                                 PlayerSoundPathPopupInit();
968                         }
969
970                         if (playState == PLAYER_STATE_PLAYING)
971                         {
972                                 __pUiControlTimer->Cancel();
973                                 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
974                         }
975                         __pSoundPathPopup->ShowPopup(true);
976                 }
977                 break;
978
979         case IDA_BUTTON_FASTFORWARD:
980                 {
981                         if (__actionTouchLongPressed == true)
982                         {
983                                 __actionTouchLongPressed = false;
984                                 break;
985                         }
986
987                         if (playState == PLAYER_STATE_PLAYING)
988                         {
989                                 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
990                         }
991
992                         __pVideoPlayerPresentationModel->Forward();
993                 }
994                 break;
995
996         case IDA_BUTTON_FASTREWIND:
997                 {
998                         if (__actionTouchLongPressed == true)
999                         {
1000                                 __actionTouchLongPressed = false;
1001                                 break;
1002                         }
1003
1004                         if (playState == PLAYER_STATE_PLAYING)
1005                         {
1006                                 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1007                         }
1008
1009                         __pVideoPlayerPresentationModel->Rewind();
1010                 }
1011                 break;
1012
1013         case IDA_BUTTON_SHARE:
1014                 {
1015                         Point point((((GetClientAreaBounds().width - __pFunctionPanel->GetBounds().width) / DIVIDE_BY_TWO)
1016                                         + (__pShareButton->GetBounds().width / DIVIDE_BY_TWO)),
1017                                         __pFunctionPanel->GetBounds().y + __pFunctionPanel->GetBounds().height);
1018
1019                         if (__pShareContextMenu != null)
1020                         {
1021                                 delete __pShareContextMenu;
1022                                 __pShareContextMenu = null;
1023                         }
1024
1025                         __pShareContextMenu = new (std::nothrow) ContextMenu();
1026                         r = __pShareContextMenu->Construct(point, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD);
1027                         TryReturnVoid(r == E_SUCCESS, "__pShareContextMenu->Construct() failed:%s", GetErrorMessage(r));
1028
1029                         String menuItemStr;
1030                         Bitmap* pBitmapMsg = null;
1031                         Bitmap* pBitmapEmail = null;
1032                         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1033
1034                         pAppResource->GetString(L"IDS_COM_BODY_MESSAGE", menuItemStr);
1035                         pBitmapMsg = pAppResource->GetBitmapN(IDB_MENU_ICON_MESSAGE);
1036                         __pShareContextMenu->AddItem(menuItemStr, IDA_CONTEXTMENU_MESSAGE, *pBitmapMsg);
1037                         delete pBitmapMsg;
1038
1039                         pAppResource->GetString(L"IDS_COM_BODY_EMAIL", menuItemStr);
1040                         pBitmapEmail = pAppResource->GetBitmapN(IDB_MENU_ICON_EMAIL);
1041                         __pShareContextMenu->AddItem(menuItemStr, IDA_CONTEXTMENU_EMAIL, *pBitmapEmail);
1042                         delete pBitmapEmail;
1043
1044                         __pShareContextMenu->SetFocusable(true);
1045                         __pShareContextMenu->AddActionEventListener(*this);
1046                         __pShareContextMenu->SetShowState(true);
1047                         __pShareContextMenu->Show();
1048
1049                         if (playState == PLAYER_STATE_PLAYING)
1050                         {
1051                                 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1052                         }
1053                 }
1054                 break;
1055
1056         case IDA_CONTEXTMENU_MESSAGE:
1057                 {
1058                         AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE);
1059                         TryReturnVoid(pAppControl != null, "pAppControl is null");
1060
1061                         String filePath = __pVideoPlayerPresentationModel->GetMediaPathName();
1062
1063                         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1064                         r = pDataList->Construct();
1065
1066                         if ( r != E_SUCCESS)
1067                         {
1068                                 delete pDataList;
1069                                 delete pAppControl;
1070                                 return;
1071                         }
1072
1073
1074                         ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1075                         pList->Add(new (std::nothrow) String(filePath));
1076                         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
1077                         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
1078                         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_RETURN_RESULT), new (std::nothrow) String("true"));
1079
1080                         r = pAppControl->Start(null, null, pDataList, this);
1081
1082                         if (r == E_SUCCESS)
1083                         {
1084                                 VideoPlayerApp* pVideoPlayerApp = static_cast<VideoPlayerApp*>(VideoPlayerApp::GetInstance());
1085                                 pVideoPlayerApp->SetFrameEnabled(false);
1086                         }
1087
1088                         pDataList->RemoveAll(true);
1089                         delete pDataList;
1090
1091
1092                         delete pAppControl;
1093                 }
1094                 break;
1095
1096         case IDA_CONTEXTMENU_EMAIL:
1097                 {
1098                         AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE);
1099                         TryReturnVoid(pAppControl != null, "pAppControl is null");
1100
1101                         String filePath = __pVideoPlayerPresentationModel->GetMediaPathName();
1102
1103                         HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1104
1105                         r = pDataList->Construct();
1106
1107                         if ( r != E_SUCCESS)
1108                         {
1109                                 delete pDataList;
1110                                 delete pAppControl;
1111                                 return;
1112                         }
1113
1114                         ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1115                         pList->Add(new (std::nothrow) String(filePath));
1116                         pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
1117
1118                         r = pAppControl->Start(null, null, pDataList, this);
1119
1120                         if (r == E_SUCCESS)
1121                         {
1122                                 VideoPlayerApp* pVideoPlayerApp = static_cast<VideoPlayerApp*>(VideoPlayerApp::GetInstance());
1123                                 pVideoPlayerApp->SetFrameEnabled(false);
1124                         }
1125
1126                         pDataList->RemoveAll(true);
1127                         delete pDataList;
1128
1129                         delete pAppControl;
1130                 }
1131                 break;
1132
1133         case IDA_BUTTON_REPEATMODE:
1134                 {
1135                         int repeatMode = __pVideoPlayerPresentationModel->GetRepeatMode();
1136
1137                         switch (repeatMode)
1138                         {
1139                         case REPEAT_TYPE_OFF:
1140                                 {
1141                                         SetRepeatButtonImage(REPEAT_TYPE_ONE);
1142                                 }
1143                                 break;
1144
1145                         case REPEAT_TYPE_ONE:
1146                                 {
1147                                         if (__pVideoPlayerPresentationModel->GetMediaCount() > 1)
1148                                         {
1149                                                 SetRepeatButtonImage(REPEAT_TYPE_ALL);
1150                                         }
1151                                         else
1152                                         {
1153                                                 SetRepeatButtonImage(REPEAT_TYPE_OFF);
1154                                         }
1155                                 }
1156                                 break;
1157
1158                         case REPEAT_TYPE_ALL:
1159                                 {
1160                                         SetRepeatButtonImage(REPEAT_TYPE_OFF);
1161                                 }
1162                                 break;
1163
1164                         default:
1165                                 break;
1166                         }
1167
1168                         if (playState == PLAYER_STATE_PLAYING)
1169                         {
1170                                 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1171                         }
1172                 }
1173                 break;
1174
1175         case IDA_BUTTON_BACK:
1176                 {
1177                         Application::GetInstance()->Terminate();
1178                 }
1179                 break;
1180
1181         default:
1182                 break;
1183         }
1184 }
1185
1186 void
1187 VideoPlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition,
1188                 const TouchEventInfo& touchInfo)
1189 {
1190         AppLogDebug("OnTouchPressed Control : %ls", source.GetName().GetPointer());
1191         __pUiControlTimer->Cancel();
1192 }
1193
1194 void
1195 VideoPlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition,
1196                 const TouchEventInfo& touchInfo)
1197 {
1198         AppLogDebug("OnTouchReleased Control : %ls", source.GetName().GetPointer());
1199
1200         PlayerState playState = PLAYER_STATE_ERROR;
1201
1202         if ((&source == __pFastForwardButton
1203                 || &source == __pFastRewindButton)
1204                 && __actionTouchLongPressed == true)
1205         {
1206                 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1207         }
1208
1209         playState = __pVideoPlayerPresentationModel->GetState();
1210
1211         if (playState == PLAYER_STATE_PLAYING || playState == PLAYER_STATE_PAUSED || playState == PLAYER_STATE_ENDOFCLIP)
1212         {
1213                 if (source.GetName() == L"IDL_MAIN_FORM"
1214                         || source.GetHashCode() == __pOverlayPanel->GetHashCode()
1215                         || source.GetHashCode() == __pHeader->GetHashCode())
1216                 {
1217                         if (__isControlVisibleState == true)
1218                         {
1219                                 if (source.GetHashCode() == __pHeader->GetHashCode())
1220                                 {
1221                                         if (__pUiControlTimer != null)
1222                                         {
1223                                                 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1224                                         }
1225                                 }
1226                                 else
1227                                 {
1228                                         ShowControl(false);
1229                                 }
1230                         }
1231                         else
1232                         {
1233                                 ShowControl(true);
1234
1235                                 if (__pUiControlTimer != null)
1236                                 {
1237                                         __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1238                                 }
1239                         }
1240                 }
1241                 else if (source.GetHashCode() == __pSlider->GetHashCode() && __playingBeforeSlide == true)
1242                 {
1243                         result r = __pVideoPlayerPresentationModel->StartPlay();
1244                         TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
1245                         __playingBeforeSlide = false;
1246                 }
1247         }
1248 }
1249
1250 void
1251 VideoPlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition,
1252                 const TouchEventInfo& touchInfo)
1253 {
1254         AppLogDebug("OnTouchLongPressed Control : %ls", source.GetName().GetPointer());
1255
1256         if (&source == __pFastForwardButton)
1257         {
1258                 __actionTouchLongPressed = true;
1259
1260                 if (__setPauseState == true)
1261                 {
1262                         __pVideoPlayerPresentationModel->FastForward(false);
1263                 }
1264                 else
1265                 {
1266                         __pVideoPlayerPresentationModel->FastForward(true);
1267                 }
1268         }
1269         else if (&source == __pFastRewindButton)
1270         {
1271                 __actionTouchLongPressed = true;
1272
1273                 if (__setPauseState == true)
1274                 {
1275                         __pVideoPlayerPresentationModel->FastRewind(false);
1276                 }
1277                 else
1278                 {
1279                         __pVideoPlayerPresentationModel->FastRewind(true);
1280                 }
1281         }
1282         else if (&source == __pSlider)
1283         {
1284                 PlayerState playState = PLAYER_STATE_ERROR;
1285                 playState = __pVideoPlayerPresentationModel->GetState();
1286
1287                 if (playState == PLAYER_STATE_PLAYING)
1288                 {
1289                         result r = __pVideoPlayerPresentationModel->PausePlay();
1290                         TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
1291                         __playingBeforeSlide = true;
1292                 }
1293         }
1294 }
1295
1296 void
1297 VideoPlayerForm::OnTimerExpired(Timer& timer)
1298 {
1299         if (timer.GetHashCode() == __pUiControlTimer->GetHashCode())
1300         {
1301                 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1302                 {
1303                         ShowControl(false);
1304                 }
1305         }
1306 }
1307
1308 void
1309 VideoPlayerForm::OnAdjustmentValueChanged(const Control& source, int adjustment)
1310 {
1311         result r = E_FAILURE;
1312         long seekTime = 0;
1313
1314         AppLogDebug("OnAdjustmentValueChanged : %d", adjustment);
1315
1316         if (source.GetHashCode() == __pSlider->GetHashCode() && __sliderMoved == true
1317                 && adjustment >= MIN_PROGRESS_RANGE && adjustment <= MAX_PROGRESS_RANGE)
1318         {
1319                 __sliderMoved = false;
1320
1321                 seekTime = adjustment * (__pVideoPlayerPresentationModel->GetDuration() / MAX_PROGRESS_RANGE);
1322                 if (__pVideoPlayerPresentationModel->GetSeekCompleted())
1323                 {
1324                         r = __pVideoPlayerPresentationModel->SeekTo(seekTime);
1325                         TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
1326                 }
1327                 else
1328                 {
1329                         __timeToSeek = seekTime;
1330                 }
1331
1332                 UpdateProgressBar(adjustment);
1333         }
1334
1335         if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1336         {
1337                 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1338         }
1339 }
1340
1341 void
1342 VideoPlayerForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1343 {
1344         __pUiControlTimer->Cancel();
1345 }
1346
1347 void
1348 VideoPlayerForm::OnKeyReleased(const Control& source, KeyCode keyCode)
1349 {
1350         AppLogDebug("OnKeyReleased Control : %ls, KeyCode : %d", source.GetName().GetPointer(), keyCode);
1351
1352         if ((&source == __pFastForwardButton
1353                 || &source == __pFastRewindButton)
1354                 && __actionTouchLongPressed == true)
1355         {
1356                 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1357         }
1358
1359         if (source.GetName() == L"IDL_MAIN_FORM" && __isControlVisibleState == false)
1360         {
1361                 ShowControl(true);
1362
1363                 if (__pUiControlTimer != null)
1364                 {
1365                         __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1366                 }
1367         }
1368 }
1369
1370 void
1371 VideoPlayerForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1372 {
1373         AppLogDebug("OnKeyLongPressed Control : %ls, KeyCode : %d", source.GetName().GetPointer(), keyCode);
1374
1375         if (keyCode == KEY_ENTER)
1376         {
1377                 if (&source == __pFastForwardButton)
1378                 {
1379                         __actionTouchLongPressed = true;
1380
1381                         if (__setPauseState == true)
1382                         {
1383                                 __pVideoPlayerPresentationModel->FastForward(false);
1384                         }
1385                         else
1386                         {
1387                                 __pVideoPlayerPresentationModel->FastForward(true);
1388                         }
1389                 }
1390                 else if (&source == __pFastRewindButton)
1391                 {
1392                         __actionTouchLongPressed = true;
1393
1394                         if (__setPauseState == true)
1395                         {
1396                                 __pVideoPlayerPresentationModel->FastRewind(false);
1397                         }
1398                         else
1399                         {
1400                                 __pVideoPlayerPresentationModel->FastRewind(true);
1401                         }
1402                 }
1403         }
1404 }
1405
1406 void
1407 VideoPlayerForm::UpdateProgressBar(const int currentPlayTime)
1408 {
1409         TryReturnVoid(__pSlider, "__pSlider is null");
1410
1411         __pSlider->SetValue(currentPlayTime);
1412         __pSlider->Invalidate(true);
1413 }
1414
1415 void
1416 VideoPlayerForm::InitTimer(void)
1417 {
1418         __pUiControlTimer = new (std::nothrow) Timer();
1419         __pUiControlTimer->Construct(*this);
1420 }
1421
1422 void
1423 VideoPlayerForm::DeleteTimer(void)
1424 {
1425         if (__pUiControlTimer != null)
1426         {
1427                 __pUiControlTimer->Cancel();
1428                 delete __pUiControlTimer;
1429                 __pUiControlTimer = null;
1430         }
1431 }
1432
1433 result
1434 VideoPlayerForm::SetPlayPauseButtonImage(PlayerState playState)
1435 {
1436         result r = E_SUCCESS;
1437
1438         Bitmap* pPlayBitmap = null;
1439         Bitmap* pPauseBitmap = null;
1440         Point point(X_BASE, Y_BASE);
1441
1442         AppLogDebug("SetPlayPauseButtonImage : %d", playState);
1443
1444         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1445
1446         __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_PLAY));
1447         TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
1448
1449         if (playState == PLAYER_STATE_PLAYING)
1450         {
1451                 pPauseBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_pause.png");
1452                 TryCatch(pPauseBitmap != null, r = E_SYSTEM, "pPauseBitmap is null");
1453
1454                 __pPlayPauseButton->SetNormalBitmap(point, *pPauseBitmap);
1455
1456                 __pPlayPauseButton->SetActionId(IDA_BUTTON_PAUSE);
1457                 __pPlayPauseButton->Invalidate(true);
1458
1459                 delete pPauseBitmap;
1460         }
1461         else
1462         {
1463                 pPlayBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_play.png");
1464                 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
1465
1466                 __pPlayPauseButton->SetNormalBitmap(point, *pPlayBitmap);
1467
1468                 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
1469                 __pPlayPauseButton->Invalidate(true);
1470
1471                 delete pPlayBitmap;
1472         }
1473         return r;
1474
1475 CATCH:
1476         return r;
1477 }
1478
1479 void
1480 VideoPlayerForm::SetRepeatButtonImage(int repeatValue)
1481 {
1482         AppLogDebug("SetRepeatButtonImage");
1483         Bitmap* pRepeatBitmap = null;
1484         Bitmap* pRepeatPressBitmap = null;
1485
1486         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1487
1488         switch (repeatValue)
1489         {
1490         case REPEAT_TYPE_OFF:
1491                 {
1492                         pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat.png");
1493                         pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_press.png");
1494                 }
1495                 break;
1496
1497         case REPEAT_TYPE_ONE:
1498                 {
1499                         pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_1.png");
1500                         pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_1_press.png");
1501                 }
1502                 break;
1503
1504         case REPEAT_TYPE_ALL:
1505                 {
1506                         pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_all.png");
1507                         pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_all_press.png");
1508                 }
1509                 break;
1510
1511         default:
1512                 break;
1513         }
1514         __pRepeatModeButton->SetNormalBitmap(Point(X_BASE, Y_BASE), *pRepeatBitmap);
1515         __pRepeatModeButton->SetPressedBitmap(Point(X_BASE, Y_BASE), *pRepeatPressBitmap);
1516         __pVideoPlayerPresentationModel->SetRepeatMode(repeatValue);
1517         __pVideoPlayerPresentationModel->ChangeCurrentMediaIndex();
1518
1519         delete pRepeatBitmap;
1520         delete pRepeatPressBitmap;
1521
1522         Invalidate(true);
1523 }
1524
1525 void
1526 VideoPlayerForm::SetScreenModeButtonImage(void)
1527 {
1528         AppLogDebug("SetScreenModeButtonImage");
1529         Rectangle rect;
1530         Point point(X_BASE, Y_BASE);
1531         Bitmap* pBitmapScreenMode = null;
1532
1533         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1534
1535         String mediaPathName = __pVideoPlayerPresentationModel->GetMediaPathName();
1536         rect = __pVideoPlayerPresentationModel->GetVideoInfoN(mediaPathName);
1537
1538         switch (__screenMode)
1539         {
1540         case SCREEN_MODE_NORMAL:
1541                 {
1542                         if (rect.width > W_NORMAL || rect.height > W_NORMAL)
1543                         {
1544                                 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03.png");
1545                                 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1546                                 delete pBitmapScreenMode;
1547                                 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03_press.png");
1548                                 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1549                                 delete pBitmapScreenMode;
1550                         }
1551                         else
1552                         {
1553                                 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_Function_icon_screenmode_press.png");
1554                                 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1555                                 delete pBitmapScreenMode;
1556                                 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_Function_icon_screenmode_press.png");
1557                                 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1558                                 delete pBitmapScreenMode;
1559                         }
1560                 }
1561                 break;
1562
1563         case SCREEN_MODE_FULL:
1564                 {
1565                         pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode02.png");
1566                         __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1567                         delete pBitmapScreenMode;
1568                         pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode02_press.png");
1569                         __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1570                         delete pBitmapScreenMode;
1571                 }
1572                 break;
1573
1574         case SCREEN_MODE_FIT:
1575                 {
1576                         pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03.png");
1577                         __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1578                         delete pBitmapScreenMode;
1579                         pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03_press.png");
1580                         __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1581                         delete pBitmapScreenMode;
1582                 }
1583                 break;
1584
1585         default:
1586                 break;
1587         }
1588
1589         Invalidate(true);
1590 }
1591
1592 void
1593 VideoPlayerForm::GetTotalTime(String& totalTime)
1594 {
1595         result r = E_FAILURE;
1596         DateTime dateTime;
1597
1598         dateTime.AddSeconds(__pVideoPlayerPresentationModel->GetDuration() / MILLISECOND);
1599         r = totalTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1600         TryReturnVoid(r == E_SUCCESS, "totalTime.Format() failed:%s", GetErrorMessage(r));
1601 }
1602
1603 void
1604 VideoPlayerForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1605 {
1606         AppLogDebug("OnOrientationChanged");
1607
1608         AccessibilityContainer* pContainer = GetAccessibilityContainer();
1609         AccessibilityElement* pAccessibilityElement = pContainer->GetElement(L"IDL_MAIN_FORM");
1610         pAccessibilityElement->SetBounds(GetBounds());
1611
1612         SetScreenMode(__screenMode, false);
1613
1614         switch (orientationStatus)
1615         {
1616         case ORIENTATION_STATUS_PORTRAIT:
1617                 {
1618                         // Empty statement
1619                 }
1620                 break;
1621
1622         case ORIENTATION_STATUS_LANDSCAPE:
1623                 // fall through
1624         case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
1625                 {
1626                         // Empty statement
1627                 }
1628                 break;
1629
1630         default:
1631                 break;
1632         }
1633 }
1634
1635 void
1636 VideoPlayerForm::PlayerSoundPathPopupInit(void)
1637 {
1638         int tempAudioRouteMode = 0;
1639         int currentOutputDevice = 0;
1640         tempAudioRouteMode = __audioRouteMode;
1641         AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1642
1643         currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1644         currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1645
1646         __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
1647         result r = __pSoundPathPopup->Construct(currentOutputDevice,
1648                         __pAudioRouteManager->GetActiveBluetoothA2dpName(), tempAudioRouteMode);
1649         TryReturnVoid(r == E_SUCCESS, "__pSoundPathPopup->Construct() failed:%s", GetErrorMessage(r));
1650 }
1651
1652 void
1653 VideoPlayerForm::CreateMessageBox(const String& title, const String& message, MessageBoxStyle style,
1654                 unsigned long timeout)
1655 {
1656 }
1657
1658 void
1659 VideoPlayerForm::ShowControl(bool setShow)
1660 {
1661         AppLogDebug("ShowControl");
1662
1663         if (setShow == true)
1664         {
1665                 __pHeader->SetShowState(true);
1666                 __pFunctionPanel->SetShowState(true);
1667                 __pControllerPanel->SetShowState(true);
1668                 __isControlVisibleState = true;
1669         }
1670         else
1671         {
1672                 __pHeader->SetShowState(false);
1673                 __pFunctionPanel->SetShowState(false);
1674                 __pControllerPanel->SetShowState(false);
1675                 SetFocus();
1676
1677                 if (__pShareContextMenu != null)
1678                 {
1679                         if (__pShareContextMenu->GetShowState() == true)
1680                         {
1681                                 __pShareContextMenu->SetShowState(false);
1682                         }
1683                 }
1684
1685                 __isControlVisibleState = false;
1686         }
1687 }
1688
1689 void
1690 VideoPlayerForm::CheckAppLaunchable(void)
1691 {
1692         AppLogDebug("CheckAppLaunchable");
1693
1694         CheckCallStatus();
1695         CheckLowBatteryStatus();
1696 }
1697
1698 void
1699 VideoPlayerForm::CancelTimerByFrameDeactivated(void)
1700 {
1701         AppLogDebug("CancelTimerByFrameDeactivated");
1702
1703         __pUiControlTimer->Cancel();
1704         __setPauseState = true;
1705
1706         ShowControl(true);
1707         __pScreenModeButton->SetShowState(false);
1708 }
1709
1710 void
1711 VideoPlayerForm::SetFrameActivated(bool frameActivated)
1712 {
1713         __frameActivated = frameActivated;
1714 }
1715
1716 bool
1717 VideoPlayerForm::GetFrameActivated(void) const
1718 {
1719         return __frameActivated;
1720 }
1721
1722 void
1723 VideoPlayerForm::OnPlayContentChanged(const String& fileName)
1724 {
1725         String totalTime;
1726
1727         AppLogDebug("OnPlayContentChanged");
1728
1729         GetTotalTime(totalTime);
1730
1731         __pHeader->SetTitleText(fileName);
1732         __pHeader->Invalidate(true);
1733
1734         __pTotalTimeLabel->SetText(totalTime);
1735         __pTotalTimeLabel->Invalidate(true);
1736 }
1737
1738 void
1739 VideoPlayerForm::OnPlayTimeChanged(int currentProgressPos, String& playTime)
1740 {
1741         AppLogDebug("OnPlayTimeChanged");
1742
1743         __pSlider->SetValue(currentProgressPos);
1744         __pSlider->Invalidate(true);
1745
1746         __pCurrenTimeLabel->SetText(playTime);
1747         __pCurrenTimeLabel->Invalidate(true);
1748 }
1749
1750 void
1751 VideoPlayerForm::OnPlayStateChanged(PlayerState playState)
1752 {
1753         AppLogDebug("OnPlayStateChanged");
1754
1755         SetPlayPauseButtonImage(playState);
1756
1757         if (playState == PLAYER_STATE_PLAYING)
1758         {
1759                 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1760
1761                 if (__pScreenModeButton->GetShowState() == false)
1762                 {
1763                         __pScreenModeButton->SetShowState(true);
1764                 }
1765         }
1766         else
1767         {
1768                 __pUiControlTimer->Cancel();
1769                 ShowControl(true);
1770
1771                 if (__pScreenModeButton->GetShowState() == true)
1772                 {
1773                         __pScreenModeButton->SetShowState(false);
1774                 }
1775         }
1776 }
1777
1778 void
1779 VideoPlayerForm::OnPlaySeekCompleted(result r)
1780 {
1781         AppLogDebug("OnPlaySeekCompleted ");
1782
1783         if (__timeToSeek != SEEK_TIME_NONE && __pVideoPlayerPresentationModel->GetSeekCompleted())
1784         {
1785                 r = __pVideoPlayerPresentationModel->SeekTo(__timeToSeek);
1786                 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
1787                 __timeToSeek = SEEK_TIME_NONE;
1788         }
1789         else if (!__sliderMoved && __playingBeforeSlide)
1790         {
1791                 r = __pVideoPlayerPresentationModel->StartPlay();
1792                 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
1793                 __playingBeforeSlide = false;
1794         }
1795 }
1796
1797 void
1798 VideoPlayerForm::CheckLowBatteryStatus(void)
1799 {
1800         bool isCharging = false;
1801         BatteryLevel batteryLevel;
1802
1803         AppLogDebug("CheckLowBatteryStatus");
1804
1805         Battery::GetCurrentLevel(batteryLevel);
1806         Battery::IsCharging(isCharging);
1807
1808         if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
1809         {
1810                 if (isCharging == false)
1811                 {
1812                         int result = 0;
1813                                 MessageBox msgBox;
1814                         String messageBoxString;
1815                         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1816                         pAppResource->GetString(IDS_COM_POP_LOW_BATTERY_UNABLE_TO_LAUNCH_APPLICATION, messageBoxString);
1817
1818                         msgBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
1819                         msgBox.ShowAndWait(result);
1820
1821                         switch (result)
1822                         {
1823                         case MSGBOX_RESULT_CLOSE:
1824                                 {
1825                                         OnFormBackRequested(*this);
1826                                 }
1827                                 break;
1828
1829                         default:
1830                                 break;
1831                         }
1832                 }
1833         }
1834 }
1835
1836 void
1837 VideoPlayerForm::CheckCallStatus(void)
1838 {
1839         AppLogDebug("CheckCallStatus");
1840
1841         CallManager* pCallManager = new (std::nothrow) CallManager();
1842
1843         result r = pCallManager->Construct();
1844         TryCatch(r == E_SUCCESS,, "pCallManager->Construct() failed : %s", GetErrorMessage(r));
1845
1846         if (pCallManager->GetCurrentCallStatus() != CALL_STATUS_IDLE
1847                 && pCallManager->GetCurrentCallStatus() != CALL_STATUS_UNDEFINED)
1848         {
1849                 int modalResult = 0;
1850                 MessageBox msgBox;
1851                 String dispString;
1852
1853                 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1854                 pAppResource->GetString(L"IDS_VPL_BODY_UNABLE_TO_PLAY_VIDEO_DURING_CALL", dispString);
1855
1856                 msgBox.Construct(L"", dispString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
1857                 msgBox.ShowAndWait(modalResult);
1858
1859                 switch (modalResult)
1860                 {
1861                 case MSGBOX_RESULT_CLOSE:
1862                         {
1863                                 OnFormBackRequested(*this);
1864                         }
1865                         break;
1866
1867                 default:
1868                         break;
1869                 }
1870         }
1871
1872 CATCH:
1873         delete pCallManager;
1874 }
1875
1876 void
1877 VideoPlayerForm::OnFormBackRequested(Form& source)
1878 {
1879         AppLogDebug("OnFormBackRequested");
1880
1881         bool frameActivated = GetFrameActivated();
1882
1883         if (frameActivated == true)
1884         {
1885                 UiApp* pApp = UiApp::GetInstance();
1886                 TryReturnVoid(pApp != null, "pApp is null");
1887
1888                 result r = pApp->Terminate();
1889                 TryReturnVoid(r == E_SUCCESS, "Failed Terminate [%s]", GetErrorMessage(r));
1890         }
1891 }
1892
1893 void
1894 VideoPlayerForm::OnActiveAudioRouteChanged(const AudioRouteInfo& route)
1895 {
1896         Color BtnColor(0, 0, 0, 0);
1897         int currentOutputAudioDevice = 0;
1898         ArrayList* pArgs = null;
1899
1900         AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1901
1902         AppLogDebug("OnActiveAudioRouteChanged");
1903
1904         switch (route.GetOutputAudioDevice())
1905         {
1906         case OUTPUT_AUDIO_DEVICE_BT_A2DP:
1907                 {
1908                         if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
1909                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1910                         {
1911                                 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1912                         }
1913                         else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1914                                         && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1915                         {
1916                                 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
1917
1918                                 if (__pSoundPathPopup != null)
1919                                 {
1920                                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1921                                         pArgs->Construct();
1922
1923                                         pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1924                                         pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1925
1926                                         __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
1927                                 }
1928                         }
1929                 }
1930                 break;
1931
1932         case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
1933                 {
1934                         if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
1935                                 &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1936                         {
1937                                 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1938
1939                                 if (__pSoundPathPopup != null)
1940                                 {
1941                                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1942                                         pArgs->Construct();
1943
1944                                         pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1945
1946                                         __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU,
1947                                                         pArgs);
1948                                 }
1949                         }
1950                         else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
1951                                         &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1952                         {
1953                                 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
1954
1955                                 if (__pSoundPathPopup != null)
1956                                 {
1957                                         currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1958                                         currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1959
1960                                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1961                                         pArgs->Construct();
1962
1963                                         pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1964                                         pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
1965
1966                                         __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
1967                                 }
1968                         }
1969                 }
1970                 break;
1971
1972         case OUTPUT_AUDIO_DEVICE_SPEAKER:
1973                 {
1974                         if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1975                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
1976                         {
1977                                 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
1978
1979                                 if (__pSoundPathPopup != null)
1980                                 {
1981                                         if (__pSoundPathPopup->GetShowState() == true)
1982                                         {
1983                                                 __pSoundPathPopup->SetShowState(false);
1984                                         }
1985                                 }
1986                         }
1987                         else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
1988                                         && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
1989                         {
1990                                 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
1991
1992                                 if (__pSoundPathPopup != null)
1993                                 {
1994                                         currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1995                                         currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1996
1997                                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1998                                         pArgs->Construct();
1999
2000                                         pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2001                                         pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
2002
2003                                         __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2004                                 }
2005                         }
2006                 }
2007                 break;
2008
2009         default:
2010                 break;
2011         }
2012 }
2013
2014 void
2015 VideoPlayerForm::OnAudioRouteAdded(const AudioRouteInfo& route)
2016 {
2017         AppLogDebug("OnAudioRouteAdded");
2018
2019         switch (route.GetOutputAudioDevice())
2020         {
2021         case OUTPUT_AUDIO_DEVICE_NONE:
2022                 {
2023                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2024                 }
2025                 break;
2026
2027         case OUTPUT_AUDIO_DEVICE_SPEAKER:
2028                 {
2029                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2030                 }
2031                 break;
2032
2033         case OUTPUT_AUDIO_DEVICE_RECEIVER:
2034                 {
2035                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2036                 }
2037                 break;
2038
2039         case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2040                 {
2041                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2042                 }
2043                 break;
2044
2045         case OUTPUT_AUDIO_DEVICE_BT_SCO:
2046                 {
2047                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2048                 }
2049                 break;
2050
2051         case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2052                 {
2053                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = true;
2054                 }
2055                 break;
2056
2057         default:
2058                 break;
2059         }
2060 }
2061
2062 void
2063 VideoPlayerForm::OnAudioRouteRemoved(const AudioRouteInfo& route)
2064 {
2065         ArrayList* pArgs = null;
2066         int currentOutputDevice = 0;
2067         AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2068
2069         AppLogDebug("OnAudioRouteRemoved");
2070
2071         currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2072
2073         switch (route.GetOutputAudioDevice())
2074         {
2075         case OUTPUT_AUDIO_DEVICE_NONE:
2076                 {
2077                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = false;
2078                 }
2079                 break;
2080
2081         case OUTPUT_AUDIO_DEVICE_SPEAKER:
2082                 {
2083                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = false;
2084                 }
2085                 break;
2086
2087         case OUTPUT_AUDIO_DEVICE_RECEIVER:
2088                 {
2089                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = false;
2090                 }
2091                 break;
2092
2093         case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2094                 {
2095                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = false;
2096                 }
2097                 break;
2098
2099         case OUTPUT_AUDIO_DEVICE_BT_SCO:
2100                 {
2101                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = false;
2102                 }
2103                 break;
2104
2105         case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2106                 {
2107                         __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = false;
2108                 }
2109                 break;
2110
2111         default:
2112                 break;
2113         }
2114
2115         if (currentAudioRoute.GetOutputAudioDevice() != route.GetOutputAudioDevice())
2116         {
2117                 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2118                 {
2119                         if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2120                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2121                         {
2122                                 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2123
2124                                 if (__pSoundPathPopup != null)
2125                                 {
2126                                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2127                                         pArgs->Construct();
2128
2129                                         pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2130                                         pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2131
2132                                         __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2133                                 }
2134                         }
2135                 }
2136                 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2137                 {
2138                         if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2139                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2140                         {
2141                                 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2142                         }
2143                         else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2144                                         && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2145                         {
2146                                 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2147                         }
2148                         else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2149                                         && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2150                         {
2151                                 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2152
2153                                 if (__pSoundPathPopup != null)
2154                                 {
2155                                         currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2156                                         currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2157
2158                                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2159                                         pArgs->Construct();
2160
2161                                         pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2162                                         pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2163
2164                                         __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2165                                 }
2166                         }
2167                 }
2168                 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2169                 {
2170                         if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2171                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2172                         {
2173                                 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2174
2175                                 if (__pSoundPathPopup != null)
2176                                 {
2177                                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2178                                         pArgs->Construct();
2179
2180                                         pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2181                                         pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2182
2183                                         __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2184                                 }
2185                         }
2186                         else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2187                                         && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2188                         {
2189                                 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2190
2191                                 if (__pSoundPathPopup != null)
2192                                 {
2193                                         currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2194                                         currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2195
2196                                         pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2197                                         pArgs->Construct();
2198
2199                                         pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2200                                         pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2201
2202                                         __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2203                                 }
2204                         }
2205                         else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2206                                         && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2207                         {
2208                                 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2209
2210                                 if (__pSoundPathPopup != null)
2211                                 {
2212                                         if (__pSoundPathPopup->GetShowState() == true)
2213                                         {
2214                                                 __pSoundPathPopup->SetShowState(false);
2215                                         }
2216                                 }
2217                         }
2218                 }
2219         }
2220 }
2221
2222 void
2223 VideoPlayerForm::InitAudioRouteList(void)
2224 {
2225         AppLogDebug("InitAudioRouteList");
2226
2227         int listCount = 0;
2228         IList* availableAudioRouteList = null;
2229         AudioRouteInfo* tempRouteInfo = null;
2230         AudioRouteInfo availableRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2231         AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2232
2233         availableAudioRouteList = __pAudioRouteManager->GetAvailableAudioRouteListN();
2234
2235         if (availableAudioRouteList != null)
2236         {
2237                 for (listCount = 0; listCount < availableAudioRouteList->GetCount(); ++listCount)
2238                 {
2239                         tempRouteInfo = static_cast<AudioRouteInfo*>(availableAudioRouteList->GetAt(listCount));
2240                         availableRouteInfo = *tempRouteInfo;
2241
2242                         if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_NONE)
2243                         {
2244                                 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2245                         }
2246                         else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2247                         {
2248                                 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2249                         }
2250                         else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_RECEIVER)
2251                         {
2252                                 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2253                         }
2254                         else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2255                         {
2256                                 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2257                         }
2258                         else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_SCO)
2259                         {
2260                                 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2261                         }
2262                         else
2263                         {
2264                                 __availableAudioRoute[OUTPUT_AUDIO_DEVICE_BT_A2DP] = true;
2265                         }
2266                 }
2267
2268                 availableAudioRouteList->RemoveAll(true);
2269                 delete availableAudioRouteList;
2270                 availableAudioRouteList = null;
2271         }
2272         currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2273
2274         if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2275         {
2276                 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2277                         && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2278                 {
2279                         __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2280                 }
2281                 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2282                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2283                 {
2284                         __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2285                 }
2286                 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2287                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2288                 {
2289                         __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2290                 }
2291         }
2292         else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2293         {
2294                 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2295                         && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2296                 {
2297                         __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2298                 }
2299                 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2300                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2301                 {
2302                         __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2303                 }
2304                 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2305                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2306                 {
2307                         __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2308                 }
2309         }
2310         else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2311         {
2312                 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2313                         && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2314                 {
2315                         __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2316                 }
2317                 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2318                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2319                 {
2320                         __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2321                 }
2322                 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2323                                 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2324                 {
2325                         __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2326                 }
2327         }
2328 }
2329
2330 result
2331 VideoPlayerForm::SetActiveAudioRoute(const AudioRouteInfo& route)
2332 {
2333         AppLogDebug("SetActiveAudioRoute");
2334         result r = __pAudioRouteManager->SetActiveAudioRoute(route);
2335
2336         return r;
2337 }
2338
2339 void
2340 VideoPlayerForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
2341 {
2342         BatteryLevel batteryLevel;
2343         bool isCharging = false;
2344
2345         AppLogDebug("OnUserEventReceivedN");
2346
2347         switch (requestId)
2348         {
2349         case REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED:
2350                 {
2351                         Battery::GetCurrentLevel(batteryLevel);
2352                         Battery::IsCharging(isCharging);
2353
2354                         if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
2355                         {
2356                                 bool frameActivated = GetFrameActivated();
2357
2358                                 if (isCharging == false && frameActivated == true)
2359                                 {
2360                                         OnFormBackRequested(*this);
2361                                 }
2362                         }
2363                 }
2364                 break;
2365
2366         default:
2367                 break;
2368         }
2369 }
2370
2371 void
2372 VideoPlayerForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId,
2373                         AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
2374 {
2375         AppLogDebug("OnAppControlCompleteResponseReceived : %d", appControlResult);
2376
2377         VideoPlayerApp* pVideoPlayerApp = static_cast<VideoPlayerApp*>(VideoPlayerApp::GetInstance());
2378         TryReturnVoid(pVideoPlayerApp != null, "pVideoPlayerApp is null");
2379         pVideoPlayerApp->SetFrameEnabled(true);
2380 }
2381
2382 void
2383 VideoPlayerForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
2384 {
2385         PlayerState playState = PLAYER_STATE_ERROR;
2386         result r = E_FAILURE;
2387
2388         __sliderMoved = true;
2389
2390         playState = __pVideoPlayerPresentationModel->GetState();
2391
2392         if (playState == PLAYER_STATE_PLAYING)
2393         {
2394                 result r = __pVideoPlayerPresentationModel->PausePlay();
2395                 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
2396                 __playingBeforeSlide = true;
2397         }
2398         else if (playState == PLAYER_STATE_PAUSED)
2399         {
2400                 long seekTime = value * (__pVideoPlayerPresentationModel->GetDuration() / MAX_PROGRESS_RANGE);
2401                 
2402                 if (__pVideoPlayerPresentationModel->GetSeekCompleted())
2403                 {
2404                         r = __pVideoPlayerPresentationModel->SeekTo(seekTime);
2405                         TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
2406                 }
2407
2408                 String currentTime;
2409                 DateTime dateTime;
2410
2411                 dateTime.AddSeconds(seekTime / MILLISECOND);
2412                 r = currentTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
2413                 TryReturnVoid(r == E_SUCCESS, "currentTime.Format() failed:%s", GetErrorMessage(r));
2414
2415                 __pCurrenTimeLabel->SetText(currentTime);
2416                 __pCurrenTimeLabel->Invalidate(true);
2417
2418         }
2419 }