2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file VpVideoPlayerForm.cpp
19 * @brief This is the implementation file for VideoPlayerForm class.
23 #include <FTelephony.h>
24 #include "VpSoundPathPopup.h"
25 #include "VpVideoPlayerApp.h"
26 #include "VpVideoPlayerForm.h"
27 #include "VpVideoPlayerPresentationModel.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Base::Runtime;
34 using namespace Tizen::Base::Utility;
35 using namespace Tizen::Content;
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Media;
38 using namespace Tizen::System;
39 using namespace Tizen::Telephony;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
44 static const int MIN_PROGRESS_RANGE = 0;
45 static const int MAX_PROGRESS_RANGE = 100;
47 static const int SHOW_CONTROL_DURATION = 5000;
49 static const int MILLISECOND = 1000;
50 static const int START_TIME = 0;
52 static const int X_BASE = 0;
53 static const int Y_BASE = 0;
54 static const int DIVIDE_BY_TWO = 2;
56 static const int X_NORMAL = 0;
57 static const int Y_NORMAL = 310;
58 static const int W_NORMAL = 720;
59 static const int H_NORMAL = 432;
61 static const int COLOR_THUMB_RED = 0;
62 static const int COLOR_THUMB_GREEN = 0;
63 static const int COLOR_THUMB_BLUE = 0;
64 static const int COLOR_THUMB_ALPHA = 0;
66 static const int MULTI_CONTENT_COUNT = 2;
68 static const int MESSAGEBOX_DISPLAY_TIME_3_SEC = 3000;
70 static const wchar_t* INIT_TIME = L"00:00:00";
72 static const RequestId REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU = 111;
73 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU = 112;
74 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU = 113;
75 static const RequestId REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED = 114;
77 void DestroyPresentationModelInstance(void)
79 delete VideoPlayerPresentationModel::GetInstance();
82 VideoPlayerForm::VideoPlayerForm(void)
83 : __pOverlayPanel(null)
84 , __screenMode(SCREEN_MODE_NORMAL)
85 , __pSoundPathPopup(null)
86 , __pUiControlTimer(null)
87 , __pAudioRouteManager(null)
89 , __pFunctionPanel(null)
90 , __pControllerPanel(null)
91 , __pPlayPauseButton(null)
92 , __pFastForwardButton(null)
93 , __pFastRewindButton(null)
95 , __pShareButton(null)
96 , __pScreenModeButton(null)
97 , __pRepeatModeButton(null)
98 , __pCurrenTimeLabel(null)
99 , __pTotalTimeLabel(null)
101 , __pContextMenuShare(null)
102 , __actionTouchLongPressed(false)
103 , __setPauseState(false)
104 , __isControlVisibleState(true)
105 , __audioRouteMode(0)
106 , __pVideoPlayerPresentationModel(null)
108 for (int count = 0; count < OUTPUT_AUDIO_ROUTE_MAX; ++count)
110 __availableAudioRoute[count] = false;
114 VideoPlayerForm::~VideoPlayerForm(void)
119 VideoPlayerForm::Initialize(void)
121 AppLogDebug("Initialize");
122 Construct(L"IDL_MAIN_FORM");
126 VideoPlayerForm::SetScreenMode(const ScreenMode mode, bool destroyOverlay)
128 result r = E_SUCCESS;
130 Rectangle clientRect = GetClientAreaBounds();
134 case SCREEN_MODE_NORMAL:
136 Rectangle rect = Rectangle(X_NORMAL, Y_NORMAL, W_NORMAL, H_NORMAL);
138 if ((clientRect.width - rect.width) <= X_BASE)
144 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
147 if ((clientRect.height - rect.height) <= Y_BASE)
153 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
156 if (destroyOverlay == true)
158 if (__pOverlayPanel != null)
160 __pOverlayPanel->RemoveTouchEventListener(*this);
161 RemoveControl(*__pOverlayPanel);
162 __pOverlayPanel = null;
165 __pOverlayPanel = new (std::nothrow) OverlayPanel();
166 r = __pOverlayPanel->Construct(rect);
167 TryCatch(r == E_SUCCESS, , "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
169 r = AddControl(*__pOverlayPanel);
170 TryCatch(r == E_SUCCESS, , "AddControl(*__pOverlayPanel) failed:%s", GetErrorMessage(r));
172 __pOverlayPanel->AddTouchEventListener(*this);
176 __pOverlayPanel->SetBounds(rect);
179 SetControlAlwaysAtBottom(*__pOverlayPanel, true);
181 __screenMode = SCREEN_MODE_NORMAL;
185 case SCREEN_MODE_FULL:
187 Rectangle rect = Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height);
188 AppLogDebug("SetScreenMode [%d] [%d]", rect.height, rect.width);
190 if (destroyOverlay == true)
192 if (__pOverlayPanel != null)
194 __pOverlayPanel->RemoveTouchEventListener(*this);
195 RemoveControl(*__pOverlayPanel);
196 __pOverlayPanel = null;
199 __pOverlayPanel = new (std::nothrow) OverlayPanel();
200 r = __pOverlayPanel->Construct(rect);
201 TryCatch(r == E_SUCCESS, , "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
203 r = AddControl(*__pOverlayPanel);
204 TryCatch(r == E_SUCCESS, , "AddControl(*__pOverlayPanel) failed:%s", GetErrorMessage(r));
206 __pOverlayPanel->AddTouchEventListener(*this);
210 __pOverlayPanel->SetBounds(rect);
212 SetControlAlwaysAtBottom(*__pOverlayPanel, true);
214 __screenMode = SCREEN_MODE_FULL;
218 case SCREEN_MODE_FIT:
220 Rectangle rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
221 __pVideoPlayerPresentationModel->GetMediaPathName());
223 if ((clientRect.width - rect.width) <= X_BASE)
229 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
232 if ((clientRect.height - rect.height) <= Y_BASE)
238 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
241 if (destroyOverlay == true)
243 if (__pOverlayPanel != null)
245 __pOverlayPanel->RemoveTouchEventListener(*this);
246 RemoveControl(*__pOverlayPanel);
247 __pOverlayPanel = null;
250 __pOverlayPanel = new (std::nothrow) OverlayPanel();
251 r = __pOverlayPanel->Construct(rect);
252 TryCatch(r == E_SUCCESS, , "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
254 r = AddControl(*__pOverlayPanel);
255 TryCatch(r == E_SUCCESS, , "AddControl(*__pOverlayPanel) failed:%s", GetErrorMessage(r));
257 __pOverlayPanel->AddTouchEventListener(*this);
261 __pOverlayPanel->SetBounds(rect);
263 SetControlAlwaysAtBottom(*__pOverlayPanel, true);
265 __screenMode = SCREEN_MODE_FIT;
276 RemoveControl(*__pOverlayPanel);
277 __pOverlayPanel = null;
278 __screenMode = SCREEN_MODE_NORMAL;
284 VideoPlayerForm::OnInitializing(void)
286 result r = E_FAILURE;
288 AppLogDebug("OnInitializing");
290 AddOrientationEventListener(*this);
291 AddKeyEventListener(*this);
292 AddTouchEventListener(*this);
294 __pAudioRouteManager = AudioRouteManager::GetInstance();
295 __pAudioRouteManager->SetAudioRouteEventListener(this);
297 r = SetScreenMode(SCREEN_MODE_NORMAL, true);
298 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
300 __pVideoPlayerPresentationModel = VideoPlayerPresentationModel::GetInstance();
301 TryCatch(__pVideoPlayerPresentationModel != null, r = E_SYSTEM, "__pVideoPlayerPresentationModel is null");
303 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
304 __pVideoPlayerPresentationModel->InitializePlayer();
306 __pVideoPlayerPresentationModel->SetVideoPlayerEventListener(this);
309 InitAudioRouteList();
311 r = InitializeHeader();
312 TryCatch(r == E_SUCCESS, , "InitializeHeader() failed : %s", GetErrorMessage(r));
313 r = InitializeFuncPanel();
314 TryCatch(r == E_SUCCESS, , "InitializeFuncPanel() failed : %s", GetErrorMessage(r));
315 r = InitializeController();
316 TryCatch(r == E_SUCCESS, , "InitializeController() failed : %s", GetErrorMessage(r));
321 DestroyPresentationModelInstance();
327 VideoPlayerForm::InitializeHeader(void)
329 result r = E_FAILURE;
331 AppLogDebug("InitializeHeader");
333 __pHeader = GetHeader();
334 TryCatch(__pHeader != null, r = E_SYSTEM, "__pHeader is null");
336 __pHeader->AddTouchEventListener(*this);
345 VideoPlayerForm::InitializeFuncPanel(void)
347 result r = E_FAILURE;
349 AppLogDebug("InitializeFuncPanel");
351 __pFunctionPanel = static_cast<Panel*>(GetControl(IDC_PANEL_FUNCTION));
352 TryCatch(__pFunctionPanel != null, r = E_SYSTEM, "__pFunctionPanel is null");
354 __pScreenModeButton = static_cast<Button*>(__pFunctionPanel->GetControl(IDC_BUTTON_SCREENMODE));
355 TryCatch(__pScreenModeButton != null, r = E_SYSTEM, "__pScreenModeButton is null");
356 __pScreenModeButton->SetActionId(IDA_BUTTON_FULLSCREEN);
357 __pScreenModeButton->AddActionEventListener(*this);
358 __pScreenModeButton->AddTouchEventListener(*this);
360 __pShareButton = static_cast<Button*>(__pFunctionPanel->GetControl(IDC_BUTTON_SHARE));
361 TryCatch(__pShareButton != null, r = E_SYSTEM, "__pShareButton is null");
362 __pShareButton->SetActionId(IDA_BUTTON_SHARE);
363 __pShareButton->AddActionEventListener(*this);
364 __pShareButton->AddTouchEventListener(*this);
373 VideoPlayerForm::InitializeController(void)
375 result r = E_FAILURE;
377 Bitmap* pSliderThumbNormalBitmap = null;
378 Bitmap* pSliderThumbPressedBitmap = null;
379 Bitmap* pSliderThumbDisableBitmap = null;
381 AppLogDebug("InitializeController");
383 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
385 __pControllerPanel = static_cast<Panel*>(GetControl(IDC_PANEL_CONTROLLER));
386 TryCatch(__pControllerPanel != null, r = E_SYSTEM, "__pControllerPanel is null");
388 __pRepeatModeButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_REPEATMODE));
389 TryCatch(__pRepeatModeButton != null, r = E_SYSTEM, "__pRepeatModeButton is null");
390 __pRepeatModeButton->SetActionId(IDA_BUTTON_REPEATMODE);
391 __pRepeatModeButton->AddActionEventListener(*this);
392 __pRepeatModeButton->AddTouchEventListener(*this);
394 __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_PLAY));
395 TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
396 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
397 __pPlayPauseButton->AddActionEventListener(*this);
398 __pPlayPauseButton->AddTouchEventListener(*this);
400 __pFastRewindButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_FASTREWIND));
401 TryCatch(__pFastRewindButton != null, r = E_SYSTEM, "__pFastRewindButton is null");
402 __pFastRewindButton ->SetActionId(IDA_BUTTON_FASTREWIND);
403 __pFastRewindButton ->AddActionEventListener(*this);
404 __pFastRewindButton->AddTouchEventListener(*this);
406 __pFastForwardButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_FASTFORWARD));
407 TryCatch(__pFastForwardButton != null, r = E_SYSTEM, "__pFastForwardButton is null");
408 __pFastForwardButton->SetActionId(IDA_BUTTON_FASTFORWARD);
409 __pFastForwardButton->AddActionEventListener(*this);
410 __pFastForwardButton->AddTouchEventListener(*this);
412 __pBackButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_BACK));
413 TryCatch(__pBackButton != null, r = E_SYSTEM, "__pBackButton is null");
414 __pBackButton->SetActionId(IDA_BUTTON_BACK);
415 __pBackButton->AddActionEventListener(*this);
416 __pBackButton->AddTouchEventListener(*this);
418 __pCurrenTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_LABEL_CURRENTTIME));
419 TryCatch(__pCurrenTimeLabel != null, r = E_SYSTEM, "__pCurrenTimeLabel is null");
420 __pCurrenTimeLabel->AddTouchEventListener(*this);
422 __pTotalTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_LABEL_FULLTIME));
423 TryCatch(__pTotalTimeLabel != null, r = E_SYSTEM, "__pTotalTimeLabel is null");
424 __pTotalTimeLabel->AddTouchEventListener(*this);
426 __pSlider = static_cast<Slider*>(__pControllerPanel->GetControl(IDC_SLIDER));
427 TryCatch(__pSlider != null, r = E_SYSTEM, "__pSlider is null");
428 __pSlider->SetEnabled(true);
429 __pSlider->SetRange(MIN_PROGRESS_RANGE, MAX_PROGRESS_RANGE);
430 __pSlider->SetValue(MIN_PROGRESS_RANGE);
431 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL,
432 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
433 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED,
434 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
435 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED,
436 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
438 pSliderThumbNormalBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle.png");
439 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *pSliderThumbNormalBitmap);
440 TryCatch(r == E_SUCCESS, , "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
442 pSliderThumbPressedBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle_press.png");
443 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *pSliderThumbPressedBitmap);
444 TryCatch(r == E_SUCCESS, , "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
446 pSliderThumbDisableBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle.png");
447 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_DISABLED, *pSliderThumbDisableBitmap);
448 TryCatch(r == E_SUCCESS, , "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
450 __pSlider->AddAdjustmentEventListener(*this);
451 __pSlider->AddTouchEventListener(*this);
454 delete pSliderThumbNormalBitmap;
455 delete pSliderThumbPressedBitmap;
456 delete pSliderThumbDisableBitmap;
462 VideoPlayerForm::OnTerminating(void)
464 AppLogDebug("OnTerminating");
466 DestroyPresentationModelInstance();
468 RemoveControl(*__pOverlayPanel);
469 __pOverlayPanel = null;
471 delete __pSoundPathPopup;
472 __pSoundPathPopup = null;
474 delete __pContextMenuShare;
475 __pContextMenuShare = null;
481 VideoPlayerForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
483 result r = E_FAILURE;
484 AppLogDebug("OnSceneActivatedN");
489 CheckLowBatteryStatus();
491 r = __pVideoPlayerPresentationModel->StartPlay();
492 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
494 GetTotalTime(totalTime);
495 AppLogDebug("totalTime [%ls]", totalTime.GetPointer());
497 __pTotalTimeLabel->SetText(totalTime);
498 __pTotalTimeLabel->Invalidate(true);
500 SetScreenModeButtonImage();
502 r = PowerManager::KeepScreenOnState(true, false);
503 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
507 VideoPlayerForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
509 result r = E_FAILURE;
511 AppLogDebug("OnSceneDeactivated");
513 r = __pVideoPlayerPresentationModel->PausePlay();
514 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
516 r = PowerManager::KeepScreenOnState(false);
517 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
521 VideoPlayerForm::OnPlayOpened(result r)
523 AppLogDebug("OnPlayOpened");
527 VideoPlayerForm::OnPlayEndOfClip(bool playNextContent, int repeatMode, int mediaCount)
529 result r = E_FAILURE;
531 Point point(X_BASE, Y_BASE);
532 Bitmap* pPlayBitmap = null;
534 AppLogDebug("OnPlayEndOfClip : %d", playNextContent);
536 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
538 if (__pSoundPathPopup != null)
540 if (__pSoundPathPopup->GetShowState() == true)
542 __pSoundPathPopup->SetShowState(false);
546 __pUiControlTimer->Cancel();
548 UpdateProgressBar(START_TIME);
550 __pCurrenTimeLabel->SetText(INIT_TIME);
551 __pCurrenTimeLabel->Invalidate(true);
553 pPlayBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_play.png");
554 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
556 __pPlayPauseButton->SetNormalBitmap(point ,*pPlayBitmap);
557 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
560 __pSlider->SetEnabled(false);
562 if (__pScreenModeButton->GetShowState() == true)
564 __pScreenModeButton->SetShowState(false);
569 case REPEAT_TYPE_OFF:
571 if (mediaCount < MULTI_CONTENT_COUNT)
573 r = PowerManager::KeepScreenOnState(false);
574 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
578 if (playNextContent == true)
580 SetScreenMode(SCREEN_MODE_NORMAL, true);
581 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
583 r = __pVideoPlayerPresentationModel->StartPlay();
584 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
586 SetScreenModeButtonImage();
588 __pSlider->SetEnabled(true);
590 if (__pScreenModeButton->GetShowState() == false)
592 __pScreenModeButton->SetShowState(true);
596 r = PowerManager::KeepScreenOnState(true, false);
597 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
602 case REPEAT_TYPE_ONE:
604 r = __pVideoPlayerPresentationModel->StartPlay();
605 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
607 __pSlider->SetEnabled(true);
609 SetScreenModeButtonImage();
610 if (__pScreenModeButton->GetShowState() == false)
612 __pScreenModeButton->SetShowState(true);
615 r = PowerManager::KeepScreenOnState(true, false);
616 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
620 case REPEAT_TYPE_ALL:
622 if (mediaCount < MULTI_CONTENT_COUNT)
624 r = __pVideoPlayerPresentationModel->StartPlay();
625 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
629 SetScreenMode(SCREEN_MODE_NORMAL, true);
630 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
632 r = __pVideoPlayerPresentationModel->StartPlay();
633 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
636 __pSlider->SetEnabled(true);
638 SetScreenModeButtonImage();
639 if (__pScreenModeButton->GetShowState() == false)
641 __pScreenModeButton->SetShowState(true);
644 r = PowerManager::KeepScreenOnState(true, false);
645 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
658 VideoPlayerForm::OnPlayBuffering(int percent)
660 AppLogDebug("OnPlayBuffering");
664 VideoPlayerForm::OnPlayErrorOccurred(PlayerErrorReason r)
666 MessageBox messageBox;
667 String messageBoxString;
669 AppResource* pAppResource = null;
671 AppLogDebug("OnPlayErrorOccurred [%d]", r);
675 case PLAYER_ERROR_INVALID_DATA:
677 if ((__pVideoPlayerPresentationModel->GetMediaPathName().EndsWith(L"flv") == true)
678 || (__pVideoPlayerPresentationModel->GetMediaPathName().EndsWith(L"FLV") == true))
680 pAppResource = Application::GetInstance()->GetAppResource();
681 pAppResource->GetString(IDS_COM_POP_UNSUPPORTED_FILE_TYPE, messageBoxString);
683 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_OK, MESSAGEBOX_DISPLAY_TIME_3_SEC);
684 messageBox.ShowAndWait(modalResult);
686 AppLogDebug("OnPlayErrorOccurred : pApp->Terminate");
687 UiApp* pApp = UiApp::GetInstance();
693 case PLAYER_ERROR_DEVICE_FAILED:
695 pAppResource = Application::GetInstance()->GetAppResource();
696 pAppResource->GetString(IDS_VPL_POP_UNABLE_TO_PLAY_VIDEO_ERROR_OCCURRED, messageBoxString);
698 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_OK, MESSAGEBOX_DISPLAY_TIME_3_SEC);
699 messageBox.ShowAndWait(modalResult);
701 AppLogDebug("OnPlayErrorOccurred : pApp->Terminate");
702 UiApp* pApp = UiApp::GetInstance();
713 VideoPlayerForm::OnPlayInterrupted(void)
715 AppLogDebug("OnPlayInterrupted");
719 VideoPlayerForm::OnPlayReleased(void)
721 AppLogDebug("OnPlayReleased");
725 VideoPlayerForm::OnActionPerformed(const Control& source, int actionId)
727 result r = E_FAILURE;
732 Point point(X_BASE, Y_BASE);
734 PlayerState playState = PLAYER_STATE_ERROR;
735 AppLogDebug("OnActionPerformed : %d", actionId);
737 playState = __pVideoPlayerPresentationModel->GetState();
739 Rectangle clientRect = GetClientAreaBounds();
743 case IDA_BUTTON_PLAY:
745 __setPauseState = false;
747 if (playState == PLAYER_STATE_ENDOFCLIP)
749 if (__pVideoPlayerPresentationModel->GetMediaCount() >= MULTI_CONTENT_COUNT)
751 int repeatMode = __pVideoPlayerPresentationModel->GetRepeatMode();
753 if (repeatMode == REPEAT_TYPE_OFF || repeatMode == REPEAT_TYPE_ALL)
755 SetScreenMode(SCREEN_MODE_NORMAL, true);
756 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
761 r = __pVideoPlayerPresentationModel->StartPlay();
762 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
764 __pSlider->SetEnabled(true);
766 SetScreenModeButtonImage();
768 if (__pScreenModeButton->GetShowState() == false)
770 __pScreenModeButton->SetShowState(true);
773 r = PowerManager::KeepScreenOnState(true, false);
774 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
778 case IDA_BUTTON_PAUSE:
780 __setPauseState = true;
782 r = __pVideoPlayerPresentationModel->PausePlay();
783 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
785 if (__pScreenModeButton->GetShowState() == true)
787 __pScreenModeButton->SetShowState(false);
790 r = PowerManager::KeepScreenOnState(false);
791 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
795 case IDA_BUTTON_FULLSCREEN:
797 if (playState == PLAYER_STATE_PLAYING)
799 __pUiControlTimer->Cancel();
800 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
807 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
808 __pVideoPlayerPresentationModel->GetMediaPathName());
810 switch (__screenMode)
812 case SCREEN_MODE_FIT:
814 r = SetScreenMode(SCREEN_MODE_FULL, true);
815 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
817 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
818 __pVideoPlayerPresentationModel->SetRenderingBuffer();
820 SetScreenModeButtonImage();
824 case SCREEN_MODE_FULL:
826 r = SetScreenMode(SCREEN_MODE_NORMAL, true);
827 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
829 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
830 __pVideoPlayerPresentationModel->SetRenderingBuffer();
832 SetScreenModeButtonImage();
836 case SCREEN_MODE_NORMAL:
838 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
840 r = SetScreenMode(SCREEN_MODE_FULL, true);
841 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
843 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
844 __pVideoPlayerPresentationModel->SetRenderingBuffer();
848 r = SetScreenMode(SCREEN_MODE_FIT, true);
849 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
851 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
852 __pVideoPlayerPresentationModel->SetRenderingBuffer();
854 SetScreenModeButtonImage();
864 case IDA_BUTTON_SOUNDPATH:
866 if (__pSoundPathPopup == null)
868 PlayerSoundPathPopupInit();
871 if (playState == PLAYER_STATE_PLAYING)
873 __pUiControlTimer->Cancel();
874 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
876 __pSoundPathPopup->ShowPopup(true);
880 case IDA_BUTTON_FASTFORWARD:
882 if (__actionTouchLongPressed == true)
884 __actionTouchLongPressed = false;
888 if (playState == PLAYER_STATE_PLAYING)
890 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
893 __pVideoPlayerPresentationModel->Forward();
897 case IDA_BUTTON_FASTREWIND:
899 if (__actionTouchLongPressed == true)
901 __actionTouchLongPressed = false;
905 if (playState == PLAYER_STATE_PLAYING)
907 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
910 __pVideoPlayerPresentationModel->Rewind();
914 case IDA_BUTTON_SHARE:
916 Point point((((GetClientAreaBounds().width - __pFunctionPanel->GetBounds().width) / DIVIDE_BY_TWO)
917 + (__pShareButton->GetBounds().width / DIVIDE_BY_TWO)),
918 __pFunctionPanel->GetBounds().y + __pFunctionPanel->GetBounds().height);
920 if (__pContextMenuShare != null)
922 delete __pContextMenuShare;
923 __pContextMenuShare = null;
926 __pContextMenuShare = new (std::nothrow) ContextMenu();
927 r = __pContextMenuShare->Construct(point, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD);
928 TryReturnVoid(r == E_SUCCESS, "__pContextMenuShare->Construct() failed:%s", GetErrorMessage(r));
931 Application::GetInstance()->GetAppResource()->GetString(L"IDS_COM_BODY_MESSAGE", str);
932 __pContextMenuShare->AddItem(str, IDA_CONTEXTMENU_MESSAGE);
933 Application::GetInstance()->GetAppResource()->GetString(L"IDS_COM_BODY_EMAIL", str);
934 __pContextMenuShare->AddItem(str, IDA_CONTEXTMENU_EMAIL);
935 __pContextMenuShare->AddActionEventListener(*this);
936 __pContextMenuShare->SetShowState(true);
937 __pContextMenuShare->Show();
939 if (playState == PLAYER_STATE_PLAYING)
941 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
946 case IDA_CONTEXTMENU_MESSAGE:
948 AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE);
949 if (pAppControl == null)
954 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
955 pDataList->Construct();
957 String mediaPathName = __pVideoPlayerPresentationModel->GetMediaPathName();
958 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS),
959 new (std::nothrow) String(mediaPathName));
960 AppLogDebug("AppControl Data : %ls", mediaPathName.GetPointer());
962 pAppControl->Start(null, null, pDataList, this);
964 if (pAppControl != null)
971 case IDA_CONTEXTMENU_EMAIL:
973 AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE);
974 if (pAppControl == null)
979 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
980 pDataList->Construct();
982 String mediaPathName = __pVideoPlayerPresentationModel->GetMediaPathName();
983 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_ATTACHMENTS),
984 new (std::nothrow) String(mediaPathName));
985 AppLogDebug("AppControl Data : %ls", mediaPathName.GetPointer());
987 pAppControl->Start(null, null, pDataList, this);
989 if (pAppControl != null)
996 case IDA_BUTTON_REPEATMODE:
998 int repeatMode = __pVideoPlayerPresentationModel->GetRepeatMode();
1002 case REPEAT_TYPE_OFF:
1004 SetRepeatButtonImage(REPEAT_TYPE_ONE);
1008 case REPEAT_TYPE_ONE:
1010 if (__pVideoPlayerPresentationModel->GetMediaCount() > 1)
1012 SetRepeatButtonImage(REPEAT_TYPE_ALL);
1016 SetRepeatButtonImage(REPEAT_TYPE_OFF);
1021 case REPEAT_TYPE_ALL:
1023 SetRepeatButtonImage(REPEAT_TYPE_OFF);
1031 if (playState == PLAYER_STATE_PLAYING)
1033 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1038 case IDA_BUTTON_BACK:
1040 Application::GetInstance()->Terminate();
1050 VideoPlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition,
1051 const TouchEventInfo& touchInfo)
1053 AppLogDebug("OnTouchPressed");
1054 __pUiControlTimer->Cancel();
1058 VideoPlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition,
1059 const TouchEventInfo& touchInfo)
1061 AppLogDebug("OnTouchReleased");
1063 PlayerState playState = PLAYER_STATE_ERROR;
1065 if ((&source == __pFastForwardButton
1066 || &source == __pFastRewindButton)
1067 && __actionTouchLongPressed == true)
1069 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1072 playState = __pVideoPlayerPresentationModel->GetState();
1074 if (playState == PLAYER_STATE_PLAYING)
1076 if (source.GetName() == L"IDL_MAIN_FORM"
1077 || source.GetHashCode() == __pOverlayPanel->GetHashCode()
1078 || source.GetHashCode() == __pHeader->GetHashCode())
1080 if (__isControlVisibleState == true)
1082 if (source.GetHashCode() == __pHeader->GetHashCode())
1084 if (__pUiControlTimer != null)
1086 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1098 if (__pUiControlTimer != null)
1100 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1108 VideoPlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition,
1109 const TouchEventInfo& touchInfo)
1111 AppLogDebug("OnTouchLongPressed");
1113 if (&source == __pFastForwardButton)
1115 __actionTouchLongPressed = true;
1117 if (__setPauseState == true)
1119 __pVideoPlayerPresentationModel->FastForward(false);
1123 __pVideoPlayerPresentationModel->FastForward(true);
1126 else if (&source == __pFastRewindButton)
1128 __actionTouchLongPressed = true;
1130 if (__setPauseState == true)
1132 __pVideoPlayerPresentationModel->FastRewind(false);
1136 __pVideoPlayerPresentationModel->FastRewind(true);
1142 VideoPlayerForm::OnTouchMoved(const Control& source, const Point& currentPosition,
1143 const TouchEventInfo& touchInfo)
1148 VideoPlayerForm::OnTouchFocusIn(const Control& source, const Point& currentPosition,
1149 const TouchEventInfo& touchInfo)
1154 VideoPlayerForm::OnTouchFocusOut(const Control& source, const Point& currentPosition,
1155 const TouchEventInfo& touchInfo)
1160 VideoPlayerForm::OnTimerExpired(Timer& timer)
1162 if (timer.GetHashCode() == __pUiControlTimer->GetHashCode())
1164 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1172 VideoPlayerForm::OnAdjustmentValueChanged(const Control& source, int adjustment)
1174 result r = E_FAILURE;
1177 AppLogDebug("OnAdjustmentValueChanged : %d", adjustment);
1179 if (adjustment >= MIN_PROGRESS_RANGE && adjustment <= MAX_PROGRESS_RANGE)
1181 seekTime = adjustment * (__pVideoPlayerPresentationModel->GetDuration() / MAX_PROGRESS_RANGE);
1183 r = __pVideoPlayerPresentationModel->SeekTo(seekTime);
1184 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
1186 UpdateProgressBar(adjustment);
1189 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1191 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1196 VideoPlayerForm::OnKeyPressed(const Control& source, KeyCode keyCode)
1198 AppLogDebug("OnKeyPressed Control : %ls, KeyCode : %d", source.GetName().GetPointer(), keyCode);
1200 if (keyCode == KEY_SIDE_UP || keyCode == KEY_SIDE_DOWN)
1207 VideoPlayerForm::OnKeyReleased(const Control& source, KeyCode keyCode)
1212 VideoPlayerForm::OnKeyLongPressed(const Control& source, KeyCode keyCode)
1217 VideoPlayerForm::UpdateProgressBar(const int currentPlayTime)
1219 TryReturnVoid(__pSlider, "__pSlider is null");
1221 __pSlider->SetValue(currentPlayTime);
1222 __pSlider->Invalidate(true);
1226 VideoPlayerForm::InitTimer(void)
1228 __pUiControlTimer = new (std::nothrow) Timer();
1229 __pUiControlTimer->Construct(*this);
1233 VideoPlayerForm::DeleteTimer(void)
1235 if (__pUiControlTimer != null)
1237 __pUiControlTimer->Cancel();
1238 delete __pUiControlTimer;
1239 __pUiControlTimer = null;
1244 VideoPlayerForm::SetPlayPauseButtonImage(PlayerState playState)
1246 result r = E_SUCCESS;
1248 Bitmap* pPlayBitmap = null;
1249 Bitmap* pPauseBitmap = null;
1250 Point point(X_BASE, Y_BASE);
1252 AppLogDebug("SetPlayPauseButtonImage : %d", playState);
1254 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1256 __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_PLAY));
1257 TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
1259 if (playState == PLAYER_STATE_PLAYING)
1261 pPauseBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_pause.png");
1262 TryCatch(pPauseBitmap != null, r = E_SYSTEM, "pPauseBitmap is null");
1264 __pPlayPauseButton->SetNormalBitmap(point, *pPauseBitmap);
1266 __pPlayPauseButton->SetActionId(IDA_BUTTON_PAUSE);
1267 __pPlayPauseButton->Invalidate(true);
1269 delete pPauseBitmap;
1273 pPlayBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_play.png");
1274 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
1276 __pPlayPauseButton->SetNormalBitmap(point, *pPlayBitmap);
1278 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
1279 __pPlayPauseButton->Invalidate(true);
1290 VideoPlayerForm::SetRepeatButtonImage(int repeatValue)
1292 AppLogDebug("SetRepeatButtonImage");
1293 Bitmap* pRepeatBitmap = null;
1294 Bitmap* pRepeatPressBitmap = null;
1296 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1298 switch (repeatValue)
1300 case REPEAT_TYPE_OFF:
1302 pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat.png");
1303 pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_press.png");
1307 case REPEAT_TYPE_ONE:
1309 pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_1.png");
1310 pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_1_press.png");
1314 case REPEAT_TYPE_ALL:
1316 pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_all.png");
1317 pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_all_press.png");
1324 __pRepeatModeButton->SetNormalBitmap(Point(X_BASE, Y_BASE), *pRepeatBitmap);
1325 __pRepeatModeButton->SetPressedBitmap(Point(X_BASE, Y_BASE), *pRepeatPressBitmap);
1326 __pVideoPlayerPresentationModel->SetRepeatMode(repeatValue);
1327 __pVideoPlayerPresentationModel->ChangeCurrentMediaIndex();
1329 delete pRepeatBitmap;
1330 delete pRepeatPressBitmap;
1334 VideoPlayerForm::SetScreenModeButtonImage(void)
1336 AppLogDebug("SetScreenModeButtonImage");
1338 Point point(X_BASE, Y_BASE);
1339 Bitmap* pBitmapScreenMode = null;
1341 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1343 String mediaPathName = __pVideoPlayerPresentationModel->GetMediaPathName();
1344 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(mediaPathName);
1346 switch (__screenMode)
1348 case SCREEN_MODE_NORMAL:
1350 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
1352 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03.png");
1353 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1354 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03_press.png");
1355 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1359 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_Function_icon_screenmode_press.png");
1360 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1361 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_Function_icon_screenmode_press.png");
1362 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1367 case SCREEN_MODE_FULL:
1369 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode02.png");
1370 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1371 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode02_press.png");
1372 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1376 case SCREEN_MODE_FIT:
1378 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03.png");
1379 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1380 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03_press.png");
1381 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1389 delete pBitmapScreenMode;
1390 pBitmapScreenMode = null;
1394 VideoPlayerForm::GetTotalTime(String& totalTime)
1396 result r = E_FAILURE;
1399 dateTime.AddSeconds(__pVideoPlayerPresentationModel->GetDuration() / MILLISECOND);
1400 r = totalTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1401 TryReturnVoid(r == E_SUCCESS, "totalTime.Format() failed:%s", GetErrorMessage(r));
1405 VideoPlayerForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1407 AppLogDebug("OnOrientationChanged");
1409 SetScreenMode(__screenMode, false);
1411 switch (orientationStatus)
1413 case ORIENTATION_STATUS_PORTRAIT:
1419 case ORIENTATION_STATUS_LANDSCAPE:
1421 case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
1433 VideoPlayerForm::PlayerSoundPathPopupInit(void)
1435 int tempAudioRouteMode = 0;
1436 int currentOutputDevice = 0;
1437 tempAudioRouteMode = __audioRouteMode;
1438 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1440 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1441 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1443 __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
1444 result r = __pSoundPathPopup->Construct(currentOutputDevice,
1445 __pAudioRouteManager->GetActiveBluetoothA2dpName(), tempAudioRouteMode);
1446 TryReturnVoid(r == E_SUCCESS, "__pSoundPathPopup->Construct() failed:%s", GetErrorMessage(r));
1450 VideoPlayerForm::CreateMessageBox(const String& title, const String& message, MessageBoxStyle style,
1451 unsigned long timeout)
1456 VideoPlayerForm::ShowControl(bool setShow)
1458 AppLogDebug("ShowControl");
1460 if (setShow == true)
1462 __pHeader->SetShowState(true);
1463 __pFunctionPanel->SetShowState(true);
1464 __pControllerPanel->SetShowState(true);
1465 __isControlVisibleState = true;
1469 __pHeader->SetShowState(false);
1470 __pFunctionPanel->SetShowState(false);
1471 __pControllerPanel->SetShowState(false);
1473 if (__pContextMenuShare != null)
1475 if (__pContextMenuShare->GetShowState() == true)
1477 __pContextMenuShare->SetShowState(false);
1481 __isControlVisibleState = false;
1486 VideoPlayerForm::ShowControlByFrameActivated(void)
1488 AppLogDebug("ShowControlByFrameActivated");
1491 CheckLowBatteryStatus();
1495 VideoPlayerForm::CancelTimerByFrameDeactivated(void)
1497 AppLogDebug("CancelTimerByFrameDeactivated");
1499 __pUiControlTimer->Cancel();
1500 __setPauseState = true;
1503 __pScreenModeButton->SetShowState(false);
1507 VideoPlayerForm::OnPlayContentChanged(const String& fileName)
1511 AppLogDebug("OnPlayContentChanged");
1513 GetTotalTime(totalTime);
1515 __pHeader->SetTitleText(fileName);
1516 __pHeader->Invalidate(true);
1518 __pTotalTimeLabel->SetText(totalTime);
1519 __pTotalTimeLabel->Invalidate(true);
1523 VideoPlayerForm::OnPlayTimeChanged(int currentProgressPos, String& playTime)
1525 AppLogDebug("OnPlayTimeChanged");
1527 __pSlider->SetValue(currentProgressPos);
1528 __pSlider->Invalidate(true);
1530 __pCurrenTimeLabel->SetText(playTime);
1531 __pCurrenTimeLabel->Invalidate(true);
1535 VideoPlayerForm::OnPlayStateChanged(PlayerState playState)
1537 AppLogDebug("OnPlayStateChanged");
1539 SetPlayPauseButtonImage(playState);
1541 if (playState == PLAYER_STATE_PLAYING)
1543 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1547 __pUiControlTimer->Cancel();
1553 VideoPlayerForm::CheckLowBatteryStatus(void)
1557 bool isCharging = false;
1558 BatteryLevel batteryLevel;
1560 AppLogDebug("CheckLowBatteryStatus");
1562 Battery::GetCurrentLevel(batteryLevel);
1563 Battery::IsCharging(isCharging);
1565 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
1567 if (isCharging == false)
1569 msgBox.Construct(L"", L"Unable to video play.Low battery", MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
1570 msgBox.ShowAndWait(result);
1574 case MSGBOX_RESULT_CLOSE:
1576 AppLogDebug("MSGBOX_RESULT_CLOSE");
1577 OnFormBackRequested(*this);
1589 VideoPlayerForm::CheckCallStatus(void)
1593 int modalResult = 0;
1594 result r = E_FAILURE;
1596 AppLogDebug("CheckCallStatus");
1598 CallManager* pCallManager = new (std::nothrow) CallManager();
1600 r = pCallManager->Construct();
1601 TryCatch(r == E_SUCCESS, , "pCallManager->Construct() failed : %s", GetErrorMessage(r));
1603 if (pCallManager->GetCurrentCallStatus() != CALL_STATUS_IDLE
1604 && pCallManager->GetCurrentCallStatus() != CALL_STATUS_UNDEFINED)
1606 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1607 pAppResource->GetString(L"IDS_VPL_BODY_UNABLE_TO_PLAY_VIDEO_DURING_CALL", dispString);
1609 msgBox.Construct(L"", dispString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
1610 msgBox.ShowAndWait(modalResult);
1612 switch (modalResult)
1614 case MSGBOX_RESULT_CLOSE:
1616 AppLogDebug("MSGBOX_RESULT_CLOSE");
1617 OnFormBackRequested(*this);
1627 delete pCallManager;
1631 VideoPlayerForm::OnFormBackRequested(Form& source)
1633 result r = E_FAILURE;
1635 AppLogDebug("OnFormBackRequested");
1637 UiApp* pApp = UiApp::GetInstance();
1638 TryReturnVoid(pApp != null, "pApp is null");
1640 r = pApp->Terminate();
1641 TryReturnVoid(r == E_SUCCESS, "Failed Terminate [%s]", GetErrorMessage(r));
1645 VideoPlayerForm::OnActiveAudioRouteChanged(const AudioRouteInfo& route)
1647 Color BtnColor(0, 0, 0, 0);
1648 int currentOutputAudioDevice = 0;
1649 ArrayList* pArgs = null;
1651 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1653 AppLogDebug("OnActiveAudioRouteChanged");
1655 switch (route.GetOutputAudioDevice())
1657 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
1659 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
1660 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1662 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1664 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1665 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1667 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
1669 if (__pSoundPathPopup != null)
1671 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1674 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1675 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1677 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
1683 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
1685 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
1686 &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1688 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1690 if (__pSoundPathPopup != null)
1692 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1695 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1697 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU,
1701 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
1702 &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1704 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
1706 if (__pSoundPathPopup != null)
1708 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1709 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1711 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1714 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1715 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
1717 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
1723 case OUTPUT_AUDIO_DEVICE_SPEAKER:
1725 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1726 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
1728 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
1730 if (__pSoundPathPopup != null)
1732 if (__pSoundPathPopup->GetShowState() == true)
1734 __pSoundPathPopup->SetShowState(false);
1738 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
1739 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
1741 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
1743 if (__pSoundPathPopup != null)
1745 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1746 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1748 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1751 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1752 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
1754 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
1766 VideoPlayerForm::OnAudioRouteAdded(const AudioRouteInfo& route)
1768 AppLogDebug("OnAudioRouteAdded");
1770 switch (route.GetOutputAudioDevice())
1772 case OUTPUT_AUDIO_DEVICE_NONE:
1774 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
1778 case OUTPUT_AUDIO_DEVICE_SPEAKER:
1780 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
1784 case OUTPUT_AUDIO_DEVICE_RECEIVER:
1786 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
1790 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
1792 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
1796 case OUTPUT_AUDIO_DEVICE_BT_SCO:
1798 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
1802 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
1804 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = true;
1814 VideoPlayerForm::OnAudioRouteRemoved(const AudioRouteInfo& route)
1816 ArrayList* pArgs = null;
1817 int currentOutputDevice = 0;
1818 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1820 AppLogDebug("OnAudioRouteRemoved");
1822 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1824 switch (route.GetOutputAudioDevice())
1826 case OUTPUT_AUDIO_DEVICE_NONE:
1828 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = false;
1832 case OUTPUT_AUDIO_DEVICE_SPEAKER:
1834 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = false;
1838 case OUTPUT_AUDIO_DEVICE_RECEIVER:
1840 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = false;
1844 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
1846 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = false;
1850 case OUTPUT_AUDIO_DEVICE_BT_SCO:
1852 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = false;
1856 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
1858 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = false;
1866 if (currentAudioRoute.GetOutputAudioDevice() != route.GetOutputAudioDevice())
1868 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
1870 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1871 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1873 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
1875 if (__pSoundPathPopup != null)
1877 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1880 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1881 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1883 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
1887 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
1889 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
1890 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1892 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1894 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
1895 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
1897 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1899 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
1900 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1902 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
1904 if (__pSoundPathPopup != null)
1906 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1907 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1909 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1912 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1913 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
1915 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
1919 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
1921 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
1922 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
1924 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
1926 if (__pSoundPathPopup != null)
1928 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1931 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1932 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1934 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
1937 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
1938 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
1940 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
1942 if (__pSoundPathPopup != null)
1944 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1945 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1947 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1950 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1951 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
1953 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
1956 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
1957 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
1959 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
1961 if (__pSoundPathPopup != null)
1963 if (__pSoundPathPopup->GetShowState() == true)
1965 __pSoundPathPopup->SetShowState(false);
1974 VideoPlayerForm::InitAudioRouteList(void)
1976 AppLogDebug("InitAudioRouteList");
1979 IList* availableAudioRouteList = null;
1980 AudioRouteInfo* tempRouteInfo = null;
1981 AudioRouteInfo availableRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1982 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1984 availableAudioRouteList = __pAudioRouteManager->GetAvailableAudioRouteListN();
1986 for (listCount = 0; listCount < availableAudioRouteList->GetCount(); ++listCount)
1988 tempRouteInfo = static_cast<AudioRouteInfo*>(availableAudioRouteList->GetAt(listCount));
1989 availableRouteInfo = *tempRouteInfo;
1991 if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_NONE)
1993 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
1995 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
1997 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
1999 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_RECEIVER)
2001 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2003 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2005 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2007 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_SCO)
2009 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2013 __availableAudioRoute[OUTPUT_AUDIO_DEVICE_BT_A2DP] = true;
2017 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2019 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2021 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2022 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2024 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2026 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2027 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2029 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2031 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2032 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2034 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2037 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2039 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2040 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2042 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2044 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2045 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2047 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2049 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2050 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2052 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2055 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2057 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2058 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2060 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2062 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2063 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2065 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2067 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2068 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2070 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2076 VideoPlayerForm::SetActiveAudioRoute(const AudioRouteInfo& route)
2078 AppLogDebug("SetActiveAudioRoute");
2079 result r = __pAudioRouteManager->SetActiveAudioRoute(route);
2085 VideoPlayerForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
2087 BatteryLevel batteryLevel;
2088 bool isCharging = false;
2090 AppLogDebug("OnUserEventReceivedN");
2094 case REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED:
2096 Battery::GetCurrentLevel(batteryLevel);
2097 Battery::IsCharging(isCharging);
2099 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
2101 if (isCharging == false)
2103 OnFormBackRequested(*this);
2115 VideoPlayerForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId,
2116 AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
2118 AppLogDebug("OnAppControlCompleteResponseReceived : %d", appControlResult);