2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
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 "VpAppResourceId.h"
25 #include "VpSoundPathPopup.h"
27 #include "VpVideoPlayerApp.h"
28 #include "VpVideoPlayerForm.h"
29 #include "VpVideoPlayerPresentationModel.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Base::Runtime;
35 using namespace Tizen::Base::Utility;
36 using namespace Tizen::Content;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Media;
39 using namespace Tizen::System;
40 using namespace Tizen::Telephony;
41 using namespace Tizen::Ui;
42 using namespace Tizen::Ui::Controls;
43 using namespace Tizen::Ui::Scenes;
45 static const int MIN_PROGRESS_RANGE = 0;
46 static const int MAX_PROGRESS_RANGE = 100;
48 static const int SHOW_CONTROL_DURATION = 5000;
50 static const int MILLISECOND = 1000;
51 static const int SLIDER_START_VALUE = 0;
52 static const int SEEK_TIME_NONE = -1;
54 static const int X_BASE = 0;
55 static const int Y_BASE = 0;
56 static const int DIVIDE_BY_TWO = 2;
58 static const int X_NORMAL = 0;
59 static const int Y_NORMAL = 310;
60 static const int W_NORMAL = 720;
61 static const int H_NORMAL = 432;
63 static const int COLOR_THUMB_RED = 0;
64 static const int COLOR_THUMB_GREEN = 0;
65 static const int COLOR_THUMB_BLUE = 0;
66 static const int COLOR_THUMB_ALPHA = 0;
68 static const int MULTI_CONTENT_COUNT = 2;
70 static const int MESSAGEBOX_DISPLAY_TIMEOUT = 3000;
72 static const wchar_t* SLIDER_INIT_TIME = L"00:00:00";
74 static const RequestId REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU = 111;
75 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU = 112;
76 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU = 113;
77 static const RequestId REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED = 114;
79 void DestroyPresentationModelInstance(void)
81 VideoPlayerPresentationModel::DestroyInstance();
84 VideoPlayerForm::VideoPlayerForm(void)
85 : __pOverlayPanel(null)
86 , __screenMode(SCREEN_MODE_NORMAL)
87 , __pSoundPathPopup(null)
88 , __pUiControlTimer(null)
89 , __pAudioRouteManager(null)
91 , __pFunctionPanel(null)
92 , __pControllerPanel(null)
93 , __pPlayPauseButton(null)
94 , __pFastForwardButton(null)
95 , __pFastRewindButton(null)
96 , __pShareButton(null)
97 , __pScreenModeButton(null)
98 , __pRepeatModeButton(null)
99 , __pCurrenTimeLabel(null)
100 , __pTotalTimeLabel(null)
102 , __pShareContextMenu(null)
103 , __actionTouchLongPressed(false)
104 , __setPauseState(false)
105 , __isControlVisibleState(true)
106 , __sliderMoved(false)
107 , __playingBeforeSlide(false)
108 , __frameActivated(false)
109 , __audioRouteMode(0)
110 , __timeToSeek(SEEK_TIME_NONE)
111 , __pVideoPlayerPresentationModel(null)
113 for (int count = 0; count < OUTPUT_AUDIO_ROUTE_MAX; ++count)
115 __availableAudioRoute[count] = false;
119 VideoPlayerForm::~VideoPlayerForm(void)
124 VideoPlayerForm::Initialize(void)
126 AppLogDebug("Initialize");
128 Construct(L"IDL_MAIN_FORM");
129 AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
130 pAccessibilityElement->Construct(GetBounds(), L"IDL_MAIN_FORM");
132 AccessibilityContainer* pContainer = GetAccessibilityContainer();
133 if (pContainer != null)
135 pContainer->AddElement(*pAccessibilityElement);
140 VideoPlayerForm::SetScreenMode(const ScreenMode mode, bool destroyOverlay)
142 result r = E_SUCCESS;
144 Rectangle clientRect = GetClientAreaBounds();
146 AccessibilityContainer* pContainer = null;
148 RecordingRotation recRotation = RECORDING_ROTATION_NONE;
149 VideoFrameExtractor extractor;
150 r = extractor.Construct(__pVideoPlayerPresentationModel->GetMediaPathName(), MEDIA_PIXEL_FORMAT_RGB565LE);
153 recRotation = extractor.GetRecordingRotation();
158 case SCREEN_MODE_NORMAL:
160 Rectangle rect = Rectangle(X_NORMAL, Y_NORMAL, W_NORMAL, H_NORMAL);
162 if (recRotation == RECORDING_ROTATION_90 || recRotation == RECORDING_ROTATION_270)
164 rect.width = H_NORMAL;
165 rect.height = W_NORMAL;
168 if ((clientRect.width - rect.width) <= X_BASE)
174 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
177 if ((clientRect.height - rect.height) <= Y_BASE)
183 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
186 AppLogDebug("SCREEN_MODE_NORMAL : [%d][%d][%d][%d][rotation:%d]", rect.x, rect.y, rect.width, rect.height, recRotation);
188 if (destroyOverlay == true)
190 if (__pOverlayPanel != null)
192 __pOverlayPanel->RemoveTouchEventListener(*this);
193 RemoveControl(__pOverlayPanel);
194 __pOverlayPanel = null;
197 __pOverlayPanel = new (std::nothrow) OverlayPanel();
198 r = __pOverlayPanel->Construct(rect);
199 TryCatch(r == E_SUCCESS,, "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
200 __pOverlayPanel->SetFocusable(false);
202 r = AddControl(__pOverlayPanel);
203 TryCatch(r == E_SUCCESS,, "AddControl(__pOverlayPanel) failed:%s", GetErrorMessage(r));
205 __pOverlayPanel->AddTouchEventListener(*this);
207 AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
208 r = pAccessibilityElement->Construct(GetBounds(), L"Overlay Panel");
210 pContainer = __pOverlayPanel->GetAccessibilityContainer();
211 if (pContainer != null)
213 pContainer->AddElement(*pAccessibilityElement);
218 __pOverlayPanel->SetBounds(rect);
221 SetControlAlwaysAtBottom(*__pOverlayPanel, true);
223 __screenMode = SCREEN_MODE_NORMAL;
227 case SCREEN_MODE_FULL:
229 Rectangle rect = Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height);
231 AppLogDebug("SCREEN_MODE_FULL : [%d][%d][%d][%d][rotation:%d]", rect.x, rect.y, rect.width, rect.height, recRotation);
233 if (destroyOverlay == true)
235 if (__pOverlayPanel != null)
237 __pOverlayPanel->RemoveTouchEventListener(*this);
238 RemoveControl(__pOverlayPanel);
239 __pOverlayPanel = null;
242 __pOverlayPanel = new (std::nothrow) OverlayPanel();
243 r = __pOverlayPanel->Construct(rect);
244 TryCatch(r == E_SUCCESS,, "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
245 __pOverlayPanel->SetFocusable(false);
247 r = AddControl(__pOverlayPanel);
248 TryCatch(r == E_SUCCESS,, "AddControl(__pOverlayPanel) failed:%s", GetErrorMessage(r));
250 __pOverlayPanel->AddTouchEventListener(*this);
252 AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
253 r = pAccessibilityElement->Construct(GetBounds(), L"Overlay Panel");
255 pContainer = __pOverlayPanel->GetAccessibilityContainer();
256 if (pContainer != null)
258 pContainer->AddElement(*pAccessibilityElement);
263 __pOverlayPanel->SetBounds(rect);
265 Dimension renderSize = __pOverlayPanel->GetSize();
266 __pOverlayPanel->SetRenderSize(renderSize);
269 SetControlAlwaysAtBottom(*__pOverlayPanel, true);
271 __screenMode = SCREEN_MODE_FULL;
275 case SCREEN_MODE_FIT:
277 Rectangle videoRect = __pVideoPlayerPresentationModel->GetVideoInfoN(__pVideoPlayerPresentationModel->GetMediaPathName());
279 Rectangle rect(0, 0, videoRect.width, videoRect.height);
281 if (recRotation == RECORDING_ROTATION_90 || recRotation == RECORDING_ROTATION_270)
283 rect.width = videoRect.height;
284 rect.height = videoRect.width;
287 if ((clientRect.width - rect.width) <= X_BASE)
293 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
296 if ((clientRect.height - rect.height) <= Y_BASE)
302 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
305 AppLogDebug("SCREEN_MODE_FIT : [%d][%d][%d][%d][rotation:%d]", rect.x, rect.y, rect.width, rect.height, recRotation);
307 if (destroyOverlay == true)
309 if (__pOverlayPanel != null)
311 __pOverlayPanel->RemoveTouchEventListener(*this);
312 RemoveControl(__pOverlayPanel);
313 __pOverlayPanel = null;
316 __pOverlayPanel = new (std::nothrow) OverlayPanel();
317 r = __pOverlayPanel->Construct(rect);
318 TryCatch(r == E_SUCCESS,, "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
319 __pOverlayPanel->SetFocusable(false);
321 r = AddControl(__pOverlayPanel);
322 TryCatch(r == E_SUCCESS,, "AddControl(__pOverlayPanel) failed:%s", GetErrorMessage(r));
324 __pOverlayPanel->AddTouchEventListener(*this);
326 AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
327 r = pAccessibilityElement->Construct(GetBounds(), L"Overlay Panel");
329 pContainer = __pOverlayPanel->GetAccessibilityContainer();
330 if (pContainer != null)
332 pContainer->AddElement(*pAccessibilityElement);
337 __pOverlayPanel->SetBounds(rect);
339 SetControlAlwaysAtBottom(*__pOverlayPanel, true);
341 __screenMode = SCREEN_MODE_FIT;
352 if (__pOverlayPanel != null)
354 RemoveControl(__pOverlayPanel);
355 __pOverlayPanel = null;
358 __screenMode = SCREEN_MODE_NORMAL;
364 VideoPlayerForm::OnInitializing(void)
366 result r = E_FAILURE;
368 AppLogDebug("OnInitializing");
370 AddOrientationEventListener(*this);
371 AddTouchEventListener(*this);
372 AddKeyEventListener(*this);
374 __pAudioRouteManager = AudioRouteManager::GetInstance();
375 __pAudioRouteManager->SetAudioRouteEventListener(this);
377 __pVideoPlayerPresentationModel = VideoPlayerPresentationModel::GetInstance();
378 TryCatch(__pVideoPlayerPresentationModel != null, r = E_SYSTEM, "__pVideoPlayerPresentationModel is null");
380 r = SetScreenMode(SCREEN_MODE_NORMAL, true);
381 TryCatch(r == E_SUCCESS,, "SetScreenMode() failed:%s", GetErrorMessage(r));
383 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
385 r = __pVideoPlayerPresentationModel->InitializePlayer();
387 __pVideoPlayerPresentationModel->SetVideoPlayerEventListener(this);
390 InitAudioRouteList();
392 r = InitializeHeader();
393 TryCatch(r == E_SUCCESS,, "InitializeHeader() failed : %s", GetErrorMessage(r));
394 r = InitializeFuncPanel();
395 TryCatch(r == E_SUCCESS,, "InitializeFuncPanel() failed : %s", GetErrorMessage(r));
396 r = InitializeController();
397 TryCatch(r == E_SUCCESS,, "InitializeController() failed : %s", GetErrorMessage(r));
404 DestroyPresentationModelInstance();
410 VideoPlayerForm::InitializeHeader(void)
412 result r = E_FAILURE;
414 AppLogDebug("InitializeHeader");
416 __pHeader = GetHeader();
417 TryCatch(__pHeader != null, r = E_SYSTEM, "__pHeader is null");
419 __pHeader->AddTouchEventListener(*this);
428 VideoPlayerForm::InitializeFuncPanel(void)
430 result r = E_FAILURE;
433 AppLogDebug("InitializeFuncPanel");
435 __pFunctionPanel = static_cast<Panel*>(GetControl(IDC_PANEL_FUNCTION));
436 TryCatch(__pFunctionPanel != null, r = E_SYSTEM, "__pFunctionPanel is null");
438 __pScreenModeButton = static_cast<Button*>(__pFunctionPanel->GetControl(IDC_BUTTON_SCREENMODE));
439 TryCatch(__pScreenModeButton != null, r = E_SYSTEM, "__pScreenModeButton is null");
440 __pScreenModeButton->SetActionId(IDA_BUTTON_FULLSCREEN);
441 __pScreenModeButton->AddActionEventListener(*this);
442 __pScreenModeButton->AddTouchEventListener(*this);
443 __pScreenModeButton->AddKeyEventListener(*this);
445 __pShareButton = static_cast<Button*>(__pFunctionPanel->GetControl(IDC_BUTTON_SHARE));
446 TryCatch(__pShareButton != null, r = E_SYSTEM, "__pShareButton is null");
447 __pShareButton->SetActionId(IDA_BUTTON_SHARE);
448 __pShareButton->AddActionEventListener(*this);
449 __pShareButton->AddTouchEventListener(*this);
450 __pShareButton->AddKeyEventListener(*this);
452 launchType = __pVideoPlayerPresentationModel->GetLaunchType();
453 if (launchType == APPCONTROL_DATA_MESSAGE || launchType == APPCONTROL_DATA_EMAIL)
455 __pShareButton->SetShowState(false);
465 VideoPlayerForm::InitializeController(void)
467 result r = E_FAILURE;
469 Bitmap* pSliderThumbNormalBitmap = null;
470 Bitmap* pSliderThumbPressedBitmap = null;
471 Bitmap* pSliderThumbDisableBitmap = null;
473 AppLogDebug("InitializeController");
475 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
477 __pControllerPanel = static_cast<Panel*>(GetControl(IDC_PANEL_CONTROLLER));
478 TryCatch(__pControllerPanel != null, r = E_SYSTEM, "__pControllerPanel is null");
480 __pRepeatModeButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_REPEATMODE));
481 TryCatch(__pRepeatModeButton != null, r = E_SYSTEM, "__pRepeatModeButton is null");
482 __pRepeatModeButton->SetActionId(IDA_BUTTON_REPEATMODE);
483 __pRepeatModeButton->AddActionEventListener(*this);
484 __pRepeatModeButton->AddTouchEventListener(*this);
485 __pRepeatModeButton->AddKeyEventListener(*this);
487 __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_PLAY));
488 TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
489 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
490 __pPlayPauseButton->AddActionEventListener(*this);
491 __pPlayPauseButton->AddTouchEventListener(*this);
492 __pPlayPauseButton->AddKeyEventListener(*this);
494 __pFastRewindButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_FASTREWIND));
495 TryCatch(__pFastRewindButton != null, r = E_SYSTEM, "__pFastRewindButton is null");
496 __pFastRewindButton ->SetActionId(IDA_BUTTON_FASTREWIND);
497 __pFastRewindButton ->AddActionEventListener(*this);
498 __pFastRewindButton->AddTouchEventListener(*this);
499 __pFastRewindButton->AddKeyEventListener(*this);
500 __pFastRewindButton->AddFocusEventListener(*this);
502 __pFastForwardButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_FASTFORWARD));
503 TryCatch(__pFastForwardButton != null, r = E_SYSTEM, "__pFastForwardButton is null");
504 __pFastForwardButton->SetActionId(IDA_BUTTON_FASTFORWARD);
505 __pFastForwardButton->AddActionEventListener(*this);
506 __pFastForwardButton->AddTouchEventListener(*this);
507 __pFastForwardButton->AddKeyEventListener(*this);
508 __pFastForwardButton->AddFocusEventListener(*this);
510 SetFormBackEventListener(this);
512 __pCurrenTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_LABEL_CURRENTTIME));
513 TryCatch(__pCurrenTimeLabel != null, r = E_SYSTEM, "__pCurrenTimeLabel is null");
514 __pCurrenTimeLabel->AddTouchEventListener(*this);
516 __pTotalTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_LABEL_FULLTIME));
517 TryCatch(__pTotalTimeLabel != null, r = E_SYSTEM, "__pTotalTimeLabel is null");
518 __pTotalTimeLabel->AddTouchEventListener(*this);
520 __pSlider = static_cast<Slider*>(__pControllerPanel->GetControl(IDC_SLIDER));
521 TryCatch(__pSlider != null, r = E_SYSTEM, "__pSlider is null");
522 __pSlider->SetEnabled(true);
523 __pSlider->SetRange(MIN_PROGRESS_RANGE, MAX_PROGRESS_RANGE);
524 __pSlider->SetValue(MIN_PROGRESS_RANGE);
525 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL,
526 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
527 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED,
528 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
529 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED,
530 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
532 pSliderThumbNormalBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle.png");
533 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *pSliderThumbNormalBitmap);
534 TryCatch(r == E_SUCCESS,, "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
536 pSliderThumbPressedBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle_press.png");
537 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *pSliderThumbPressedBitmap);
538 TryCatch(r == E_SUCCESS,, "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
540 pSliderThumbDisableBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle.png");
541 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_DISABLED, *pSliderThumbDisableBitmap);
542 TryCatch(r == E_SUCCESS,, "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
544 __pSlider->AddAdjustmentEventListener(*this);
545 __pSlider->AddTouchEventListener(*this);
546 __pSlider->AddSliderEventListener(*this);
547 __pSlider->AddKeyEventListener(*this);
550 delete pSliderThumbNormalBitmap;
551 delete pSliderThumbPressedBitmap;
552 delete pSliderThumbDisableBitmap;
558 VideoPlayerForm::OnTerminating(void)
560 AppLogDebug("OnTerminating");
562 AccessibilityContainer* pContainer = null;
565 DestroyPresentationModelInstance();
567 __pVideoPlayerPresentationModel = null;
569 if (__pOverlayPanel != null)
571 pContainer = __pOverlayPanel->GetAccessibilityContainer();
572 pContainer->RemoveAllElements();
573 RemoveControl(__pOverlayPanel);
574 __pOverlayPanel = null;
577 delete __pSoundPathPopup;
578 __pSoundPathPopup = null;
580 delete __pShareContextMenu;
581 __pShareContextMenu = null;
583 pContainer = GetAccessibilityContainer();
584 pContainer->RemoveAllElements();
590 VideoPlayerForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
592 AppLogDebug("OnSceneActivatedN");
594 TryReturnVoid(__pVideoPlayerPresentationModel != null, "__pVideoPlayerPresentationModel is null");
596 SetScreenModeButtonImage();
600 VideoPlayerForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
602 result r = E_FAILURE;
604 AppLogDebug("OnSceneDeactivated");
606 r = __pVideoPlayerPresentationModel->PausePlay();
607 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
611 VideoPlayerForm::OnPlayOpened(result r)
613 AppLogDebug("OnPlayOpened");
617 VideoPlayerForm::OnPlayEndOfClip(bool playNextContent, int repeatMode, int mediaCount)
619 result r = E_FAILURE;
621 Point point(X_BASE, Y_BASE);
622 Bitmap* pPlayBitmap = null;
624 AppLogDebug("OnPlayEndOfClip : %d", playNextContent);
626 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
628 if (__pSoundPathPopup != null)
630 if (__pSoundPathPopup->GetShowState() == true)
632 __pSoundPathPopup->SetShowState(false);
636 __pUiControlTimer->Cancel();
638 UpdateProgressBar(SLIDER_START_VALUE);
640 __pCurrenTimeLabel->SetText(SLIDER_INIT_TIME);
641 __pCurrenTimeLabel->Invalidate(true);
643 pPlayBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_play.png");
644 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
646 __pPlayPauseButton->SetNormalBitmap(point, *pPlayBitmap);
647 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
650 __pSlider->SetEnabled(false);
652 if (__pScreenModeButton->GetShowState() == true)
654 __pScreenModeButton->SetShowState(false);
659 case REPEAT_TYPE_OFF:
661 if (mediaCount < MULTI_CONTENT_COUNT)
663 r = PowerManager::KeepScreenOnState(false);
664 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
668 if (playNextContent == true && __setPauseState == false)
670 SetScreenMode(SCREEN_MODE_NORMAL, true);
671 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
673 r = __pVideoPlayerPresentationModel->StartPlay();
674 TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
676 SetScreenModeButtonImage();
678 __pSlider->SetEnabled(true);
680 if (__pScreenModeButton->GetShowState() == false)
682 __pScreenModeButton->SetShowState(true);
685 r = PowerManager::KeepScreenOnState(true, false);
686 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
692 case REPEAT_TYPE_ONE:
694 if (__setPauseState == false)
696 r = __pVideoPlayerPresentationModel->StartPlay();
697 TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
699 __pSlider->SetEnabled(true);
701 SetScreenModeButtonImage();
702 if (__pScreenModeButton->GetShowState() == false)
704 __pScreenModeButton->SetShowState(true);
707 r = PowerManager::KeepScreenOnState(true, false);
708 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
713 case REPEAT_TYPE_ALL:
715 if ( __setPauseState == false)
717 if (mediaCount < MULTI_CONTENT_COUNT)
719 r = __pVideoPlayerPresentationModel->StartPlay();
720 TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
724 SetScreenMode(SCREEN_MODE_NORMAL, true);
725 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
727 r = __pVideoPlayerPresentationModel->StartPlay();
728 TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
731 __pSlider->SetEnabled(true);
733 SetScreenModeButtonImage();
734 if (__pScreenModeButton->GetShowState() == false)
736 __pScreenModeButton->SetShowState(true);
739 r = PowerManager::KeepScreenOnState(true, false);
740 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
754 VideoPlayerForm::OnPlayBuffering(int percent)
756 AppLogDebug("OnPlayBuffering");
760 VideoPlayerForm::OnPlayErrorOccurred(PlayerErrorReason r)
762 MessageBox messageBox;
763 String messageBoxString;
765 AppResource* pAppResource = null;
767 AppLogDebug("OnPlayErrorOccurred [%d]", r);
771 case PLAYER_ERROR_INVALID_DATA:
773 __pVideoPlayerPresentationModel->StopPlay();
775 pAppResource = Application::GetInstance()->GetAppResource();
776 pAppResource->GetString(IDS_COM_POP_UNSUPPORTED_FILE_TYPE, messageBoxString);
778 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
779 messageBox.ShowAndWait(modalResult);
781 UiApp* pApp = UiApp::GetInstance();
782 TryReturnVoid(pApp != null, "pApp is null");
787 case PLAYER_ERROR_DEVICE_FAILED:
789 __pVideoPlayerPresentationModel->StopPlay();
791 pAppResource = Application::GetInstance()->GetAppResource();
792 pAppResource->GetString(IDS_VPL_POP_UNABLE_TO_PLAY_VIDEO_ERROR_OCCURRED, messageBoxString);
794 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
795 messageBox.ShowAndWait(modalResult);
797 UiApp* pApp = UiApp::GetInstance();
798 TryReturnVoid(pApp != null, "pApp is null");
809 VideoPlayerForm::OnPlayInterrupted(void)
811 AppLogDebug("OnPlayInterrupted");
815 VideoPlayerForm::OnPlayReleased(void)
817 AppLogDebug("OnPlayReleased");
821 VideoPlayerForm::OnActionPerformed(const Control& source, int actionId)
823 result r = E_FAILURE;
828 Point point(X_BASE, Y_BASE);
830 PlayerState playState = PLAYER_STATE_ERROR;
831 AppLogDebug("OnActionPerformed : %d", actionId);
833 playState = __pVideoPlayerPresentationModel->GetState();
835 Rectangle clientRect = GetClientAreaBounds();
839 case IDA_BUTTON_PLAY:
841 __setPauseState = false;
843 if (playState == PLAYER_STATE_ENDOFCLIP)
845 if (__pVideoPlayerPresentationModel->GetMediaCount() >= MULTI_CONTENT_COUNT)
847 int repeatMode = __pVideoPlayerPresentationModel->GetRepeatMode();
849 if (repeatMode == REPEAT_TYPE_OFF || repeatMode == REPEAT_TYPE_ALL)
851 SetScreenMode(SCREEN_MODE_NORMAL, true);
852 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
857 r = __pVideoPlayerPresentationModel->StartPlay();
858 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
860 __pSlider->SetEnabled(true);
862 SetScreenModeButtonImage();
864 if (__pScreenModeButton->GetShowState() == false)
866 __pScreenModeButton->SetShowState(true);
869 r = PowerManager::KeepScreenOnState(true, false);
870 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
874 case IDA_BUTTON_PAUSE:
876 __setPauseState = true;
878 r = __pVideoPlayerPresentationModel->PausePlay();
879 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
881 if (__pScreenModeButton->GetShowState() == true)
883 __pScreenModeButton->SetShowState(false);
886 r = PowerManager::KeepScreenOnState(false);
887 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
891 case IDA_BUTTON_FULLSCREEN:
893 if (playState == PLAYER_STATE_PLAYING)
895 __pUiControlTimer->Cancel();
896 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
903 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
904 __pVideoPlayerPresentationModel->GetMediaPathName());
906 if (rect.width == 0 || rect.height == 0)
911 switch (__screenMode)
913 case SCREEN_MODE_FIT:
915 r = SetScreenMode(SCREEN_MODE_FULL, true);
916 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
918 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
919 __pVideoPlayerPresentationModel->SetRenderingBuffer();
921 SetScreenModeButtonImage();
925 case SCREEN_MODE_FULL:
927 r = SetScreenMode(SCREEN_MODE_NORMAL, true);
928 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
930 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
931 __pVideoPlayerPresentationModel->SetRenderingBuffer();
933 SetScreenModeButtonImage();
937 case SCREEN_MODE_NORMAL:
939 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
941 r = SetScreenMode(SCREEN_MODE_FULL, true);
942 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
944 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
945 __pVideoPlayerPresentationModel->SetRenderingBuffer();
949 r = SetScreenMode(SCREEN_MODE_FIT, true);
950 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
952 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
953 __pVideoPlayerPresentationModel->SetRenderingBuffer();
955 SetScreenModeButtonImage();
965 case IDA_BUTTON_SOUNDPATH:
967 if (__pSoundPathPopup == null)
969 PlayerSoundPathPopupInit();
972 if (playState == PLAYER_STATE_PLAYING)
974 __pUiControlTimer->Cancel();
975 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
977 __pSoundPathPopup->ShowPopup(true);
981 case IDA_BUTTON_FASTFORWARD:
983 if (__actionTouchLongPressed == true)
985 __actionTouchLongPressed = false;
989 if (playState == PLAYER_STATE_PLAYING)
991 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
994 __pVideoPlayerPresentationModel->Forward();
998 case IDA_BUTTON_FASTREWIND:
1000 if (__actionTouchLongPressed == true)
1002 __actionTouchLongPressed = false;
1006 if (playState == PLAYER_STATE_PLAYING)
1008 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1011 __pVideoPlayerPresentationModel->Rewind();
1015 case IDA_BUTTON_SHARE:
1017 Point point((((GetClientAreaBounds().width - __pFunctionPanel->GetBounds().width) / DIVIDE_BY_TWO)
1018 + (__pShareButton->GetBounds().width / DIVIDE_BY_TWO)),
1019 __pFunctionPanel->GetBounds().y + __pFunctionPanel->GetBounds().height);
1021 if (__pShareContextMenu != null)
1023 delete __pShareContextMenu;
1024 __pShareContextMenu = null;
1027 __pShareContextMenu = new (std::nothrow) ContextMenu();
1028 r = __pShareContextMenu->Construct(point, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD);
1029 TryReturnVoid(r == E_SUCCESS, "__pShareContextMenu->Construct() failed:%s", GetErrorMessage(r));
1032 Bitmap* pBitmapMsg = null;
1033 Bitmap* pBitmapEmail = null;
1034 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1036 pAppResource->GetString(L"IDS_COM_BODY_MESSAGE", menuItemStr);
1037 pBitmapMsg = pAppResource->GetBitmapN(IDB_MENU_ICON_MESSAGE);
1038 __pShareContextMenu->AddItem(menuItemStr, IDA_CONTEXTMENU_MESSAGE, *pBitmapMsg);
1041 pAppResource->GetString(L"IDS_COM_BODY_EMAIL", menuItemStr);
1042 pBitmapEmail = pAppResource->GetBitmapN(IDB_MENU_ICON_EMAIL);
1043 __pShareContextMenu->AddItem(menuItemStr, IDA_CONTEXTMENU_EMAIL, *pBitmapEmail);
1044 delete pBitmapEmail;
1046 __pShareContextMenu->SetFocusable(true);
1047 __pShareContextMenu->AddActionEventListener(*this);
1048 __pShareContextMenu->SetShowState(true);
1049 __pShareContextMenu->Show();
1051 if (playState == PLAYER_STATE_PLAYING)
1053 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1058 case IDA_CONTEXTMENU_MESSAGE:
1060 AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE);
1061 TryReturnVoid(pAppControl != null, "pAppControl is null");
1063 String filePath = __pVideoPlayerPresentationModel->GetMediaPathName();
1065 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1066 r = pDataList->Construct();
1068 if ( r != E_SUCCESS)
1076 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1077 pList->Add(new (std::nothrow) String(filePath));
1078 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
1079 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
1080 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_RETURN_RESULT), new (std::nothrow) String("true"));
1082 r = pAppControl->Start(null, null, pDataList, this);
1086 VideoPlayerApp* pVideoPlayerApp = static_cast<VideoPlayerApp*>(VideoPlayerApp::GetInstance());
1087 pVideoPlayerApp->SetFrameEnabled(false);
1090 pDataList->RemoveAll(true);
1098 case IDA_CONTEXTMENU_EMAIL:
1100 AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE);
1101 TryReturnVoid(pAppControl != null, "pAppControl is null");
1103 String filePath = __pVideoPlayerPresentationModel->GetMediaPathName();
1105 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1107 r = pDataList->Construct();
1109 if ( r != E_SUCCESS)
1116 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1117 pList->Add(new (std::nothrow) String(filePath));
1118 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
1120 r = pAppControl->Start(null, null, pDataList, this);
1124 VideoPlayerApp* pVideoPlayerApp = static_cast<VideoPlayerApp*>(VideoPlayerApp::GetInstance());
1125 pVideoPlayerApp->SetFrameEnabled(false);
1128 pDataList->RemoveAll(true);
1135 case IDA_BUTTON_REPEATMODE:
1137 int repeatMode = __pVideoPlayerPresentationModel->GetRepeatMode();
1141 case REPEAT_TYPE_OFF:
1143 SetRepeatButtonImage(REPEAT_TYPE_ONE);
1147 case REPEAT_TYPE_ONE:
1149 if (__pVideoPlayerPresentationModel->GetMediaCount() > 1)
1151 SetRepeatButtonImage(REPEAT_TYPE_ALL);
1155 SetRepeatButtonImage(REPEAT_TYPE_OFF);
1160 case REPEAT_TYPE_ALL:
1162 SetRepeatButtonImage(REPEAT_TYPE_OFF);
1170 if (playState == PLAYER_STATE_PLAYING)
1172 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1177 case IDA_BUTTON_BACK:
1179 Application::GetInstance()->Terminate();
1189 VideoPlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition,
1190 const TouchEventInfo& touchInfo)
1192 AppLogDebug("OnTouchPressed Control : %ls", source.GetName().GetPointer());
1193 __pUiControlTimer->Cancel();
1197 VideoPlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition,
1198 const TouchEventInfo& touchInfo)
1200 AppLogDebug("OnTouchReleased Control : %ls", source.GetName().GetPointer());
1202 PlayerState playState = PLAYER_STATE_ERROR;
1204 if ((&source == __pFastForwardButton
1205 || &source == __pFastRewindButton)
1206 && __actionTouchLongPressed == true)
1208 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1211 playState = __pVideoPlayerPresentationModel->GetState();
1213 if (playState == PLAYER_STATE_PLAYING || playState == PLAYER_STATE_PAUSED || playState == PLAYER_STATE_ENDOFCLIP)
1215 if (source.GetName() == L"IDL_MAIN_FORM"
1216 || source.GetHashCode() == __pOverlayPanel->GetHashCode()
1217 || source.GetHashCode() == __pHeader->GetHashCode())
1219 if (__isControlVisibleState == true)
1221 if (source.GetHashCode() == __pHeader->GetHashCode())
1223 if (__pUiControlTimer != null)
1225 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1237 if (__pUiControlTimer != null)
1239 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1243 else if (source.GetHashCode() == __pSlider->GetHashCode() && __playingBeforeSlide == true)
1245 result r = __pVideoPlayerPresentationModel->StartPlay();
1246 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
1247 __playingBeforeSlide = false;
1253 VideoPlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition,
1254 const TouchEventInfo& touchInfo)
1256 AppLogDebug("OnTouchLongPressed Control : %ls", source.GetName().GetPointer());
1258 if (&source == __pFastForwardButton)
1260 __actionTouchLongPressed = true;
1262 if (__setPauseState == true)
1264 __pVideoPlayerPresentationModel->FastForward(false);
1268 __pVideoPlayerPresentationModel->FastForward(true);
1271 else if (&source == __pFastRewindButton)
1273 __actionTouchLongPressed = true;
1275 if (__setPauseState == true)
1277 __pVideoPlayerPresentationModel->FastRewind(false);
1281 __pVideoPlayerPresentationModel->FastRewind(true);
1284 else if (&source == __pSlider)
1286 PlayerState playState = PLAYER_STATE_ERROR;
1287 playState = __pVideoPlayerPresentationModel->GetState();
1289 if (playState == PLAYER_STATE_PLAYING)
1291 result r = __pVideoPlayerPresentationModel->PausePlay();
1292 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
1293 __playingBeforeSlide = true;
1299 VideoPlayerForm::OnTimerExpired(Timer& timer)
1301 if (timer.GetHashCode() == __pUiControlTimer->GetHashCode())
1303 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1311 VideoPlayerForm::OnAdjustmentValueChanged(const Control& source, int adjustment)
1313 result r = E_FAILURE;
1316 AppLogDebug("OnAdjustmentValueChanged : %d", adjustment);
1318 if (source.GetHashCode() == __pSlider->GetHashCode() && __sliderMoved == true
1319 && adjustment >= MIN_PROGRESS_RANGE && adjustment <= MAX_PROGRESS_RANGE)
1321 __sliderMoved = false;
1323 seekTime = adjustment * (__pVideoPlayerPresentationModel->GetDuration() / MAX_PROGRESS_RANGE);
1324 if (__pVideoPlayerPresentationModel->GetSeekCompleted())
1326 r = __pVideoPlayerPresentationModel->SeekTo(seekTime);
1327 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
1331 __timeToSeek = seekTime;
1334 UpdateProgressBar(adjustment);
1337 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1339 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1344 VideoPlayerForm::OnFocusLost(const Tizen::Ui::Control& source)
1346 AppLogDebug("OnFocusLost Control : %ls, KeyCode : %d", source.GetName().GetPointer());
1348 if ((&source == __pFastForwardButton
1349 || &source == __pFastRewindButton)
1350 && __actionTouchLongPressed == true)
1352 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1357 VideoPlayerForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1359 __pUiControlTimer->Cancel();
1363 VideoPlayerForm::OnKeyReleased(const Control& source, KeyCode keyCode)
1365 AppLogDebug("OnKeyReleased Control : %ls, KeyCode : %d", source.GetName().GetPointer(), keyCode);
1367 if ((&source == __pFastForwardButton
1368 || &source == __pFastRewindButton)
1369 && __actionTouchLongPressed == true)
1371 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1374 if (source.GetName() == L"IDL_MAIN_FORM" && __isControlVisibleState == false)
1378 if (__pUiControlTimer != null)
1380 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1386 VideoPlayerForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1388 AppLogDebug("OnKeyLongPressed Control : %ls, KeyCode : %d", source.GetName().GetPointer(), keyCode);
1390 if (keyCode == KEY_ENTER)
1392 if (&source == __pFastForwardButton)
1394 __actionTouchLongPressed = true;
1396 if (__setPauseState == true)
1398 __pVideoPlayerPresentationModel->FastForward(false);
1402 __pVideoPlayerPresentationModel->FastForward(true);
1405 else if (&source == __pFastRewindButton)
1407 __actionTouchLongPressed = true;
1409 if (__setPauseState == true)
1411 __pVideoPlayerPresentationModel->FastRewind(false);
1415 __pVideoPlayerPresentationModel->FastRewind(true);
1422 VideoPlayerForm::UpdateProgressBar(const int currentPlayTime)
1424 TryReturnVoid(__pSlider, "__pSlider is null");
1426 __pSlider->SetValue(currentPlayTime);
1427 __pSlider->Invalidate(true);
1431 VideoPlayerForm::InitTimer(void)
1433 __pUiControlTimer = new (std::nothrow) Timer();
1434 __pUiControlTimer->Construct(*this);
1438 VideoPlayerForm::DeleteTimer(void)
1440 if (__pUiControlTimer != null)
1442 __pUiControlTimer->Cancel();
1443 delete __pUiControlTimer;
1444 __pUiControlTimer = null;
1449 VideoPlayerForm::SetPlayPauseButtonImage(PlayerState playState)
1451 result r = E_SUCCESS;
1453 Bitmap* pPlayBitmap = null;
1454 Bitmap* pPauseBitmap = null;
1455 Point point(X_BASE, Y_BASE);
1457 AppLogDebug("SetPlayPauseButtonImage : %d", playState);
1459 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1461 __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_PLAY));
1462 TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
1464 if (playState == PLAYER_STATE_PLAYING)
1466 pPauseBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_pause.png");
1467 TryCatch(pPauseBitmap != null, r = E_SYSTEM, "pPauseBitmap is null");
1469 __pPlayPauseButton->SetNormalBitmap(point, *pPauseBitmap);
1471 __pPlayPauseButton->SetActionId(IDA_BUTTON_PAUSE);
1472 __pPlayPauseButton->Invalidate(true);
1474 delete pPauseBitmap;
1478 pPlayBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_play.png");
1479 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
1481 __pPlayPauseButton->SetNormalBitmap(point, *pPlayBitmap);
1483 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
1484 __pPlayPauseButton->Invalidate(true);
1495 VideoPlayerForm::SetRepeatButtonImage(int repeatValue)
1497 AppLogDebug("SetRepeatButtonImage");
1498 Bitmap* pRepeatBitmap = null;
1499 Bitmap* pRepeatPressBitmap = null;
1501 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1503 switch (repeatValue)
1505 case REPEAT_TYPE_OFF:
1507 pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat.png");
1508 pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_press.png");
1512 case REPEAT_TYPE_ONE:
1514 pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_1.png");
1515 pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_1_press.png");
1519 case REPEAT_TYPE_ALL:
1521 pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_all.png");
1522 pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_all_press.png");
1529 __pRepeatModeButton->SetNormalBitmap(Point(X_BASE, Y_BASE), *pRepeatBitmap);
1530 __pRepeatModeButton->SetPressedBitmap(Point(X_BASE, Y_BASE), *pRepeatPressBitmap);
1531 __pVideoPlayerPresentationModel->SetRepeatMode(repeatValue);
1532 __pVideoPlayerPresentationModel->ChangeCurrentMediaIndex();
1534 delete pRepeatBitmap;
1535 delete pRepeatPressBitmap;
1541 VideoPlayerForm::SetScreenModeButtonImage(void)
1543 AppLogDebug("SetScreenModeButtonImage");
1545 Point point(X_BASE, Y_BASE);
1546 Bitmap* pBitmapScreenMode = null;
1548 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1550 String mediaPathName = __pVideoPlayerPresentationModel->GetMediaPathName();
1551 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(mediaPathName);
1553 switch (__screenMode)
1555 case SCREEN_MODE_NORMAL:
1557 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
1559 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03.png");
1560 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1561 delete pBitmapScreenMode;
1562 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03_press.png");
1563 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1564 delete pBitmapScreenMode;
1568 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_Function_icon_screenmode_press.png");
1569 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1570 delete pBitmapScreenMode;
1571 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_Function_icon_screenmode_press.png");
1572 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1573 delete pBitmapScreenMode;
1578 case SCREEN_MODE_FULL:
1580 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode02.png");
1581 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1582 delete pBitmapScreenMode;
1583 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode02_press.png");
1584 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1585 delete pBitmapScreenMode;
1589 case SCREEN_MODE_FIT:
1591 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03.png");
1592 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1593 delete pBitmapScreenMode;
1594 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03_press.png");
1595 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1596 delete pBitmapScreenMode;
1608 VideoPlayerForm::GetTotalTime(String& totalTime)
1610 result r = E_FAILURE;
1613 dateTime.AddSeconds(__pVideoPlayerPresentationModel->GetDuration() / MILLISECOND);
1614 r = totalTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1615 TryReturnVoid(r == E_SUCCESS, "totalTime.Format() failed:%s", GetErrorMessage(r));
1619 VideoPlayerForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1621 AppLogDebug("OnOrientationChanged");
1623 AccessibilityContainer* pContainer = GetAccessibilityContainer();
1624 AccessibilityElement* pAccessibilityElement = pContainer->GetElement(L"IDL_MAIN_FORM");
1625 pAccessibilityElement->SetBounds(GetBounds());
1627 SetScreenMode(__screenMode, false);
1629 switch (orientationStatus)
1631 case ORIENTATION_STATUS_PORTRAIT:
1637 case ORIENTATION_STATUS_LANDSCAPE:
1639 case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
1651 VideoPlayerForm::PlayerSoundPathPopupInit(void)
1653 int tempAudioRouteMode = 0;
1654 int currentOutputDevice = 0;
1655 tempAudioRouteMode = __audioRouteMode;
1656 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1658 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1659 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1661 __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
1662 result r = __pSoundPathPopup->Construct(currentOutputDevice,
1663 __pAudioRouteManager->GetActiveBluetoothA2dpName(), tempAudioRouteMode);
1664 TryReturnVoid(r == E_SUCCESS, "__pSoundPathPopup->Construct() failed:%s", GetErrorMessage(r));
1668 VideoPlayerForm::CreateMessageBox(const String& title, const String& message, MessageBoxStyle style,
1669 unsigned long timeout)
1674 VideoPlayerForm::ShowControl(bool setShow)
1676 AppLogDebug("ShowControl");
1678 if (setShow == true)
1680 __pHeader->SetShowState(true);
1681 __pFunctionPanel->SetShowState(true);
1682 __pControllerPanel->SetShowState(true);
1683 __isControlVisibleState = true;
1687 __pHeader->SetShowState(false);
1688 __pFunctionPanel->SetShowState(false);
1689 __pControllerPanel->SetShowState(false);
1692 if (__pShareContextMenu != null)
1694 if (__pShareContextMenu->GetShowState() == true)
1696 __pShareContextMenu->SetShowState(false);
1700 __isControlVisibleState = false;
1705 VideoPlayerForm::CheckAppLaunchable(void)
1707 AppLogDebug("CheckAppLaunchable");
1710 CheckLowBatteryStatus();
1714 VideoPlayerForm::CancelTimerByFrameDeactivated(void)
1716 AppLogDebug("CancelTimerByFrameDeactivated");
1718 __pUiControlTimer->Cancel();
1719 __setPauseState = true;
1722 __pScreenModeButton->SetShowState(false);
1726 VideoPlayerForm::SetFrameActivated(bool frameActivated)
1728 __frameActivated = frameActivated;
1732 VideoPlayerForm::GetFrameActivated(void) const
1734 return __frameActivated;
1738 VideoPlayerForm::OnPlayContentChanged(const String& fileName)
1742 AppLogDebug("OnPlayContentChanged");
1744 GetTotalTime(totalTime);
1746 __pHeader->SetTitleText(fileName);
1747 __pHeader->Invalidate(true);
1749 __pTotalTimeLabel->SetText(totalTime);
1750 __pTotalTimeLabel->Invalidate(true);
1754 VideoPlayerForm::OnPlayTimeChanged(int currentProgressPos, String& playTime)
1756 AppLogDebug("OnPlayTimeChanged");
1758 __pSlider->SetValue(currentProgressPos);
1759 __pSlider->Invalidate(true);
1761 __pCurrenTimeLabel->SetText(playTime);
1762 __pCurrenTimeLabel->Invalidate(true);
1766 VideoPlayerForm::OnPlayStateChanged(PlayerState playState)
1768 AppLogDebug("OnPlayStateChanged");
1770 SetPlayPauseButtonImage(playState);
1772 if (playState == PLAYER_STATE_PLAYING)
1774 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1776 if (__pScreenModeButton->GetShowState() == false)
1778 __pScreenModeButton->SetShowState(true);
1783 __pUiControlTimer->Cancel();
1786 if (__pScreenModeButton->GetShowState() == true)
1788 __pScreenModeButton->SetShowState(false);
1794 VideoPlayerForm::OnPlaySeekCompleted(result r)
1796 AppLogDebug("OnPlaySeekCompleted ");
1798 if (__timeToSeek != SEEK_TIME_NONE && __pVideoPlayerPresentationModel->GetSeekCompleted())
1800 r = __pVideoPlayerPresentationModel->SeekTo(__timeToSeek);
1801 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
1802 __timeToSeek = SEEK_TIME_NONE;
1804 else if (!__sliderMoved && __playingBeforeSlide)
1806 r = __pVideoPlayerPresentationModel->StartPlay();
1807 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
1808 __playingBeforeSlide = false;
1813 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)
1829 String messageBoxString;
1830 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1831 pAppResource->GetString(IDS_COM_POP_LOW_BATTERY_UNABLE_TO_LAUNCH_APPLICATION, messageBoxString);
1833 msgBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
1834 msgBox.ShowAndWait(result);
1838 case MSGBOX_RESULT_CLOSE:
1840 OnFormBackRequested(*this);
1852 VideoPlayerForm::CheckCallStatus(void)
1854 AppLogDebug("CheckCallStatus");
1856 CallManager* pCallManager = new (std::nothrow) CallManager();
1858 result 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 int modalResult = 0;
1868 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1869 pAppResource->GetString(L"IDS_VPL_BODY_UNABLE_TO_PLAY_VIDEO_DURING_CALL", dispString);
1871 msgBox.Construct(L"", dispString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
1872 msgBox.ShowAndWait(modalResult);
1874 switch (modalResult)
1876 case MSGBOX_RESULT_CLOSE:
1878 OnFormBackRequested(*this);
1888 delete pCallManager;
1892 VideoPlayerForm::OnFormBackRequested(Form& source)
1894 AppLogDebug("OnFormBackRequested");
1896 bool frameActivated = GetFrameActivated();
1898 if (frameActivated == true)
1900 UiApp* pApp = UiApp::GetInstance();
1901 TryReturnVoid(pApp != null, "pApp is null");
1903 result r = pApp->Terminate();
1904 TryReturnVoid(r == E_SUCCESS, "Failed Terminate [%s]", GetErrorMessage(r));
1909 VideoPlayerForm::OnActiveAudioRouteChanged(const AudioRouteInfo& route)
1911 Color BtnColor(0, 0, 0, 0);
1912 int currentOutputAudioDevice = 0;
1913 ArrayList* pArgs = null;
1915 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
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 (__pSoundPathPopup != null)
1972 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1973 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1975 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1978 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1979 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
1981 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
1987 case OUTPUT_AUDIO_DEVICE_SPEAKER:
1989 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1990 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
1992 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
1994 if (__pSoundPathPopup != null)
1996 if (__pSoundPathPopup->GetShowState() == true)
1998 __pSoundPathPopup->SetShowState(false);
2002 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2003 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
2005 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2007 if (__pSoundPathPopup != null)
2009 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2010 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2012 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2015 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2016 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
2018 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2030 VideoPlayerForm::OnAudioRouteAdded(const AudioRouteInfo& route)
2032 AppLogDebug("OnAudioRouteAdded");
2034 switch (route.GetOutputAudioDevice())
2036 case OUTPUT_AUDIO_DEVICE_NONE:
2038 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2042 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2044 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2048 case OUTPUT_AUDIO_DEVICE_RECEIVER:
2050 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2054 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2056 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2060 case OUTPUT_AUDIO_DEVICE_BT_SCO:
2062 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2066 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2068 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = true;
2078 VideoPlayerForm::OnAudioRouteRemoved(const AudioRouteInfo& route)
2080 ArrayList* pArgs = null;
2081 int currentOutputDevice = 0;
2082 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2084 AppLogDebug("OnAudioRouteRemoved");
2086 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2088 switch (route.GetOutputAudioDevice())
2090 case OUTPUT_AUDIO_DEVICE_NONE:
2092 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = false;
2096 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2098 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = false;
2102 case OUTPUT_AUDIO_DEVICE_RECEIVER:
2104 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = false;
2108 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2110 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = false;
2114 case OUTPUT_AUDIO_DEVICE_BT_SCO:
2116 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = false;
2120 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2122 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = false;
2130 if (currentAudioRoute.GetOutputAudioDevice() != route.GetOutputAudioDevice())
2132 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2134 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2135 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2137 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2139 if (__pSoundPathPopup != null)
2141 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2144 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2145 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2147 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2151 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2153 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2154 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2156 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2158 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2159 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2161 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2163 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2164 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2166 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2168 if (__pSoundPathPopup != null)
2170 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2171 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2173 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2176 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2177 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2179 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2183 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2185 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2186 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2188 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2190 if (__pSoundPathPopup != null)
2192 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2195 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2196 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2198 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2201 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2202 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2204 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2206 if (__pSoundPathPopup != null)
2208 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2209 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2211 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2214 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2215 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2217 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2220 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2221 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2223 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2225 if (__pSoundPathPopup != null)
2227 if (__pSoundPathPopup->GetShowState() == true)
2229 __pSoundPathPopup->SetShowState(false);
2238 VideoPlayerForm::InitAudioRouteList(void)
2240 AppLogDebug("InitAudioRouteList");
2243 IList* availableAudioRouteList = null;
2244 AudioRouteInfo* tempRouteInfo = null;
2245 AudioRouteInfo availableRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2246 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2248 availableAudioRouteList = __pAudioRouteManager->GetAvailableAudioRouteListN();
2250 if (availableAudioRouteList != null)
2252 for (listCount = 0; listCount < availableAudioRouteList->GetCount(); ++listCount)
2254 tempRouteInfo = static_cast<AudioRouteInfo*>(availableAudioRouteList->GetAt(listCount));
2255 availableRouteInfo = *tempRouteInfo;
2257 if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_NONE)
2259 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2261 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2263 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2265 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_RECEIVER)
2267 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2269 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2271 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2273 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_SCO)
2275 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2279 __availableAudioRoute[OUTPUT_AUDIO_DEVICE_BT_A2DP] = true;
2283 availableAudioRouteList->RemoveAll(true);
2284 delete availableAudioRouteList;
2285 availableAudioRouteList = null;
2287 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2289 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2291 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2292 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2294 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2296 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2297 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2299 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2301 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2302 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2304 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2307 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2309 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2310 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2312 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2314 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2315 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2317 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2319 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2320 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2322 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2325 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2327 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2328 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2330 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2332 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2333 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2335 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2337 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2338 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2340 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2346 VideoPlayerForm::SetActiveAudioRoute(const AudioRouteInfo& route)
2348 AppLogDebug("SetActiveAudioRoute");
2349 result r = __pAudioRouteManager->SetActiveAudioRoute(route);
2355 VideoPlayerForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
2357 BatteryLevel batteryLevel;
2358 bool isCharging = false;
2360 AppLogDebug("OnUserEventReceivedN");
2364 case REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED:
2366 Battery::GetCurrentLevel(batteryLevel);
2367 Battery::IsCharging(isCharging);
2369 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
2371 bool frameActivated = GetFrameActivated();
2373 if (isCharging == false && frameActivated == true)
2375 OnFormBackRequested(*this);
2387 VideoPlayerForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId,
2388 AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
2390 AppLogDebug("OnAppControlCompleteResponseReceived : %d", appControlResult);
2392 VideoPlayerApp* pVideoPlayerApp = static_cast<VideoPlayerApp*>(VideoPlayerApp::GetInstance());
2393 TryReturnVoid(pVideoPlayerApp != null, "pVideoPlayerApp is null");
2394 pVideoPlayerApp->SetFrameEnabled(true);
2398 VideoPlayerForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
2400 PlayerState playState = PLAYER_STATE_ERROR;
2401 result r = E_FAILURE;
2403 __sliderMoved = true;
2405 playState = __pVideoPlayerPresentationModel->GetState();
2407 if (playState == PLAYER_STATE_PLAYING)
2409 result r = __pVideoPlayerPresentationModel->PausePlay();
2410 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
2411 __playingBeforeSlide = true;
2413 else if (playState == PLAYER_STATE_PAUSED)
2415 long seekTime = value * (__pVideoPlayerPresentationModel->GetDuration() / MAX_PROGRESS_RANGE);
2417 if (__pVideoPlayerPresentationModel->GetSeekCompleted())
2419 r = __pVideoPlayerPresentationModel->SeekTo(seekTime);
2420 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
2426 dateTime.AddSeconds(seekTime / MILLISECOND);
2427 r = currentTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
2428 TryReturnVoid(r == E_SUCCESS, "currentTime.Format() failed:%s", GetErrorMessage(r));
2430 __pCurrenTimeLabel->SetText(currentTime);
2431 __pCurrenTimeLabel->Invalidate(true);