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