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 VideoPlayerMainForm 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 MARGIN_PORTRAIT_SLIDER = 42;
57 static const int MARGIN_LANDSCAPE_SLIDER = 40;
59 static const int X_NORMAL = 0;
60 static const int Y_NORMAL = 310;
61 static const int W_NORMAL = 720;
62 static const int H_NORMAL = 432;
64 static const int WVGA_W_FULL = 1200;
65 static const int WVGA_X_FASTREWIND_BTN = 216;
66 static const int WVGA_X_PLAYPAUSE_BTN = 532;
67 static const int WVGA_X_BACK_BTN = 1049;
68 static const int WVGA_X_CURRENT_TIME_LABEL = 10;
69 static const int WVGA_X_TOTAL_TIME_LABEL = 1068;
70 static const int WVGA_X_SLIDER = 124;
71 static const int WVGA_X_VERTICAL_LEFT_LINE = 182;
72 static const int WVGA_X_VERTICAL_RIGHT_LINE = 1036;
74 static const int COLOR_THUMB_RED = 0;
75 static const int COLOR_THUMB_GREEN = 0;
76 static const int COLOR_THUMB_BLUE = 0;
77 static const int COLOR_THUMB_ALPHA = 0;
79 static const int MESSAGEBOX_DISPLAY_TIME_3_SEC = 3000;
81 static const wchar_t* INIT_TIME = L"00:00:00";
83 static const RequestId REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU = 111;
84 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU = 112;
85 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU = 113;
86 static const RequestId REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED = 114;
88 void DestroyPresentationModelInstance(void)
90 delete VideoPlayerPresentationModel::GetInstance();
93 VideoPlayerForm::VideoPlayerForm(void)
94 : __pOverlayRegion(null)
95 , __screenMode(SCREEN_MODE_NORMAL)
96 , __pSoundPathPopup(null)
97 , __pUiControlTimer(null)
98 , __pAudioRouteManager(null)
99 , __pPlayPauseButton(null)
100 , __pFastForwardButton(null)
101 , __pFastRewindButton(null)
102 , __pBackButton(null)
103 , __pButtonLeftItem(null)
104 , __pButtonRightItem(null)
106 , __pControlLabel(null)
107 , __pCurrenTimeLabel(null)
108 , __pFirstLineLabel(null)
109 , __pTotalTimeLabel(null)
110 , __pVerticalLeftLine(null)
111 , __pVerticalRightLine(null)
113 , __actionTouchLongPressed(false)
114 , __setPauseState(false)
115 , __isControlVisibleState(true)
116 , __audioRouteMode(0)
117 , __pVideoPlayerPresentationModel(null)
119 for (int count = 0; count < OUTPUT_AUDIO_ROUTE_MAX; ++count)
121 __availableAudioRoute[count] = false;
125 VideoPlayerForm::~VideoPlayerForm(void)
130 VideoPlayerForm::Initialize(void)
132 AppLogDebug("Initialize");
133 Construct(L"IDL_MAIN_FORM");
137 VideoPlayerForm::SetScreenMode(const ScreenMode mode)
139 result r = E_SUCCESS;
141 Rectangle clientRect = GetClientAreaBounds();
143 delete __pOverlayRegion;
144 __pOverlayRegion = null;
148 case SCREEN_MODE_NORMAL:
150 bool modified = false;
152 Rectangle rect = Rectangle(X_NORMAL, Y_NORMAL, W_NORMAL, H_NORMAL);
154 if ((clientRect.width - rect.width) <= X_BASE)
160 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
163 if ((clientRect.height - rect.height) <= Y_BASE)
169 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
172 __pOverlayRegion->EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_GREATER_THAN, rect, modified);
174 AppLogDebug("SetScreenMode [%d] [%d]", rect.height, rect.width);
176 __pOverlayRegion = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_NORMAL);
177 TryCatch(__pOverlayRegion != null, r = E_SYSTEM, "__pOverlayRegion is null");
179 __screenMode = SCREEN_MODE_NORMAL;
183 case SCREEN_MODE_FULL:
185 bool modified = false;
187 Rectangle rect = Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height);
189 __pOverlayRegion->EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_GREATER_THAN, rect, modified);
191 AppLogDebug("SetScreenMode [%d] [%d]", rect.height, rect.width);
193 __pOverlayRegion = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_NORMAL);
194 TryCatch(__pOverlayRegion != null, r = E_SYSTEM, "__pOverlayRegion is null");
196 __screenMode = SCREEN_MODE_FULL;
200 case SCREEN_MODE_FIT:
202 bool modified = false;
204 Rectangle rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
205 __pVideoPlayerPresentationModel->GetMediaPathName());
207 if ((clientRect.width - rect.width) <= X_BASE)
213 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
216 if ((clientRect.height - rect.height) <= Y_BASE)
222 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
225 __pOverlayRegion->EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_GREATER_THAN, rect, modified);
227 AppLogDebug("SetScreenMode [%d] [%d]", rect.height, rect.width);
229 __pOverlayRegion = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_NORMAL);
230 TryCatch(__pOverlayRegion != null, r = E_SYSTEM, "__pOverlayRegion is null");
232 __screenMode = SCREEN_MODE_FIT;
243 delete __pOverlayRegion;
244 __pOverlayRegion = null;
245 __screenMode = SCREEN_MODE_NORMAL;
251 VideoPlayerForm::OnInitializing(void)
253 result r = E_FAILURE;
255 Bitmap* pBitmapScreenMode = null;
256 Bitmap* pBitmapSoundPath = null;
257 Bitmap* pSliderThumbNormalBitmap = null;
258 Bitmap* pSliderThumbPressedBitmap = null;
259 Bitmap* pSliderThumbDisableBitmap = null;
261 AppLogDebug("OnInitializing");
263 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
265 AddOrientationEventListener(*this);
266 AddKeyEventListener(*this);
267 AddTouchEventListener(*this);
269 r = SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER, true);
270 TryCatch(r == E_SUCCESS, , "SetActionBarsTranslucent() failed:%s", GetErrorMessage(r));
272 __pAudioRouteManager = AudioRouteManager::GetInstance();
273 __pAudioRouteManager->SetAudioRouteEventListener(this);
275 SetScreenMode(SCREEN_MODE_NORMAL);
277 __pVideoPlayerPresentationModel = VideoPlayerPresentationModel::GetInstance();
278 TryCatch(__pVideoPlayerPresentationModel != null, r = E_SYSTEM, "__pVideoPlayerPresentationModel is null");
280 __pVideoPlayerPresentationModel->SetOverlayRegion(__pOverlayRegion);
281 __pVideoPlayerPresentationModel->InitializePlayer();
283 __pVideoPlayerPresentationModel->SetVideoPlayerEventListener(this);
287 InitAudioRouteList();
289 __pHeader = GetHeader();
291 __pButtonLeftItem = new (std::nothrow) ButtonItem();
292 __pButtonRightItem = new (std::nothrow) ButtonItem();
294 r = __pButtonLeftItem->Construct(BUTTON_ITEM_STYLE_ICON, IDA_BUTTON_FULLSCREEN);
295 TryCatch(r == E_SUCCESS, , "buttonLeftItem->Construct() Failed:%s", GetErrorMessage(r));
297 r = __pButtonRightItem->Construct(BUTTON_ITEM_STYLE_ICON, IDA_BUTTON_SOUNDPATH);
298 TryCatch(r == E_SUCCESS, , "buttonRightItem->Construct() Failed:%s", GetErrorMessage(r));
300 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
302 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
303 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
304 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
306 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
308 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
309 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
310 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
314 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
315 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
316 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
318 __pButtonLeftItem->SetActionId(IDA_BUTTON_FULLSCREEN);
319 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
321 pBitmapSoundPath = pAppResource->GetBitmapN(L"T01_icon_title_soundpath.png");
322 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapSoundPath);
323 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
325 __pButtonRightItem->SetActionId(IDA_BUTTON_SOUNDPATH);
326 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
329 __pHeader->AddActionEventListener(*this);
330 __pHeader->AddTouchEventListener(*this);
332 __pPlayPauseButton = static_cast<Button*>(GetControl("IDC_BUTTON_PLAY"));
333 TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
334 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
335 __pPlayPauseButton->AddActionEventListener(*this);
336 __pPlayPauseButton->AddTouchEventListener(*this);
338 __pFastRewindButton = static_cast<Button*>(GetControl("IDC_BUTTON_FASTREWIND"));
339 TryCatch(__pFastRewindButton != null, r = E_SYSTEM, "__pFastRewindButton is null");
340 __pFastRewindButton->SetActionId(IDA_BUTTON_FASTREWIND);
341 __pFastRewindButton->AddActionEventListener(*this);
342 __pFastRewindButton->AddTouchEventListener(*this);
344 __pFastForwardButton = static_cast<Button*>(GetControl("IDC_BUTTON_FASTFORWARD"));
345 TryCatch(__pFastForwardButton != null, r = E_SYSTEM, "__pFastForwardButton is null");
346 __pFastForwardButton->SetActionId(IDA_BUTTON_FASTFORWARD);
347 __pFastForwardButton->AddActionEventListener(*this);
348 __pFastForwardButton->AddTouchEventListener(*this);
350 __pBackButton = static_cast<Button*>(GetControl("IDC_BUTTON_BACK"));
351 TryCatch(__pBackButton != null, r = E_SYSTEM, "__pBackButton is null");
352 __pBackButton->SetActionId(IDA_BUTTON_BACK);
353 __pBackButton->AddActionEventListener(*this);
354 __pBackButton->AddTouchEventListener(*this);
356 __pSlider = static_cast<Slider*>(GetControl("IDC_SLIDER"));
357 TryCatch(__pSlider != null, r = E_SYSTEM, "__pSlider is null");
358 __pSlider->SetEnabled(true);
359 __pSlider->SetRange(MIN_PROGRESS_RANGE, MAX_PROGRESS_RANGE);
360 __pSlider->SetValue(MIN_PROGRESS_RANGE);
361 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL,
362 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
363 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED,
364 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
365 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED,
366 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
368 pSliderThumbNormalBitmap = pAppResource->GetBitmapN(L"T01_controller_progress_handle.png");
369 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *pSliderThumbNormalBitmap);
370 TryCatch(r == E_SUCCESS, , "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
372 pSliderThumbPressedBitmap = pAppResource->GetBitmapN(L"T01_controller_progress_handle_press.png");
373 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *pSliderThumbPressedBitmap);
374 TryCatch(r == E_SUCCESS, , "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
376 pSliderThumbDisableBitmap = pAppResource->GetBitmapN(L"T01_controller_progress_handle.png");
377 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_DISABLED, *pSliderThumbDisableBitmap);
378 TryCatch(r == E_SUCCESS, , "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
380 __pSlider->AddAdjustmentEventListener(*this);
381 __pSlider->AddTouchEventListener(*this);
383 __pCurrenTimeLabel = static_cast<Label*>(GetControl("IDC_LABEL_CURRENTTIME"));
384 TryCatch(__pCurrenTimeLabel != null, r = E_SYSTEM, "__pCurrenTimeLabel is null");
385 __pCurrenTimeLabel->AddTouchEventListener(*this);
387 __pCurrenTimeLabel->SetText(INIT_TIME);
389 __pTotalTimeLabel = static_cast<Label*>(GetControl("IDC_LABEL_FULLTIME"));
390 TryCatch(__pTotalTimeLabel != null, r = E_SYSTEM, "__pTotalTimeLabel is null");
391 __pTotalTimeLabel->AddTouchEventListener(*this);
393 __pTotalTimeLabel->SetText(INIT_TIME);
395 __pControlLabel = static_cast<Label*>(GetControl("IDC_LABEL_BOTTOM_CONTROL_PANEL"));
396 TryCatch(__pControlLabel != null, r = E_SYSTEM, "__pControlLabel is null");
398 __pFirstLineLabel = static_cast<Label*>(GetControl("IDC_LABEL_LINE1"));
399 TryCatch(__pFirstLineLabel != null, r = E_SYSTEM, "__pFirstLineLabel is null");
401 __pVerticalLeftLine = static_cast<Label*>(GetControl("IDC_LABEL_VERTICAL_LINE_LEFT"));
402 TryCatch(__pVerticalLeftLine != null, r = E_SYSTEM, "__pVerticalLeftLine is null");
404 __pVerticalRightLine = static_cast<Label*>(GetControl("IDC_LABEL_VERTICAL_LINE_RIGHT"));
405 TryCatch(__pVerticalRightLine != null, r = E_SYSTEM, "__pVerticalRightLine is null");
409 delete pBitmapScreenMode;
410 delete pBitmapSoundPath;
411 delete pSliderThumbNormalBitmap;
412 delete pSliderThumbPressedBitmap;
413 delete pSliderThumbDisableBitmap;
418 delete pBitmapScreenMode;
419 delete pBitmapSoundPath;
420 delete pSliderThumbNormalBitmap;
421 delete pSliderThumbPressedBitmap;
422 delete pSliderThumbDisableBitmap;
424 DestroyPresentationModelInstance();
430 VideoPlayerForm::OnTerminating(void)
432 AppLogDebug("OnTerminating");
434 DestroyPresentationModelInstance();
436 delete __pButtonLeftItem;
437 __pButtonLeftItem = null;
439 delete __pButtonRightItem;
440 __pButtonRightItem = null;
442 delete __pOverlayRegion;
443 __pOverlayRegion = null;
445 delete __pSoundPathPopup;
446 __pSoundPathPopup = null;
452 VideoPlayerForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
454 result r = E_FAILURE;
455 AppLogDebug("OnSceneActivatedN");
458 Bitmap* pBitmapScreenMode = null;
460 Rectangle rect(0, 0, 0, 0);
462 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
465 CheckLowBatteryStatus();
467 r = __pVideoPlayerPresentationModel->StartPlay();
468 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
470 GetTotalTime(totalTime);
472 AppLogDebug("totalTime [%ls]", totalTime.GetPointer());
474 __pTotalTimeLabel->SetText(totalTime);
475 __pTotalTimeLabel->Invalidate(true);
477 String mediaPathName = __pVideoPlayerPresentationModel->GetMediaPathName();
478 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(mediaPathName);
480 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
482 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
484 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
486 __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
487 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
491 __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
492 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
496 r = PowerManager::KeepScreenOnState(true, false);
497 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
499 delete pBitmapScreenMode;
500 pBitmapScreenMode = null;
504 VideoPlayerForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
506 result r = E_FAILURE;
508 AppLogDebug("OnSceneDeactivated");
510 r = __pVideoPlayerPresentationModel->PausePlay();
511 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
513 r = PowerManager::KeepScreenOnState(false);
514 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
518 VideoPlayerForm::OnPlayOpened(result r)
520 AppLogDebug("OnPlayOpened");
524 VideoPlayerForm::OnPlayEndOfClip(bool playNextContent)
526 result r = E_FAILURE;
528 Bitmap* pPlayBitmap = null;
529 Bitmap* pBitmapScreenMode = null;
530 Bitmap* pBitmapSoundPath = null;
532 AppLogDebug("OnPlayEndOfClip : %d", playNextContent);
534 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
536 if (__pSoundPathPopup != null)
538 if (__pSoundPathPopup->GetShowState() == true)
540 __pSoundPathPopup->SetShowState(false);
544 __pUiControlTimer->Cancel();
546 UpdateProgressBar(START_TIME);
548 __pCurrenTimeLabel->SetText(INIT_TIME);
549 __pCurrenTimeLabel->Invalidate(true);
551 pPlayBitmap = pAppResource->GetBitmapN(L"T01_icon_toolbar_play.png");
552 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
553 __pPlayPauseButton->SetNormalBackgroundBitmap(*pPlayBitmap);
557 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
559 __pSlider->SetEnabled(false);
561 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
563 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
564 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
566 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
570 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
571 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
573 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
576 if (playNextContent == true)
578 SetScreenMode(SCREEN_MODE_NORMAL);
579 __pVideoPlayerPresentationModel->SetOverlayRegion(__pOverlayRegion);
580 __pVideoPlayerPresentationModel->InitializePlayer();
582 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
584 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
585 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
586 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
588 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
590 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
591 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
592 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
596 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
597 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
598 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
600 __pButtonLeftItem->SetActionId(IDA_BUTTON_FULLSCREEN);
601 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
603 pBitmapSoundPath = pAppResource->GetBitmapN(L"T01_icon_title_soundpath.png");
604 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapSoundPath);
605 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
607 __pButtonRightItem->SetActionId(IDA_BUTTON_SOUNDPATH);
608 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
611 __pSlider->SetEnabled(true);
613 r = __pVideoPlayerPresentationModel->StartPlay();
614 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
616 r = PowerManager::KeepScreenOnState(true, false);
617 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
621 r = PowerManager::KeepScreenOnState(false);
622 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
631 VideoPlayerForm::OnPlayBuffering(int percent)
633 AppLogDebug("OnPlayBuffering");
637 VideoPlayerForm::OnPlayErrorOccurred(PlayerErrorReason r)
639 MessageBox messageBox;
640 String messageBoxString;
642 AppResource* pAppResource = null;
644 AppLogDebug("OnPlayErrorOccurred [%d]", r);
648 case PLAYER_ERROR_INVALID_DATA:
650 if ((__pVideoPlayerPresentationModel->GetMediaPathName().EndsWith(L"flv") == true)
651 || (__pVideoPlayerPresentationModel->GetMediaPathName().EndsWith(L"FLV") == true))
653 pAppResource = Application::GetInstance()->GetAppResource();
654 pAppResource->GetString(IDS_COM_POP_UNSUPPORTED_FILE_TYPE, messageBoxString);
656 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_OK, MESSAGEBOX_DISPLAY_TIME_3_SEC);
657 messageBox.ShowAndWait(modalResult);
659 AppLogDebug("OnPlayErrorOccurred : pApp->Terminate");
660 UiApp* pApp = UiApp::GetInstance();
666 case PLAYER_ERROR_DEVICE_FAILED:
668 pAppResource = Application::GetInstance()->GetAppResource();
669 pAppResource->GetString(IDS_VPL_POP_UNABLE_TO_PLAY_VIDEO_ERROR_OCCURRED, messageBoxString);
671 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_OK, MESSAGEBOX_DISPLAY_TIME_3_SEC);
672 messageBox.ShowAndWait(modalResult);
674 AppLogDebug("OnPlayErrorOccurred : pApp->Terminate");
675 UiApp* pApp = UiApp::GetInstance();
686 VideoPlayerForm::OnPlayInterrupted(void)
688 AppLogDebug("OnPlayInterrupted");
692 VideoPlayerForm::OnPlayReleased(void)
694 AppLogDebug("OnPlayReleased");
698 VideoPlayerForm::GetOverlayRegion(void)
700 return __pOverlayRegion;
704 VideoPlayerForm::OnActionPerformed(const Control& source, int actionId)
706 result r = E_FAILURE;
711 Bitmap* pBitmapScreenMode = null;
713 PlayerState playState = PLAYER_STATE_ERROR;
714 AppLogDebug("OnActionPerformed : %d", actionId);
716 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
718 playState = __pVideoPlayerPresentationModel->GetState();
720 Rectangle clientRect = GetClientAreaBounds();
721 Rectangle rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
722 __pVideoPlayerPresentationModel->GetMediaPathName());
726 case IDA_BUTTON_PLAY:
728 __setPauseState = false;
730 if ((__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_ENDOFCLIP))
732 if (__pVideoPlayerPresentationModel->GetCurrentMediaIndex() != __pVideoPlayerPresentationModel->GetPreviousMediaIndex())
734 SetScreenMode(SCREEN_MODE_NORMAL);
735 __pVideoPlayerPresentationModel->SetOverlayRegion(__pOverlayRegion);
737 __pVideoPlayerPresentationModel->InitializePlayer();
740 r = __pVideoPlayerPresentationModel->StartPlay();
741 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->StartPlay() failed:%s",
744 __pSlider->SetEnabled(true);
746 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
748 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
750 if (__screenMode == SCREEN_MODE_NORMAL)
752 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
754 else if (__screenMode == SCREEN_MODE_FULL)
756 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
761 if (__screenMode == SCREEN_MODE_FIT)
763 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
765 else if (__screenMode == SCREEN_MODE_NORMAL)
767 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
771 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
775 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
776 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
778 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
782 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
784 if (__screenMode == SCREEN_MODE_NORMAL)
786 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
788 else if (__screenMode == SCREEN_MODE_FULL)
790 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
795 if (__screenMode == SCREEN_MODE_FIT)
797 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
799 else if (__screenMode == SCREEN_MODE_NORMAL)
801 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
805 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
809 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
810 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
812 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
815 r = PowerManager::KeepScreenOnState(true, false);
816 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
818 delete pBitmapScreenMode;
819 pBitmapScreenMode = null;
823 case IDA_BUTTON_PAUSE:
825 __setPauseState = true;
827 r = __pVideoPlayerPresentationModel->PausePlay();
828 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->PausePlay() failed:%s",
831 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
833 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
834 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
836 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
840 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
841 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
843 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
846 r = PowerManager::KeepScreenOnState(false);
847 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
851 case IDA_BUTTON_FULLSCREEN:
853 if (playState != PLAYER_STATE_PLAYING)
858 if (playState == PLAYER_STATE_PLAYING)
860 __pUiControlTimer->Cancel();
861 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
864 switch (__screenMode)
866 case SCREEN_MODE_FIT:
868 r = SetScreenMode(SCREEN_MODE_FULL);
869 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
871 __pVideoPlayerPresentationModel->SetOverlayRegion(__pOverlayRegion);
872 __pVideoPlayerPresentationModel->SetRenderingBuffer();
874 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
876 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
878 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
879 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s", GetErrorMessage(r));
881 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
885 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
886 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s", GetErrorMessage(r));
888 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
891 delete pBitmapScreenMode;
892 pBitmapScreenMode = null;
896 case SCREEN_MODE_FULL:
898 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
900 r = SetScreenMode(SCREEN_MODE_NORMAL);
901 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
903 __pVideoPlayerPresentationModel->SetOverlayRegion(__pOverlayRegion);
904 __pVideoPlayerPresentationModel->SetRenderingBuffer();
906 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
908 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
910 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
911 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s",
914 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
918 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
919 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s",
922 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
927 r = SetScreenMode(SCREEN_MODE_NORMAL);
928 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
930 __pVideoPlayerPresentationModel->SetOverlayRegion(__pOverlayRegion);
931 __pVideoPlayerPresentationModel->SetRenderingBuffer();
933 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
935 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
937 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
938 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s",
941 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
945 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
946 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s",
949 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
953 delete pBitmapScreenMode;
954 pBitmapScreenMode = null;
958 case SCREEN_MODE_NORMAL:
960 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
962 r = SetScreenMode(SCREEN_MODE_FULL);
963 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
965 __pVideoPlayerPresentationModel->SetOverlayRegion(__pOverlayRegion);
966 __pVideoPlayerPresentationModel->SetRenderingBuffer();
968 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
970 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
972 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
973 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s",
976 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
980 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
981 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s",
984 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
989 r = SetScreenMode(SCREEN_MODE_FIT);
990 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
992 __pVideoPlayerPresentationModel->SetOverlayRegion(__pOverlayRegion);
993 __pVideoPlayerPresentationModel->SetRenderingBuffer();
995 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
997 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
999 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1000 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s",
1001 GetErrorMessage(r));
1003 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1007 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1008 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s",
1009 GetErrorMessage(r));
1011 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1015 delete pBitmapScreenMode;
1016 pBitmapScreenMode = null;
1026 case IDA_BUTTON_SOUNDPATH:
1028 if (__pSoundPathPopup == null)
1030 PlayerSoundPathPopupInit();
1033 if (playState == PLAYER_STATE_PLAYING)
1035 __pUiControlTimer->Cancel();
1036 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1038 __pSoundPathPopup->ShowPopup(true);
1042 case IDA_BUTTON_FASTFORWARD:
1044 if (__actionTouchLongPressed == true)
1046 __actionTouchLongPressed = false;
1050 if (playState == PLAYER_STATE_PLAYING)
1052 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1055 __pVideoPlayerPresentationModel->Forward();
1059 case IDA_BUTTON_FASTREWIND:
1061 if (__actionTouchLongPressed == true)
1063 __actionTouchLongPressed = false;
1067 if (playState == PLAYER_STATE_PLAYING)
1069 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1072 __pVideoPlayerPresentationModel->Rewind();
1076 case IDA_BUTTON_BACK:
1078 Application::GetInstance()->Terminate();
1087 delete pBitmapScreenMode;
1088 pBitmapScreenMode = null;
1092 VideoPlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition,
1093 const TouchEventInfo& touchInfo)
1095 AppLogDebug("OnTouchPressed");
1096 __pUiControlTimer->Cancel();
1100 VideoPlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition,
1101 const TouchEventInfo& touchInfo)
1103 result r = E_FAILURE;
1105 PlayerState playState = PLAYER_STATE_ERROR;
1107 AppLogDebug("OnTouchReleased");
1109 ChangedControlPos();
1111 if ((&source == __pFastForwardButton
1112 || &source == __pFastRewindButton)
1113 && __actionTouchLongPressed == true)
1115 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1118 playState = __pVideoPlayerPresentationModel->GetState();
1120 if (playState != PLAYER_STATE_PAUSED)
1122 if (source.GetName() == L"IDL_MAIN_FORM" && playState == PLAYER_STATE_PLAYING)
1124 if (__isControlVisibleState == true)
1132 r = __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1133 TryReturnVoid(r == E_SUCCESS, "__pUiControlTimer->Start() failed:%s", GetErrorMessage(r));
1140 VideoPlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition,
1141 const TouchEventInfo& touchInfo)
1143 AppLogDebug("OnTouchLongPressed");
1145 if (&source == __pFastForwardButton)
1147 __actionTouchLongPressed = true;
1149 if (__setPauseState == true)
1151 __pVideoPlayerPresentationModel->FastForward(false);
1155 __pVideoPlayerPresentationModel->FastForward(true);
1158 else if (&source == __pFastRewindButton)
1160 __actionTouchLongPressed = true;
1162 if (__setPauseState == true)
1164 __pVideoPlayerPresentationModel->FastRewind(false);
1168 __pVideoPlayerPresentationModel->FastRewind(true);
1174 VideoPlayerForm::OnTouchMoved(const Control& source, const Point& currentPosition,
1175 const TouchEventInfo& touchInfo)
1180 VideoPlayerForm::OnTouchFocusIn(const Control& source, const Point& currentPosition,
1181 const TouchEventInfo& touchInfo)
1186 VideoPlayerForm::OnTouchFocusOut(const Control& source, const Point& currentPosition,
1187 const TouchEventInfo& touchInfo)
1192 VideoPlayerForm::OnTimerExpired(Timer& timer)
1194 if (timer.GetHashCode() == __pUiControlTimer->GetHashCode())
1196 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1204 VideoPlayerForm::OnAdjustmentValueChanged(const Control& source, int adjustment)
1206 result r = E_FAILURE;
1209 AppLogDebug("OnAdjustmentValueChanged : %d", adjustment);
1211 if (adjustment >= MIN_PROGRESS_RANGE && adjustment < MAX_PROGRESS_RANGE)
1213 seekTime = adjustment * (__pVideoPlayerPresentationModel->GetDuration() / MAX_PROGRESS_RANGE);
1215 r = __pVideoPlayerPresentationModel->SeekTo(seekTime);
1216 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
1218 UpdateProgressBar(adjustment);
1221 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1223 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1228 VideoPlayerForm::OnKeyPressed(const Control& source, KeyCode keyCode)
1230 AppLogDebug("OnKeyPressed Control : %ls, KeyCode : %d", source.GetName().GetPointer(), keyCode);
1232 if (keyCode == KEY_SIDE_UP || keyCode == KEY_SIDE_DOWN)
1239 VideoPlayerForm::OnKeyReleased(const Control& source, KeyCode keyCode)
1244 VideoPlayerForm::OnKeyLongPressed(const Control& source, KeyCode keyCode)
1249 VideoPlayerForm::UpdateProgressBar(const int currentPlayTime)
1251 TryReturnVoid(__pSlider, "__pSlider is null");
1253 __pSlider->SetValue(currentPlayTime);
1254 __pSlider->Invalidate(true);
1258 VideoPlayerForm::InitTimer(void)
1260 __pUiControlTimer = new (std::nothrow) Timer();
1261 __pUiControlTimer->Construct(*this);
1265 VideoPlayerForm::DeleteTimer(void)
1267 if (__pUiControlTimer != null)
1269 __pUiControlTimer->Cancel();
1270 delete __pUiControlTimer;
1271 __pUiControlTimer = null;
1276 VideoPlayerForm::SetPlayPauseButtonImage(PlayerState playState)
1278 result r = E_SUCCESS;
1280 Bitmap* pPlayBitmap = null;
1281 Bitmap* pPauseBitmap = null;
1283 AppLogDebug("SetPlayPauseButtonImage : %d", playState);
1285 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1287 __pPlayPauseButton = static_cast<Button*>(GetControl("IDC_BUTTON_PLAY"));
1288 TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
1290 if (playState == PLAYER_STATE_PLAYING)
1292 pPauseBitmap = pAppResource->GetBitmapN(L"T01_icon_toolbar_pause.png");
1293 TryCatch(pPauseBitmap != null, r = E_SYSTEM, "pPauseBitmap is null");
1295 __pPlayPauseButton->SetNormalBackgroundBitmap(*pPauseBitmap);
1297 __pPlayPauseButton->SetActionId(IDA_BUTTON_PAUSE);
1298 __pPlayPauseButton->Invalidate(true);
1300 delete pPauseBitmap;
1304 pPlayBitmap = pAppResource->GetBitmapN(L"T01_icon_toolbar_play.png");
1305 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
1307 __pPlayPauseButton->SetNormalBackgroundBitmap(*pPlayBitmap);
1309 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
1310 __pPlayPauseButton->Invalidate(true);
1322 VideoPlayerForm::GetTotalTime(String& totalTime)
1324 result r = E_FAILURE;
1327 dateTime.AddSeconds(__pVideoPlayerPresentationModel->GetDuration() / MILLISECOND);
1328 r = totalTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1329 TryReturnVoid(r == E_SUCCESS, "totalTime.Format() failed:%s", GetErrorMessage(r));
1333 VideoPlayerForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1335 AppLogDebug("OnOrientationChanged");
1337 SetScreenMode(__screenMode);
1339 __pVideoPlayerPresentationModel->SetOverlayRegion(__pOverlayRegion);
1340 __pVideoPlayerPresentationModel->SetRenderingBuffer();
1342 switch (orientationStatus)
1344 case ORIENTATION_STATUS_PORTRAIT:
1346 ChangedControlPos();
1350 case ORIENTATION_STATUS_LANDSCAPE:
1352 case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
1354 ChangedControlPos();
1364 VideoPlayerForm::PlayerSoundPathPopupInit(void)
1366 int tempAudioRouteMode = 0;
1367 int currentOutputDevice = 0;
1368 tempAudioRouteMode = __audioRouteMode;
1369 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1371 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1372 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1374 __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
1375 result r = __pSoundPathPopup->Construct(currentOutputDevice,
1376 __pAudioRouteManager->GetActiveBluetoothA2dpName(), tempAudioRouteMode);
1377 TryReturnVoid(r == E_SUCCESS, "__pSoundPathPopup->Construct() failed:%s", GetErrorMessage(r));
1381 VideoPlayerForm::CreateMessageBox(const String& title, const String& message, MessageBoxStyle style,
1382 unsigned long timeout)
1387 VideoPlayerForm::ShowControl(bool setShow)
1389 AppLogDebug("ShowControl");
1391 if (setShow == true)
1393 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR|FORM_ACTION_BAR_HEADER, true);
1395 __pPlayPauseButton->SetShowState(true);
1396 __pFastForwardButton->SetShowState(true);
1397 __pFastRewindButton->SetShowState(true);
1398 __pBackButton->SetShowState(true);
1399 __pCurrenTimeLabel->SetShowState(true);
1400 __pTotalTimeLabel->SetShowState(true);
1401 __pSlider->SetShowState(true);
1402 __pControlLabel->SetShowState(true);
1403 __pFirstLineLabel->SetShowState(true);
1404 __pVerticalLeftLine->SetShowState(true);
1405 __pVerticalRightLine->SetShowState(true);
1407 __isControlVisibleState = true;
1413 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR|FORM_ACTION_BAR_HEADER, false);
1415 __pPlayPauseButton->SetShowState(false);
1416 __pFastForwardButton->SetShowState(false);
1417 __pFastRewindButton->SetShowState(false);
1418 __pBackButton->SetShowState(false);
1419 __pCurrenTimeLabel->SetShowState(false);
1420 __pTotalTimeLabel->SetShowState(false);
1421 __pSlider->SetShowState(false);
1422 __pControlLabel->SetShowState(false);
1423 __pFirstLineLabel->SetShowState(false);
1424 __pVerticalLeftLine->SetShowState(false);
1425 __pVerticalRightLine->SetShowState(false);
1427 __isControlVisibleState = false;
1432 VideoPlayerForm::ChangedControlPos(void)
1434 Rectangle controlRect(0, 0, 0, 0);
1435 Rectangle posRect(0, 0, 0, 0);
1437 result r = E_FAILURE;
1439 AppLogDebug("ChangedControlPos");
1441 if (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
1443 controlRect = __pControlLabel->GetBounds();
1444 posRect.y = GetClientAreaBounds().height - controlRect.height;
1445 controlRect.y = posRect.y;
1447 r = __pControlLabel->SetBounds(controlRect);
1448 TryReturnVoid(r == E_SUCCESS, "__pControlLabel->SetBounds() failed:%s", GetErrorMessage(r));
1450 controlRect = __pFastRewindButton->GetBounds();
1451 posRect.y = GetClientAreaBounds().height - controlRect.height;
1452 controlRect.y = posRect.y;
1454 r = __pFastRewindButton->SetBounds(controlRect);
1455 TryReturnVoid(r == E_SUCCESS, "__pFastRewindButton->SetBounds() failed:%s", GetErrorMessage(r));
1457 controlRect = __pPlayPauseButton->GetBounds();
1458 posRect.y = GetClientAreaBounds().height - controlRect.height;
1459 controlRect.y = posRect.y;
1461 r = __pPlayPauseButton->SetBounds(controlRect);
1462 TryReturnVoid(r == E_SUCCESS, "__pPlayPauseButton->SetBounds() failed:%s", GetErrorMessage(r));
1464 controlRect = __pFastForwardButton->GetBounds();
1465 posRect.y = GetClientAreaBounds().height - controlRect.height;
1466 controlRect.y = posRect.y;
1468 r = __pFastForwardButton->SetBounds(controlRect);
1469 TryReturnVoid(r == E_SUCCESS, "__pFastForwardButton->SetBounds() failed:%s", GetErrorMessage(r));
1471 controlRect = __pBackButton->GetBounds();
1472 posRect.y = GetClientAreaBounds().height - controlRect.height;
1473 controlRect.y = posRect.y;
1475 r = __pBackButton->SetBounds(controlRect);
1476 TryReturnVoid(r == E_SUCCESS, "__pBackButton->SetBounds() failed:%s", GetErrorMessage(r));
1478 Rectangle controlLabelRect = __pControlLabel->GetBounds();
1479 controlRect = __pFirstLineLabel->GetBounds();
1480 posRect.y = GetClientAreaBounds().height - controlLabelRect.height - controlRect.height;
1481 controlRect.y = posRect.y;
1483 r = __pFirstLineLabel->SetBounds(controlRect);
1484 TryReturnVoid(r == E_SUCCESS, "__pFirstLineLabel->SetBounds() failed:%s", GetErrorMessage(r));
1486 controlRect = __pCurrenTimeLabel->GetBounds();
1487 posRect.y = GetClientAreaBounds().height - controlLabelRect.height + MARGIN_PORTRAIT_SLIDER;
1488 controlRect.y = posRect.y;
1490 r = __pCurrenTimeLabel->SetBounds(controlRect);
1491 TryReturnVoid(r == E_SUCCESS, "__pCurrenTimeLabel->SetBounds() failed:%s", GetErrorMessage(r));
1493 controlRect = __pTotalTimeLabel->GetBounds();
1494 posRect.y = GetClientAreaBounds().height - controlLabelRect.height + MARGIN_PORTRAIT_SLIDER;
1495 controlRect.y = posRect.y;
1497 r = __pTotalTimeLabel->SetBounds(controlRect);
1498 TryReturnVoid(r == E_SUCCESS, "__pTotalTimeLabel->SetBounds() failed:%s", GetErrorMessage(r));
1500 controlRect = __pSlider->GetBounds();
1501 posRect.y = GetClientAreaBounds().height - controlLabelRect.height;
1502 controlRect.y = posRect.y;
1504 r = __pSlider->SetBounds(controlRect);
1505 TryReturnVoid(r == E_SUCCESS, "__pSlider->SetBounds() failed:%s", GetErrorMessage(r));
1507 controlRect = __pVerticalLeftLine->GetBounds();
1508 posRect.y = GetClientAreaBounds().height - controlRect.height;
1509 controlRect.y = posRect.y;
1511 r = __pVerticalLeftLine->SetBounds(controlRect);
1512 TryReturnVoid(r == E_SUCCESS, "__pVerticalLeftLine->SetBounds() failed:%s", GetErrorMessage(r));
1514 controlRect = __pVerticalRightLine->GetBounds();
1515 posRect.y = GetClientAreaBounds().height - controlRect.height;
1516 controlRect.y = posRect.y;
1518 r = __pVerticalRightLine->SetBounds(controlRect);
1519 TryReturnVoid(r == E_SUCCESS, "__pVerticalRightLine->SetBounds() failed:%s", GetErrorMessage(r));
1521 else if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE
1522 || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1524 if (GetClientAreaBounds().width <= WVGA_W_FULL)
1526 controlRect = __pControlLabel->GetBounds();
1527 posRect.y = GetClientAreaBounds().height - controlRect.height;
1528 controlRect.y = posRect.y;
1530 r = __pControlLabel->SetBounds(controlRect);
1531 TryReturnVoid(r == E_SUCCESS, "__pControlLabel->SetBounds() failed:%s", GetErrorMessage(r));
1533 controlRect = __pFastRewindButton->GetBounds();
1534 posRect.x = WVGA_X_FASTREWIND_BTN;
1535 posRect.y = GetClientAreaBounds().height - controlRect.height;
1536 controlRect.x = posRect.x;
1537 controlRect.y = posRect.y;
1539 r = __pFastRewindButton->SetBounds(controlRect);
1540 TryReturnVoid(r == E_SUCCESS, "__pFastRewindButton->SetBounds() failed:%s", GetErrorMessage(r));
1542 controlRect = __pPlayPauseButton->GetBounds();
1543 posRect.x = WVGA_X_PLAYPAUSE_BTN;
1544 posRect.y = GetClientAreaBounds().height - controlRect.height;
1545 controlRect.x = posRect.x;
1546 controlRect.y = posRect.y;
1548 r = __pPlayPauseButton->SetBounds(controlRect);
1549 TryReturnVoid(r == E_SUCCESS, "__pPlayPauseButton->SetBounds() failed:%s", GetErrorMessage(r));
1551 controlRect = __pFastForwardButton->GetBounds();
1552 posRect.y = GetClientAreaBounds().height - controlRect.height;
1553 controlRect.y = posRect.y;
1555 r = __pFastForwardButton->SetBounds(controlRect);
1556 TryReturnVoid(r == E_SUCCESS, "__pFastForwardButton->SetBounds() failed:%s", GetErrorMessage(r));
1558 controlRect = __pBackButton->GetBounds();
1559 posRect.x = WVGA_X_BACK_BTN;
1560 posRect.y = GetClientAreaBounds().height - controlRect.height;
1561 controlRect.x = posRect.x;
1562 controlRect.y = posRect.y;
1564 r = __pBackButton->SetBounds(controlRect);
1565 TryReturnVoid(r == E_SUCCESS, "__pBackButton->SetBounds() failed:%s", GetErrorMessage(r));
1567 Rectangle controlLabelRect = __pControlLabel->GetBounds();
1568 controlRect = __pFirstLineLabel->GetBounds();
1569 posRect.y = GetClientAreaBounds().height - controlLabelRect.height - controlRect.height;
1570 controlRect.y = posRect.y;
1572 r = __pFirstLineLabel->SetBounds(controlRect);
1573 TryReturnVoid(r == E_SUCCESS, "__pFirstLineLabel->SetBounds() failed:%s", GetErrorMessage(r));
1575 controlRect = __pCurrenTimeLabel->GetBounds();
1576 posRect.x = WVGA_X_CURRENT_TIME_LABEL;
1577 posRect.y = GetClientAreaBounds().height - controlLabelRect.height + MARGIN_LANDSCAPE_SLIDER;
1578 controlRect.x = posRect.x;
1579 controlRect.y = posRect.y;
1581 r = __pCurrenTimeLabel->SetBounds(controlRect);
1582 TryReturnVoid(r == E_SUCCESS, "__pCurrenTimeLabel->SetBounds() failed:%s", GetErrorMessage(r));
1584 controlRect = __pTotalTimeLabel->GetBounds();
1585 posRect.x = WVGA_X_TOTAL_TIME_LABEL;
1586 posRect.y = GetClientAreaBounds().height - controlLabelRect.height + MARGIN_LANDSCAPE_SLIDER;
1587 controlRect.x = posRect.x;
1588 controlRect.y = posRect.y;
1590 r = __pTotalTimeLabel->SetBounds(controlRect);
1591 TryReturnVoid(r == E_SUCCESS, "__pTotalTimeLabel->SetBounds() failed:%s", GetErrorMessage(r));
1593 controlRect = __pSlider->GetBounds();
1594 posRect.x = WVGA_X_SLIDER;
1595 posRect.y = GetClientAreaBounds().height - controlLabelRect.height;
1596 controlRect.x = posRect.x;
1597 controlRect.y = posRect.y;
1599 r = __pSlider->SetBounds(controlRect);
1600 TryReturnVoid(r == E_SUCCESS, "__pSlider->SetBounds() failed:%s", GetErrorMessage(r));
1602 controlRect = __pVerticalLeftLine->GetBounds();
1603 posRect.x = WVGA_X_VERTICAL_LEFT_LINE;
1604 posRect.y = GetClientAreaBounds().height - controlRect.height;
1605 controlRect.x = posRect.x;
1606 controlRect.y = posRect.y;
1608 r = __pVerticalLeftLine->SetBounds(controlRect);
1609 TryReturnVoid(r == E_SUCCESS, "__pVerticalLeftLine->SetBounds() failed:%s", GetErrorMessage(r));
1611 controlRect = __pVerticalRightLine->GetBounds();
1612 posRect.x = WVGA_X_VERTICAL_RIGHT_LINE;
1613 posRect.y = GetClientAreaBounds().height - controlRect.height;
1614 controlRect.x = posRect.x;
1615 controlRect.y = posRect.y;
1617 r = __pVerticalRightLine->SetBounds(controlRect);
1618 TryReturnVoid(r == E_SUCCESS, "__pVerticalRightLine->SetBounds() failed:%s", GetErrorMessage(r));
1622 controlRect = __pControlLabel->GetBounds();
1623 posRect.y = GetClientAreaBounds().height - controlRect.height;
1624 controlRect.y = posRect.y;
1626 r = __pControlLabel->SetBounds(controlRect);
1627 TryReturnVoid(r == E_SUCCESS, "__pControlLabel->SetBounds() failed:%s", GetErrorMessage(r));
1629 controlRect = __pFastRewindButton->GetBounds();
1630 posRect.y = GetClientAreaBounds().height - controlRect.height;
1631 controlRect.y = posRect.y;
1633 r = __pFastRewindButton->SetBounds(controlRect);
1634 TryReturnVoid(r == E_SUCCESS, "__pFastRewindButton->SetBounds() failed:%s", GetErrorMessage(r));
1636 controlRect = __pPlayPauseButton->GetBounds();
1637 posRect.y = GetClientAreaBounds().height - controlRect.height;
1638 controlRect.y = posRect.y;
1640 r = __pPlayPauseButton->SetBounds(controlRect);
1641 TryReturnVoid(r == E_SUCCESS, "__pPlayPauseButton->SetBounds() failed:%s", GetErrorMessage(r));
1643 controlRect = __pFastForwardButton->GetBounds();
1644 posRect.y = GetClientAreaBounds().height - controlRect.height;
1645 controlRect.y = posRect.y;
1647 r = __pFastForwardButton->SetBounds(controlRect);
1648 TryReturnVoid(r == E_SUCCESS, "__pFastForwardButton->SetBounds() failed:%s", GetErrorMessage(r));
1650 controlRect = __pBackButton->GetBounds();
1651 posRect.y = GetClientAreaBounds().height - controlRect.height;
1652 controlRect.y = posRect.y;
1654 r = __pBackButton->SetBounds(controlRect);
1655 TryReturnVoid(r == E_SUCCESS, "__pBackButton->SetBounds() failed:%s", GetErrorMessage(r));
1657 Rectangle controlLabelRect = __pControlLabel->GetBounds();
1658 controlRect = __pFirstLineLabel->GetBounds();
1659 posRect.y = GetClientAreaBounds().height - controlLabelRect.height - controlRect.height;
1660 controlRect.y = posRect.y;
1662 r = __pFirstLineLabel->SetBounds(controlRect);
1663 TryReturnVoid(r == E_SUCCESS, "__pFirstLineLabel->SetBounds() failed:%s", GetErrorMessage(r));
1665 controlRect = __pCurrenTimeLabel->GetBounds();
1666 posRect.y = GetClientAreaBounds().height - controlLabelRect.height + MARGIN_LANDSCAPE_SLIDER;
1667 controlRect.y = posRect.y;
1669 r = __pCurrenTimeLabel->SetBounds(controlRect);
1670 TryReturnVoid(r == E_SUCCESS, "__pCurrenTimeLabel->SetBounds() failed:%s", GetErrorMessage(r));
1672 controlRect = __pTotalTimeLabel->GetBounds();
1673 posRect.y = GetClientAreaBounds().height - controlLabelRect.height + MARGIN_LANDSCAPE_SLIDER;
1674 controlRect.y = posRect.y;
1676 r = __pTotalTimeLabel->SetBounds(controlRect);
1677 TryReturnVoid(r == E_SUCCESS, "__pTotalTimeLabel->SetBounds() failed:%s", GetErrorMessage(r));
1679 controlRect = __pSlider->GetBounds();
1680 posRect.y = GetClientAreaBounds().height - controlLabelRect.height;
1681 controlRect.y = posRect.y;
1683 r = __pSlider->SetBounds(controlRect);
1684 TryReturnVoid(r == E_SUCCESS, "__pSlider->SetBounds() failed:%s", GetErrorMessage(r));
1686 controlRect = __pVerticalLeftLine->GetBounds();
1687 posRect.y = GetClientAreaBounds().height - controlRect.height;
1688 controlRect.y = posRect.y;
1690 r = __pVerticalLeftLine->SetBounds(controlRect);
1691 TryReturnVoid(r == E_SUCCESS, "__pVerticalLeftLine->SetBounds() failed:%s", GetErrorMessage(r));
1693 controlRect = __pVerticalRightLine->GetBounds();
1694 posRect.y = GetClientAreaBounds().height - controlRect.height;
1695 controlRect.y = posRect.y;
1697 r = __pVerticalRightLine->SetBounds(controlRect);
1698 TryReturnVoid(r == E_SUCCESS, "__pVerticalRightLine->SetBounds() failed:%s", GetErrorMessage(r));
1704 VideoPlayerForm::ShowControlByFrameActivated(void)
1706 Bitmap* pPlayBitmap = null;
1708 AppLogDebug("ShowControlByFrameActivated");
1710 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1712 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR|FORM_ACTION_BAR_HEADER, true);
1714 pPlayBitmap = pAppResource->GetBitmapN(L"T01_icon_toolbar_play.png");
1715 __pPlayPauseButton->SetNormalBackgroundBitmap(*pPlayBitmap);
1717 __pPlayPauseButton->SetShowState(true);
1718 __pFastRewindButton->SetShowState(true);
1719 __pFastForwardButton->SetShowState(true);
1720 __pBackButton->SetShowState(true);
1721 __pSlider->SetShowState(true);
1722 __pCurrenTimeLabel->SetShowState(true);
1723 __pTotalTimeLabel->SetShowState(true);
1724 __pControlLabel->SetShowState(true);
1725 __pFirstLineLabel->SetShowState(true);
1726 __pVerticalLeftLine->SetShowState(true);
1727 __pVerticalRightLine->SetShowState(true);
1732 CheckLowBatteryStatus();
1738 VideoPlayerForm::CancelTimerByFrameDeactivated(void)
1740 result r = E_FAILURE;
1742 AppLogDebug("CancelTimerByFrameDeactivated");
1744 __pUiControlTimer->Cancel();
1746 __setPauseState = true;
1748 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
1750 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
1751 TryReturnVoid(r == E_SUCCESS, "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
1753 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1757 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
1758 TryReturnVoid(r == E_SUCCESS, "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
1760 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1765 VideoPlayerForm::OnPlayContentChanged(const String& fileName)
1769 AppLogDebug("OnPlayContentChanged");
1771 GetTotalTime(totalTime);
1773 __pHeader->SetTitleText(fileName);
1774 __pHeader->Invalidate(true);
1776 __pTotalTimeLabel->SetText(totalTime);
1777 __pTotalTimeLabel->Invalidate(true);
1781 VideoPlayerForm::OnPlayTimeChanged(int currentProgressPos, String& playTime)
1783 AppLogDebug("OnPlayTimeChanged");
1785 __pSlider->SetValue(currentProgressPos);
1786 __pSlider->Invalidate(true);
1788 __pCurrenTimeLabel->SetText(playTime);
1789 __pCurrenTimeLabel->Invalidate(true);
1793 VideoPlayerForm::OnPlayStateChanged(PlayerState playState)
1795 AppLogDebug("OnPlayStateChanged");
1797 SetPlayPauseButtonImage(playState);
1799 if (playState == PLAYER_STATE_PLAYING)
1801 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1805 __pUiControlTimer->Cancel();
1811 VideoPlayerForm::CheckLowBatteryStatus(void)
1815 bool isCharging = false;
1816 BatteryLevel batteryLevel;
1818 AppLogDebug("CheckLowBatteryStatus");
1820 Battery::GetCurrentLevel(batteryLevel);
1821 Battery::IsCharging(isCharging);
1823 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
1825 if (isCharging == false)
1827 msgBox.Construct(L"", L"Unable to video play.Low battery", MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
1828 msgBox.ShowAndWait(result);
1832 case MSGBOX_RESULT_CLOSE:
1834 AppLogDebug("MSGBOX_RESULT_CLOSE");
1835 OnFormBackRequested(*this);
1847 VideoPlayerForm::CheckCallStatus(void)
1851 int modalResult = 0;
1852 result r = E_FAILURE;
1854 AppLogDebug("CheckCallStatus");
1856 CallManager* pCallManager = new (std::nothrow) CallManager();
1858 r = pCallManager->Construct();
1859 TryCatch(r == E_SUCCESS, , "pCallManager->Construct() failed : %s", GetErrorMessage(r));
1861 if (pCallManager->GetCurrentCallStatus() != CALL_STATUS_IDLE
1862 && pCallManager->GetCurrentCallStatus() != CALL_STATUS_UNDEFINED)
1864 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1865 pAppResource->GetString(L"IDS_VPL_BODY_UNABLE_TO_PLAY_VIDEO_DURING_CALL", dispString);
1867 msgBox.Construct(L"", dispString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
1868 msgBox.ShowAndWait(modalResult);
1870 switch (modalResult)
1872 case MSGBOX_RESULT_CLOSE:
1874 AppLogDebug("MSGBOX_RESULT_CLOSE");
1875 OnFormBackRequested(*this);
1885 delete pCallManager;
1886 pCallManager = null;
1890 VideoPlayerForm::OnFormBackRequested(Form& source)
1892 result r = E_FAILURE;
1894 AppLogDebug("OnFormBackRequested");
1896 UiApp* pApp = UiApp::GetInstance();
1897 TryReturnVoid(pApp != null, "pApp is null");
1899 r = pApp->Terminate();
1900 TryReturnVoid(r == E_SUCCESS, "Failed Terminate [%s]", GetErrorMessage(r));
1904 VideoPlayerForm::OnActiveAudioRouteChanged(const AudioRouteInfo& route)
1906 Color BtnColor(0, 0, 0, 0);
1907 int currentOutputAudioDevice = 0;
1908 Bitmap* pBitmapScreenMode = null;
1909 Bitmap* pBitmapSoundPath = null;
1910 ArrayList* pArgs = null;
1911 result r = E_FAILURE;
1913 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1915 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1917 AppLogDebug("OnActiveAudioRouteChanged");
1919 switch (route.GetOutputAudioDevice())
1921 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
1923 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
1924 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1926 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1928 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1929 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1931 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
1933 if (__pSoundPathPopup != null)
1935 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1938 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1939 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1941 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
1947 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
1949 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
1950 &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1952 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1954 if (__pSoundPathPopup != null)
1956 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1959 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1961 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU,
1965 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
1966 &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1968 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
1970 if (__pHeader->GetButtonStatus(BUTTON_POSITION_LEFT) == BUTTON_ITEM_STATUS_DISABLED)
1972 if (__screenMode == SCREEN_MODE_FIT)
1974 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
1975 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1976 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
1978 else if (__screenMode == SCREEN_MODE_NORMAL)
1980 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
1981 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1982 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
1986 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
1987 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1988 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
1991 __pButtonLeftItem->SetActionId(IDA_BUTTON_FULLSCREEN);
1992 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1993 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
1996 pBitmapSoundPath = pAppResource->GetBitmapN(L"T01_icon_title_soundpath.png");
1997 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapSoundPath);
1998 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2000 __pButtonRightItem->SetActionId(IDA_BUTTON_SOUNDPATH);
2001 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2002 __pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
2004 if (__pSoundPathPopup != null)
2006 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2007 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2009 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2012 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2013 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
2015 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2021 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2023 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2024 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
2026 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2028 if (__screenMode == SCREEN_MODE_FIT)
2030 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2031 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2033 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
2034 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2035 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2037 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2039 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2040 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2041 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2043 else if (__screenMode == SCREEN_MODE_NORMAL)
2045 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2046 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2048 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
2049 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2050 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2052 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2054 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2055 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2056 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2060 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2061 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2063 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
2064 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2065 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2067 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2069 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2070 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2071 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2074 if (__pSoundPathPopup != null)
2076 if (__pSoundPathPopup->GetShowState() == true)
2078 __pSoundPathPopup->SetShowState(false);
2082 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2083 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
2085 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2087 if (__screenMode == SCREEN_MODE_FIT)
2089 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
2090 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2091 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2093 else if (__screenMode == SCREEN_MODE_NORMAL)
2095 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
2096 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2097 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2101 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
2102 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2103 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2106 __pButtonLeftItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2107 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2108 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
2110 pBitmapSoundPath = pAppResource->GetBitmapN(L"T01_icon_title_soundpath.png");
2111 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapSoundPath);
2112 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2114 __pButtonRightItem->SetActionId(IDA_BUTTON_SOUNDPATH);
2115 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2116 __pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
2118 if (__pSoundPathPopup != null)
2120 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2121 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2123 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2126 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2127 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
2129 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2139 delete pBitmapSoundPath;
2140 pBitmapSoundPath = null;
2143 delete pBitmapSoundPath;
2144 pBitmapSoundPath = null;
2148 VideoPlayerForm::OnAudioRouteAdded(const AudioRouteInfo& route)
2150 AppLogDebug("OnAudioRouteAdded");
2152 switch (route.GetOutputAudioDevice())
2154 case OUTPUT_AUDIO_DEVICE_NONE:
2156 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2160 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2162 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2166 case OUTPUT_AUDIO_DEVICE_RECEIVER:
2168 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2172 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2174 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2178 case OUTPUT_AUDIO_DEVICE_BT_SCO:
2180 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2184 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2186 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = true;
2196 VideoPlayerForm::OnAudioRouteRemoved(const AudioRouteInfo& route)
2198 result r = E_FAILURE;
2199 ArrayList* pArgs = null;
2200 Bitmap* pBitmapScreenMode = null;
2201 int currentOutputDevice = 0;
2202 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2204 AppLogDebug("OnAudioRouteRemoved");
2206 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
2208 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2210 switch (route.GetOutputAudioDevice())
2212 case OUTPUT_AUDIO_DEVICE_NONE:
2214 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = false;
2218 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2220 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = false;
2224 case OUTPUT_AUDIO_DEVICE_RECEIVER:
2226 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = false;
2230 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2232 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = false;
2236 case OUTPUT_AUDIO_DEVICE_BT_SCO:
2238 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = false;
2242 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2244 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = false;
2252 if (currentAudioRoute.GetOutputAudioDevice() != route.GetOutputAudioDevice())
2254 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2256 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2257 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2259 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2261 if (__pSoundPathPopup != null)
2263 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2266 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2267 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2269 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2273 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2275 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2276 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2278 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2280 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2281 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2283 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2285 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2286 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2288 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2290 if (__pSoundPathPopup != null)
2292 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2293 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2295 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2298 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2299 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2301 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2305 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2307 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2308 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2310 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2312 if (__pSoundPathPopup != null)
2314 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2317 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2318 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2320 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2323 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2324 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2326 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2328 if (__pSoundPathPopup != null)
2330 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2331 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2333 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2336 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2337 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2339 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2342 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2343 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2345 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2347 if (__screenMode == SCREEN_MODE_FIT)
2349 __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2351 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
2352 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2353 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2355 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2357 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2358 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2359 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2361 else if (__screenMode == SCREEN_MODE_NORMAL)
2363 __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2365 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
2366 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2367 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2369 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2371 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2372 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2373 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2377 __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2379 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
2380 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2381 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2383 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2385 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2386 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2387 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2390 if (__pSoundPathPopup != null)
2392 if (__pSoundPathPopup->GetShowState() == true)
2394 __pSoundPathPopup->SetShowState(false);
2401 delete pBitmapScreenMode;
2402 pBitmapScreenMode = null;
2405 delete pBitmapScreenMode;
2406 pBitmapScreenMode = null;
2410 VideoPlayerForm::InitAudioRouteList(void)
2412 AppLogDebug("InitAudioRouteList");
2415 IList* availableAudioRouteList = null;
2416 AudioRouteInfo* tempRouteInfo = null;
2417 AudioRouteInfo availableRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2418 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2420 availableAudioRouteList = __pAudioRouteManager->GetAvailableAudioRouteListN();
2422 for (listCount = 0; listCount < availableAudioRouteList->GetCount(); ++listCount)
2424 tempRouteInfo = static_cast<AudioRouteInfo*>(availableAudioRouteList->GetAt(listCount));
2425 availableRouteInfo = *tempRouteInfo;
2427 if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_NONE)
2429 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2431 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2433 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2435 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_RECEIVER)
2437 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2439 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2441 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2443 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_SCO)
2445 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2449 __availableAudioRoute[OUTPUT_AUDIO_DEVICE_BT_A2DP] = true;
2453 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2455 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2457 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2458 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2460 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2462 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2463 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2465 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2467 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2468 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2470 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2473 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2475 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2476 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2478 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2480 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2481 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2483 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2485 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2486 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2488 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2491 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2493 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2494 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2496 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2498 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2499 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2501 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2503 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2504 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2506 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2512 VideoPlayerForm::SetActiveAudioRoute(const AudioRouteInfo& route)
2514 AppLogDebug("SetActiveAudioRoute");
2515 result r = __pAudioRouteManager->SetActiveAudioRoute(route);
2521 VideoPlayerForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
2523 BatteryLevel batteryLevel;
2525 AppLogDebug("OnUserEventReceivedN");
2529 case REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED:
2531 Battery::GetCurrentLevel(batteryLevel);
2533 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
2535 OnFormBackRequested(*this);