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);
501 __pFastForwardButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_FASTFORWARD));
502 TryCatch(__pFastForwardButton != null, r = E_SYSTEM, "__pFastForwardButton is null");
503 __pFastForwardButton->SetActionId(IDA_BUTTON_FASTFORWARD);
504 __pFastForwardButton->AddActionEventListener(*this);
505 __pFastForwardButton->AddTouchEventListener(*this);
506 __pFastForwardButton->AddKeyEventListener(*this);
508 SetFormBackEventListener(this);
510 __pCurrenTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_LABEL_CURRENTTIME));
511 TryCatch(__pCurrenTimeLabel != null, r = E_SYSTEM, "__pCurrenTimeLabel is null");
512 __pCurrenTimeLabel->AddTouchEventListener(*this);
514 __pTotalTimeLabel = static_cast<Label*>(__pControllerPanel->GetControl(IDC_LABEL_FULLTIME));
515 TryCatch(__pTotalTimeLabel != null, r = E_SYSTEM, "__pTotalTimeLabel is null");
516 __pTotalTimeLabel->AddTouchEventListener(*this);
518 __pSlider = static_cast<Slider*>(__pControllerPanel->GetControl(IDC_SLIDER));
519 TryCatch(__pSlider != null, r = E_SYSTEM, "__pSlider is null");
520 __pSlider->SetEnabled(true);
521 __pSlider->SetRange(MIN_PROGRESS_RANGE, MAX_PROGRESS_RANGE);
522 __pSlider->SetValue(MIN_PROGRESS_RANGE);
523 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL,
524 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
525 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED,
526 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
527 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED,
528 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
530 pSliderThumbNormalBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle.png");
531 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *pSliderThumbNormalBitmap);
532 TryCatch(r == E_SUCCESS,, "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
534 pSliderThumbPressedBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle_press.png");
535 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *pSliderThumbPressedBitmap);
536 TryCatch(r == E_SUCCESS,, "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
538 pSliderThumbDisableBitmap = pAppResource->GetBitmapN(L"T01_2_control_progress_handle.png");
539 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_DISABLED, *pSliderThumbDisableBitmap);
540 TryCatch(r == E_SUCCESS,, "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
542 __pSlider->AddAdjustmentEventListener(*this);
543 __pSlider->AddTouchEventListener(*this);
544 __pSlider->AddSliderEventListener(*this);
545 __pSlider->AddKeyEventListener(*this);
548 delete pSliderThumbNormalBitmap;
549 delete pSliderThumbPressedBitmap;
550 delete pSliderThumbDisableBitmap;
556 VideoPlayerForm::OnTerminating(void)
558 AppLogDebug("OnTerminating");
560 AccessibilityContainer* pContainer = null;
563 DestroyPresentationModelInstance();
565 __pVideoPlayerPresentationModel = null;
567 if (__pOverlayPanel != null)
569 pContainer = __pOverlayPanel->GetAccessibilityContainer();
570 pContainer->RemoveAllElements();
571 RemoveControl(__pOverlayPanel);
572 __pOverlayPanel = null;
575 delete __pSoundPathPopup;
576 __pSoundPathPopup = null;
578 delete __pShareContextMenu;
579 __pShareContextMenu = null;
581 pContainer = GetAccessibilityContainer();
582 pContainer->RemoveAllElements();
588 VideoPlayerForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
590 AppLogDebug("OnSceneActivatedN");
592 TryReturnVoid(__pVideoPlayerPresentationModel != null, "__pVideoPlayerPresentationModel is null");
594 SetScreenModeButtonImage();
598 VideoPlayerForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
600 result r = E_FAILURE;
602 AppLogDebug("OnSceneDeactivated");
604 r = __pVideoPlayerPresentationModel->PausePlay();
605 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
609 VideoPlayerForm::OnPlayOpened(result r)
611 AppLogDebug("OnPlayOpened");
615 VideoPlayerForm::OnPlayEndOfClip(bool playNextContent, int repeatMode, int mediaCount)
617 result r = E_FAILURE;
619 Point point(X_BASE, Y_BASE);
620 Bitmap* pPlayBitmap = null;
622 AppLogDebug("OnPlayEndOfClip : %d", playNextContent);
624 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
626 if (__pSoundPathPopup != null)
628 if (__pSoundPathPopup->GetShowState() == true)
630 __pSoundPathPopup->SetShowState(false);
634 __pUiControlTimer->Cancel();
636 UpdateProgressBar(SLIDER_START_VALUE);
638 __pCurrenTimeLabel->SetText(SLIDER_INIT_TIME);
639 __pCurrenTimeLabel->Invalidate(true);
641 pPlayBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_play.png");
642 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
644 __pPlayPauseButton->SetNormalBitmap(point, *pPlayBitmap);
645 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
648 __pSlider->SetEnabled(false);
650 if (__pScreenModeButton->GetShowState() == true)
652 __pScreenModeButton->SetShowState(false);
657 case REPEAT_TYPE_OFF:
659 if (mediaCount < MULTI_CONTENT_COUNT)
661 r = PowerManager::KeepScreenOnState(false);
662 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
666 if (playNextContent == true && __setPauseState == false)
668 SetScreenMode(SCREEN_MODE_NORMAL, true);
669 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
671 r = __pVideoPlayerPresentationModel->StartPlay();
672 TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
674 SetScreenModeButtonImage();
676 __pSlider->SetEnabled(true);
678 if (__pScreenModeButton->GetShowState() == false)
680 __pScreenModeButton->SetShowState(true);
683 r = PowerManager::KeepScreenOnState(true, false);
684 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
690 case REPEAT_TYPE_ONE:
692 if (__setPauseState == false)
694 r = __pVideoPlayerPresentationModel->StartPlay();
695 TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
697 __pSlider->SetEnabled(true);
699 SetScreenModeButtonImage();
700 if (__pScreenModeButton->GetShowState() == false)
702 __pScreenModeButton->SetShowState(true);
705 r = PowerManager::KeepScreenOnState(true, false);
706 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
711 case REPEAT_TYPE_ALL:
713 if ( __setPauseState == false)
715 if (mediaCount < MULTI_CONTENT_COUNT)
717 r = __pVideoPlayerPresentationModel->StartPlay();
718 TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
722 SetScreenMode(SCREEN_MODE_NORMAL, true);
723 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
725 r = __pVideoPlayerPresentationModel->StartPlay();
726 TryCatch(r == E_SUCCESS,, "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
729 __pSlider->SetEnabled(true);
731 SetScreenModeButtonImage();
732 if (__pScreenModeButton->GetShowState() == false)
734 __pScreenModeButton->SetShowState(true);
737 r = PowerManager::KeepScreenOnState(true, false);
738 TryCatch(r == E_SUCCESS,, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
752 VideoPlayerForm::OnPlayBuffering(int percent)
754 AppLogDebug("OnPlayBuffering");
758 VideoPlayerForm::OnPlayErrorOccurred(PlayerErrorReason r)
760 MessageBox messageBox;
761 String messageBoxString;
763 AppResource* pAppResource = null;
765 AppLogDebug("OnPlayErrorOccurred [%d]", r);
769 case PLAYER_ERROR_INVALID_DATA:
771 __pVideoPlayerPresentationModel->StopPlay();
773 pAppResource = Application::GetInstance()->GetAppResource();
774 pAppResource->GetString(IDS_COM_POP_UNSUPPORTED_FILE_TYPE, messageBoxString);
776 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
777 messageBox.ShowAndWait(modalResult);
779 UiApp* pApp = UiApp::GetInstance();
780 TryReturnVoid(pApp != null, "pApp is null");
785 case PLAYER_ERROR_DEVICE_FAILED:
787 __pVideoPlayerPresentationModel->StopPlay();
789 pAppResource = Application::GetInstance()->GetAppResource();
790 pAppResource->GetString(IDS_VPL_POP_UNABLE_TO_PLAY_VIDEO_ERROR_OCCURRED, messageBoxString);
792 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
793 messageBox.ShowAndWait(modalResult);
795 UiApp* pApp = UiApp::GetInstance();
796 TryReturnVoid(pApp != null, "pApp is null");
807 VideoPlayerForm::OnPlayInterrupted(void)
809 AppLogDebug("OnPlayInterrupted");
813 VideoPlayerForm::OnPlayReleased(void)
815 AppLogDebug("OnPlayReleased");
819 VideoPlayerForm::OnActionPerformed(const Control& source, int actionId)
821 result r = E_FAILURE;
826 Point point(X_BASE, Y_BASE);
828 PlayerState playState = PLAYER_STATE_ERROR;
829 AppLogDebug("OnActionPerformed : %d", actionId);
831 playState = __pVideoPlayerPresentationModel->GetState();
833 Rectangle clientRect = GetClientAreaBounds();
837 case IDA_BUTTON_PLAY:
839 __setPauseState = false;
841 if (playState == PLAYER_STATE_ENDOFCLIP)
843 if (__pVideoPlayerPresentationModel->GetMediaCount() >= MULTI_CONTENT_COUNT)
845 int repeatMode = __pVideoPlayerPresentationModel->GetRepeatMode();
847 if (repeatMode == REPEAT_TYPE_OFF || repeatMode == REPEAT_TYPE_ALL)
849 SetScreenMode(SCREEN_MODE_NORMAL, true);
850 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
855 r = __pVideoPlayerPresentationModel->StartPlay();
856 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
858 __pSlider->SetEnabled(true);
860 SetScreenModeButtonImage();
862 if (__pScreenModeButton->GetShowState() == false)
864 __pScreenModeButton->SetShowState(true);
867 r = PowerManager::KeepScreenOnState(true, false);
868 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
872 case IDA_BUTTON_PAUSE:
874 __setPauseState = true;
876 r = __pVideoPlayerPresentationModel->PausePlay();
877 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
879 if (__pScreenModeButton->GetShowState() == true)
881 __pScreenModeButton->SetShowState(false);
884 r = PowerManager::KeepScreenOnState(false);
885 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
889 case IDA_BUTTON_FULLSCREEN:
891 if (playState == PLAYER_STATE_PLAYING)
893 __pUiControlTimer->Cancel();
894 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
901 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
902 __pVideoPlayerPresentationModel->GetMediaPathName());
904 if (rect.width == 0 || rect.height == 0)
909 switch (__screenMode)
911 case SCREEN_MODE_FIT:
913 r = SetScreenMode(SCREEN_MODE_FULL, true);
914 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
916 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
917 __pVideoPlayerPresentationModel->SetRenderingBuffer();
919 SetScreenModeButtonImage();
923 case SCREEN_MODE_FULL:
925 r = SetScreenMode(SCREEN_MODE_NORMAL, true);
926 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
928 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
929 __pVideoPlayerPresentationModel->SetRenderingBuffer();
931 SetScreenModeButtonImage();
935 case SCREEN_MODE_NORMAL:
937 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
939 r = SetScreenMode(SCREEN_MODE_FULL, true);
940 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
942 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
943 __pVideoPlayerPresentationModel->SetRenderingBuffer();
947 r = SetScreenMode(SCREEN_MODE_FIT, true);
948 TryReturnVoid(r == E_SUCCESS, "SetScreenMode() failed:%s", GetErrorMessage(r));
950 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
951 __pVideoPlayerPresentationModel->SetRenderingBuffer();
953 SetScreenModeButtonImage();
963 case IDA_BUTTON_SOUNDPATH:
965 if (__pSoundPathPopup == null)
967 PlayerSoundPathPopupInit();
970 if (playState == PLAYER_STATE_PLAYING)
972 __pUiControlTimer->Cancel();
973 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
975 __pSoundPathPopup->ShowPopup(true);
979 case IDA_BUTTON_FASTFORWARD:
981 if (__actionTouchLongPressed == true)
983 __actionTouchLongPressed = false;
987 if (playState == PLAYER_STATE_PLAYING)
989 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
992 __pVideoPlayerPresentationModel->Forward();
996 case IDA_BUTTON_FASTREWIND:
998 if (__actionTouchLongPressed == true)
1000 __actionTouchLongPressed = false;
1004 if (playState == PLAYER_STATE_PLAYING)
1006 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1009 __pVideoPlayerPresentationModel->Rewind();
1013 case IDA_BUTTON_SHARE:
1015 Point point((((GetClientAreaBounds().width - __pFunctionPanel->GetBounds().width) / DIVIDE_BY_TWO)
1016 + (__pShareButton->GetBounds().width / DIVIDE_BY_TWO)),
1017 __pFunctionPanel->GetBounds().y + __pFunctionPanel->GetBounds().height);
1019 if (__pShareContextMenu != null)
1021 delete __pShareContextMenu;
1022 __pShareContextMenu = null;
1025 __pShareContextMenu = new (std::nothrow) ContextMenu();
1026 r = __pShareContextMenu->Construct(point, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD);
1027 TryReturnVoid(r == E_SUCCESS, "__pShareContextMenu->Construct() failed:%s", GetErrorMessage(r));
1030 Bitmap* pBitmapMsg = null;
1031 Bitmap* pBitmapEmail = null;
1032 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1034 pAppResource->GetString(L"IDS_COM_BODY_MESSAGE", menuItemStr);
1035 pBitmapMsg = pAppResource->GetBitmapN(IDB_MENU_ICON_MESSAGE);
1036 __pShareContextMenu->AddItem(menuItemStr, IDA_CONTEXTMENU_MESSAGE, *pBitmapMsg);
1039 pAppResource->GetString(L"IDS_COM_BODY_EMAIL", menuItemStr);
1040 pBitmapEmail = pAppResource->GetBitmapN(IDB_MENU_ICON_EMAIL);
1041 __pShareContextMenu->AddItem(menuItemStr, IDA_CONTEXTMENU_EMAIL, *pBitmapEmail);
1042 delete pBitmapEmail;
1044 __pShareContextMenu->SetFocusable(true);
1045 __pShareContextMenu->AddActionEventListener(*this);
1046 __pShareContextMenu->SetShowState(true);
1047 __pShareContextMenu->Show();
1049 if (playState == PLAYER_STATE_PLAYING)
1051 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1056 case IDA_CONTEXTMENU_MESSAGE:
1058 AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_MESSAGE, APPCONTROL_OPERATION_ID_COMPOSE);
1059 TryReturnVoid(pAppControl != null, "pAppControl is null");
1061 String filePath = __pVideoPlayerPresentationModel->GetMediaPathName();
1063 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1064 r = pDataList->Construct();
1066 if ( r != E_SUCCESS)
1074 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1075 pList->Add(new (std::nothrow) String(filePath));
1076 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
1077 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE), new (std::nothrow) String(APPCONTROL_DATA_MMS));
1078 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_RETURN_RESULT), new (std::nothrow) String("true"));
1080 r = pAppControl->Start(null, null, pDataList, this);
1084 VideoPlayerApp* pVideoPlayerApp = static_cast<VideoPlayerApp*>(VideoPlayerApp::GetInstance());
1085 pVideoPlayerApp->SetFrameEnabled(false);
1088 pDataList->RemoveAll(true);
1096 case IDA_CONTEXTMENU_EMAIL:
1098 AppControl* pAppControl = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE);
1099 TryReturnVoid(pAppControl != null, "pAppControl is null");
1101 String filePath = __pVideoPlayerPresentationModel->GetMediaPathName();
1103 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1105 r = pDataList->Construct();
1107 if ( r != E_SUCCESS)
1114 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1115 pList->Add(new (std::nothrow) String(filePath));
1116 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pList);
1118 r = pAppControl->Start(null, null, pDataList, this);
1122 VideoPlayerApp* pVideoPlayerApp = static_cast<VideoPlayerApp*>(VideoPlayerApp::GetInstance());
1123 pVideoPlayerApp->SetFrameEnabled(false);
1126 pDataList->RemoveAll(true);
1133 case IDA_BUTTON_REPEATMODE:
1135 int repeatMode = __pVideoPlayerPresentationModel->GetRepeatMode();
1139 case REPEAT_TYPE_OFF:
1141 SetRepeatButtonImage(REPEAT_TYPE_ONE);
1145 case REPEAT_TYPE_ONE:
1147 if (__pVideoPlayerPresentationModel->GetMediaCount() > 1)
1149 SetRepeatButtonImage(REPEAT_TYPE_ALL);
1153 SetRepeatButtonImage(REPEAT_TYPE_OFF);
1158 case REPEAT_TYPE_ALL:
1160 SetRepeatButtonImage(REPEAT_TYPE_OFF);
1168 if (playState == PLAYER_STATE_PLAYING)
1170 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1175 case IDA_BUTTON_BACK:
1177 Application::GetInstance()->Terminate();
1187 VideoPlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition,
1188 const TouchEventInfo& touchInfo)
1190 AppLogDebug("OnTouchPressed Control : %ls", source.GetName().GetPointer());
1191 __pUiControlTimer->Cancel();
1195 VideoPlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition,
1196 const TouchEventInfo& touchInfo)
1198 AppLogDebug("OnTouchReleased Control : %ls", source.GetName().GetPointer());
1200 PlayerState playState = PLAYER_STATE_ERROR;
1202 if ((&source == __pFastForwardButton
1203 || &source == __pFastRewindButton)
1204 && __actionTouchLongPressed == true)
1206 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1209 playState = __pVideoPlayerPresentationModel->GetState();
1211 if (playState == PLAYER_STATE_PLAYING || playState == PLAYER_STATE_PAUSED || playState == PLAYER_STATE_ENDOFCLIP)
1213 if (source.GetName() == L"IDL_MAIN_FORM"
1214 || source.GetHashCode() == __pOverlayPanel->GetHashCode()
1215 || source.GetHashCode() == __pHeader->GetHashCode())
1217 if (__isControlVisibleState == true)
1219 if (source.GetHashCode() == __pHeader->GetHashCode())
1221 if (__pUiControlTimer != null)
1223 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1235 if (__pUiControlTimer != null)
1237 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1241 else if (source.GetHashCode() == __pSlider->GetHashCode() && __playingBeforeSlide == true)
1243 result r = __pVideoPlayerPresentationModel->StartPlay();
1244 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
1245 __playingBeforeSlide = false;
1251 VideoPlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition,
1252 const TouchEventInfo& touchInfo)
1254 AppLogDebug("OnTouchLongPressed Control : %ls", source.GetName().GetPointer());
1256 if (&source == __pFastForwardButton)
1258 __actionTouchLongPressed = true;
1260 if (__setPauseState == true)
1262 __pVideoPlayerPresentationModel->FastForward(false);
1266 __pVideoPlayerPresentationModel->FastForward(true);
1269 else if (&source == __pFastRewindButton)
1271 __actionTouchLongPressed = true;
1273 if (__setPauseState == true)
1275 __pVideoPlayerPresentationModel->FastRewind(false);
1279 __pVideoPlayerPresentationModel->FastRewind(true);
1282 else if (&source == __pSlider)
1284 PlayerState playState = PLAYER_STATE_ERROR;
1285 playState = __pVideoPlayerPresentationModel->GetState();
1287 if (playState == PLAYER_STATE_PLAYING)
1289 result r = __pVideoPlayerPresentationModel->PausePlay();
1290 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
1291 __playingBeforeSlide = true;
1297 VideoPlayerForm::OnTimerExpired(Timer& timer)
1299 if (timer.GetHashCode() == __pUiControlTimer->GetHashCode())
1301 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1309 VideoPlayerForm::OnAdjustmentValueChanged(const Control& source, int adjustment)
1311 result r = E_FAILURE;
1314 AppLogDebug("OnAdjustmentValueChanged : %d", adjustment);
1316 if (source.GetHashCode() == __pSlider->GetHashCode() && __sliderMoved == true
1317 && adjustment >= MIN_PROGRESS_RANGE && adjustment <= MAX_PROGRESS_RANGE)
1319 __sliderMoved = false;
1321 seekTime = adjustment * (__pVideoPlayerPresentationModel->GetDuration() / MAX_PROGRESS_RANGE);
1322 if (__pVideoPlayerPresentationModel->GetSeekCompleted())
1324 r = __pVideoPlayerPresentationModel->SeekTo(seekTime);
1325 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
1329 __timeToSeek = seekTime;
1332 UpdateProgressBar(adjustment);
1335 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1337 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1342 VideoPlayerForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1344 __pUiControlTimer->Cancel();
1348 VideoPlayerForm::OnKeyReleased(const Control& source, KeyCode keyCode)
1350 AppLogDebug("OnKeyReleased Control : %ls, KeyCode : %d", source.GetName().GetPointer(), keyCode);
1352 if ((&source == __pFastForwardButton
1353 || &source == __pFastRewindButton)
1354 && __actionTouchLongPressed == true)
1356 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1359 if (source.GetName() == L"IDL_MAIN_FORM" && __isControlVisibleState == false)
1363 if (__pUiControlTimer != null)
1365 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1371 VideoPlayerForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1373 AppLogDebug("OnKeyLongPressed Control : %ls, KeyCode : %d", source.GetName().GetPointer(), keyCode);
1375 if (keyCode == KEY_ENTER)
1377 if (&source == __pFastForwardButton)
1379 __actionTouchLongPressed = true;
1381 if (__setPauseState == true)
1383 __pVideoPlayerPresentationModel->FastForward(false);
1387 __pVideoPlayerPresentationModel->FastForward(true);
1390 else if (&source == __pFastRewindButton)
1392 __actionTouchLongPressed = true;
1394 if (__setPauseState == true)
1396 __pVideoPlayerPresentationModel->FastRewind(false);
1400 __pVideoPlayerPresentationModel->FastRewind(true);
1407 VideoPlayerForm::UpdateProgressBar(const int currentPlayTime)
1409 TryReturnVoid(__pSlider, "__pSlider is null");
1411 __pSlider->SetValue(currentPlayTime);
1412 __pSlider->Invalidate(true);
1416 VideoPlayerForm::InitTimer(void)
1418 __pUiControlTimer = new (std::nothrow) Timer();
1419 __pUiControlTimer->Construct(*this);
1423 VideoPlayerForm::DeleteTimer(void)
1425 if (__pUiControlTimer != null)
1427 __pUiControlTimer->Cancel();
1428 delete __pUiControlTimer;
1429 __pUiControlTimer = null;
1434 VideoPlayerForm::SetPlayPauseButtonImage(PlayerState playState)
1436 result r = E_SUCCESS;
1438 Bitmap* pPlayBitmap = null;
1439 Bitmap* pPauseBitmap = null;
1440 Point point(X_BASE, Y_BASE);
1442 AppLogDebug("SetPlayPauseButtonImage : %d", playState);
1444 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1446 __pPlayPauseButton = static_cast<Button*>(__pControllerPanel->GetControl(IDC_BUTTON_PLAY));
1447 TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
1449 if (playState == PLAYER_STATE_PLAYING)
1451 pPauseBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_pause.png");
1452 TryCatch(pPauseBitmap != null, r = E_SYSTEM, "pPauseBitmap is null");
1454 __pPlayPauseButton->SetNormalBitmap(point, *pPauseBitmap);
1456 __pPlayPauseButton->SetActionId(IDA_BUTTON_PAUSE);
1457 __pPlayPauseButton->Invalidate(true);
1459 delete pPauseBitmap;
1463 pPlayBitmap = pAppResource->GetBitmapN(L"T01-2_control_circle_icon_play.png");
1464 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
1466 __pPlayPauseButton->SetNormalBitmap(point, *pPlayBitmap);
1468 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
1469 __pPlayPauseButton->Invalidate(true);
1480 VideoPlayerForm::SetRepeatButtonImage(int repeatValue)
1482 AppLogDebug("SetRepeatButtonImage");
1483 Bitmap* pRepeatBitmap = null;
1484 Bitmap* pRepeatPressBitmap = null;
1486 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1488 switch (repeatValue)
1490 case REPEAT_TYPE_OFF:
1492 pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat.png");
1493 pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_press.png");
1497 case REPEAT_TYPE_ONE:
1499 pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_1.png");
1500 pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_1_press.png");
1504 case REPEAT_TYPE_ALL:
1506 pRepeatBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_all.png");
1507 pRepeatPressBitmap = pAppResource->GetBitmapN(L"T01-2_function_icon_repeat_all_press.png");
1514 __pRepeatModeButton->SetNormalBitmap(Point(X_BASE, Y_BASE), *pRepeatBitmap);
1515 __pRepeatModeButton->SetPressedBitmap(Point(X_BASE, Y_BASE), *pRepeatPressBitmap);
1516 __pVideoPlayerPresentationModel->SetRepeatMode(repeatValue);
1517 __pVideoPlayerPresentationModel->ChangeCurrentMediaIndex();
1519 delete pRepeatBitmap;
1520 delete pRepeatPressBitmap;
1526 VideoPlayerForm::SetScreenModeButtonImage(void)
1528 AppLogDebug("SetScreenModeButtonImage");
1530 Point point(X_BASE, Y_BASE);
1531 Bitmap* pBitmapScreenMode = null;
1533 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1535 String mediaPathName = __pVideoPlayerPresentationModel->GetMediaPathName();
1536 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(mediaPathName);
1538 switch (__screenMode)
1540 case SCREEN_MODE_NORMAL:
1542 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
1544 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03.png");
1545 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1546 delete pBitmapScreenMode;
1547 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03_press.png");
1548 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1549 delete pBitmapScreenMode;
1553 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_Function_icon_screenmode_press.png");
1554 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1555 delete pBitmapScreenMode;
1556 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_Function_icon_screenmode_press.png");
1557 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1558 delete pBitmapScreenMode;
1563 case SCREEN_MODE_FULL:
1565 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode02.png");
1566 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1567 delete pBitmapScreenMode;
1568 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode02_press.png");
1569 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1570 delete pBitmapScreenMode;
1574 case SCREEN_MODE_FIT:
1576 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03.png");
1577 __pScreenModeButton->SetNormalBitmap(point, *pBitmapScreenMode);
1578 delete pBitmapScreenMode;
1579 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01-2_function_icon_screenmode03_press.png");
1580 __pScreenModeButton->SetPressedBitmap(point, *pBitmapScreenMode);
1581 delete pBitmapScreenMode;
1593 VideoPlayerForm::GetTotalTime(String& totalTime)
1595 result r = E_FAILURE;
1598 dateTime.AddSeconds(__pVideoPlayerPresentationModel->GetDuration() / MILLISECOND);
1599 r = totalTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1600 TryReturnVoid(r == E_SUCCESS, "totalTime.Format() failed:%s", GetErrorMessage(r));
1604 VideoPlayerForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1606 AppLogDebug("OnOrientationChanged");
1608 AccessibilityContainer* pContainer = GetAccessibilityContainer();
1609 AccessibilityElement* pAccessibilityElement = pContainer->GetElement(L"IDL_MAIN_FORM");
1610 pAccessibilityElement->SetBounds(GetBounds());
1612 SetScreenMode(__screenMode, false);
1614 switch (orientationStatus)
1616 case ORIENTATION_STATUS_PORTRAIT:
1622 case ORIENTATION_STATUS_LANDSCAPE:
1624 case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
1636 VideoPlayerForm::PlayerSoundPathPopupInit(void)
1638 int tempAudioRouteMode = 0;
1639 int currentOutputDevice = 0;
1640 tempAudioRouteMode = __audioRouteMode;
1641 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1643 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1644 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1646 __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
1647 result r = __pSoundPathPopup->Construct(currentOutputDevice,
1648 __pAudioRouteManager->GetActiveBluetoothA2dpName(), tempAudioRouteMode);
1649 TryReturnVoid(r == E_SUCCESS, "__pSoundPathPopup->Construct() failed:%s", GetErrorMessage(r));
1653 VideoPlayerForm::CreateMessageBox(const String& title, const String& message, MessageBoxStyle style,
1654 unsigned long timeout)
1659 VideoPlayerForm::ShowControl(bool setShow)
1661 AppLogDebug("ShowControl");
1663 if (setShow == true)
1665 __pHeader->SetShowState(true);
1666 __pFunctionPanel->SetShowState(true);
1667 __pControllerPanel->SetShowState(true);
1668 __isControlVisibleState = true;
1672 __pHeader->SetShowState(false);
1673 __pFunctionPanel->SetShowState(false);
1674 __pControllerPanel->SetShowState(false);
1677 if (__pShareContextMenu != null)
1679 if (__pShareContextMenu->GetShowState() == true)
1681 __pShareContextMenu->SetShowState(false);
1685 __isControlVisibleState = false;
1690 VideoPlayerForm::CheckAppLaunchable(void)
1692 AppLogDebug("CheckAppLaunchable");
1695 CheckLowBatteryStatus();
1699 VideoPlayerForm::CancelTimerByFrameDeactivated(void)
1701 AppLogDebug("CancelTimerByFrameDeactivated");
1703 __pUiControlTimer->Cancel();
1704 __setPauseState = true;
1707 __pScreenModeButton->SetShowState(false);
1711 VideoPlayerForm::SetFrameActivated(bool frameActivated)
1713 __frameActivated = frameActivated;
1717 VideoPlayerForm::GetFrameActivated(void) const
1719 return __frameActivated;
1723 VideoPlayerForm::OnPlayContentChanged(const String& fileName)
1727 AppLogDebug("OnPlayContentChanged");
1729 GetTotalTime(totalTime);
1731 __pHeader->SetTitleText(fileName);
1732 __pHeader->Invalidate(true);
1734 __pTotalTimeLabel->SetText(totalTime);
1735 __pTotalTimeLabel->Invalidate(true);
1739 VideoPlayerForm::OnPlayTimeChanged(int currentProgressPos, String& playTime)
1741 AppLogDebug("OnPlayTimeChanged");
1743 __pSlider->SetValue(currentProgressPos);
1744 __pSlider->Invalidate(true);
1746 __pCurrenTimeLabel->SetText(playTime);
1747 __pCurrenTimeLabel->Invalidate(true);
1751 VideoPlayerForm::OnPlayStateChanged(PlayerState playState)
1753 AppLogDebug("OnPlayStateChanged");
1755 SetPlayPauseButtonImage(playState);
1757 if (playState == PLAYER_STATE_PLAYING)
1759 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1761 if (__pScreenModeButton->GetShowState() == false)
1763 __pScreenModeButton->SetShowState(true);
1768 __pUiControlTimer->Cancel();
1771 if (__pScreenModeButton->GetShowState() == true)
1773 __pScreenModeButton->SetShowState(false);
1779 VideoPlayerForm::OnPlaySeekCompleted(result r)
1781 AppLogDebug("OnPlaySeekCompleted ");
1783 if (__timeToSeek != SEEK_TIME_NONE && __pVideoPlayerPresentationModel->GetSeekCompleted())
1785 r = __pVideoPlayerPresentationModel->SeekTo(__timeToSeek);
1786 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
1787 __timeToSeek = SEEK_TIME_NONE;
1789 else if (!__sliderMoved && __playingBeforeSlide)
1791 r = __pVideoPlayerPresentationModel->StartPlay();
1792 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
1793 __playingBeforeSlide = false;
1798 VideoPlayerForm::CheckLowBatteryStatus(void)
1800 bool isCharging = false;
1801 BatteryLevel batteryLevel;
1803 AppLogDebug("CheckLowBatteryStatus");
1805 Battery::GetCurrentLevel(batteryLevel);
1806 Battery::IsCharging(isCharging);
1808 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
1810 if (isCharging == false)
1814 String messageBoxString;
1815 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1816 pAppResource->GetString(IDS_COM_POP_LOW_BATTERY_UNABLE_TO_LAUNCH_APPLICATION, messageBoxString);
1818 msgBox.Construct(L"", messageBoxString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
1819 msgBox.ShowAndWait(result);
1823 case MSGBOX_RESULT_CLOSE:
1825 OnFormBackRequested(*this);
1837 VideoPlayerForm::CheckCallStatus(void)
1839 AppLogDebug("CheckCallStatus");
1841 CallManager* pCallManager = new (std::nothrow) CallManager();
1843 result r = pCallManager->Construct();
1844 TryCatch(r == E_SUCCESS,, "pCallManager->Construct() failed : %s", GetErrorMessage(r));
1846 if (pCallManager->GetCurrentCallStatus() != CALL_STATUS_IDLE
1847 && pCallManager->GetCurrentCallStatus() != CALL_STATUS_UNDEFINED)
1849 int modalResult = 0;
1853 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1854 pAppResource->GetString(L"IDS_VPL_BODY_UNABLE_TO_PLAY_VIDEO_DURING_CALL", dispString);
1856 msgBox.Construct(L"", dispString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIMEOUT);
1857 msgBox.ShowAndWait(modalResult);
1859 switch (modalResult)
1861 case MSGBOX_RESULT_CLOSE:
1863 OnFormBackRequested(*this);
1873 delete pCallManager;
1877 VideoPlayerForm::OnFormBackRequested(Form& source)
1879 AppLogDebug("OnFormBackRequested");
1881 bool frameActivated = GetFrameActivated();
1883 if (frameActivated == true)
1885 UiApp* pApp = UiApp::GetInstance();
1886 TryReturnVoid(pApp != null, "pApp is null");
1888 result r = pApp->Terminate();
1889 TryReturnVoid(r == E_SUCCESS, "Failed Terminate [%s]", GetErrorMessage(r));
1894 VideoPlayerForm::OnActiveAudioRouteChanged(const AudioRouteInfo& route)
1896 Color BtnColor(0, 0, 0, 0);
1897 int currentOutputAudioDevice = 0;
1898 ArrayList* pArgs = null;
1900 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1902 AppLogDebug("OnActiveAudioRouteChanged");
1904 switch (route.GetOutputAudioDevice())
1906 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
1908 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
1909 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1911 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1913 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1914 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1916 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
1918 if (__pSoundPathPopup != null)
1920 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1923 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1924 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1926 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
1932 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
1934 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
1935 &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1937 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1939 if (__pSoundPathPopup != null)
1941 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1944 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1946 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU,
1950 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
1951 &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1953 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
1955 if (__pSoundPathPopup != null)
1957 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1958 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1960 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1963 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1964 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
1966 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
1972 case OUTPUT_AUDIO_DEVICE_SPEAKER:
1974 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1975 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
1977 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
1979 if (__pSoundPathPopup != null)
1981 if (__pSoundPathPopup->GetShowState() == true)
1983 __pSoundPathPopup->SetShowState(false);
1987 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
1988 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
1990 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
1992 if (__pSoundPathPopup != null)
1994 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1995 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1997 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2000 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2001 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
2003 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2015 VideoPlayerForm::OnAudioRouteAdded(const AudioRouteInfo& route)
2017 AppLogDebug("OnAudioRouteAdded");
2019 switch (route.GetOutputAudioDevice())
2021 case OUTPUT_AUDIO_DEVICE_NONE:
2023 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2027 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2029 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2033 case OUTPUT_AUDIO_DEVICE_RECEIVER:
2035 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2039 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2041 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2045 case OUTPUT_AUDIO_DEVICE_BT_SCO:
2047 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2051 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2053 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = true;
2063 VideoPlayerForm::OnAudioRouteRemoved(const AudioRouteInfo& route)
2065 ArrayList* pArgs = null;
2066 int currentOutputDevice = 0;
2067 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2069 AppLogDebug("OnAudioRouteRemoved");
2071 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2073 switch (route.GetOutputAudioDevice())
2075 case OUTPUT_AUDIO_DEVICE_NONE:
2077 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = false;
2081 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2083 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = false;
2087 case OUTPUT_AUDIO_DEVICE_RECEIVER:
2089 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = false;
2093 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2095 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = false;
2099 case OUTPUT_AUDIO_DEVICE_BT_SCO:
2101 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = false;
2105 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2107 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = false;
2115 if (currentAudioRoute.GetOutputAudioDevice() != route.GetOutputAudioDevice())
2117 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2119 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2120 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2122 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2124 if (__pSoundPathPopup != null)
2126 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2129 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2130 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2132 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2136 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2138 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2139 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2141 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2143 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2144 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2146 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2148 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2149 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2151 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2153 if (__pSoundPathPopup != null)
2155 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2156 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2158 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2161 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2162 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2164 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2168 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2170 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2171 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2173 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2175 if (__pSoundPathPopup != null)
2177 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2180 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2181 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2183 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2186 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2187 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2189 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2191 if (__pSoundPathPopup != null)
2193 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2194 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2196 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2199 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2200 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2202 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2205 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2206 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2208 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2210 if (__pSoundPathPopup != null)
2212 if (__pSoundPathPopup->GetShowState() == true)
2214 __pSoundPathPopup->SetShowState(false);
2223 VideoPlayerForm::InitAudioRouteList(void)
2225 AppLogDebug("InitAudioRouteList");
2228 IList* availableAudioRouteList = null;
2229 AudioRouteInfo* tempRouteInfo = null;
2230 AudioRouteInfo availableRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2231 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2233 availableAudioRouteList = __pAudioRouteManager->GetAvailableAudioRouteListN();
2235 if (availableAudioRouteList != null)
2237 for (listCount = 0; listCount < availableAudioRouteList->GetCount(); ++listCount)
2239 tempRouteInfo = static_cast<AudioRouteInfo*>(availableAudioRouteList->GetAt(listCount));
2240 availableRouteInfo = *tempRouteInfo;
2242 if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_NONE)
2244 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2246 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2248 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2250 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_RECEIVER)
2252 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2254 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2256 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2258 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_SCO)
2260 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2264 __availableAudioRoute[OUTPUT_AUDIO_DEVICE_BT_A2DP] = true;
2268 availableAudioRouteList->RemoveAll(true);
2269 delete availableAudioRouteList;
2270 availableAudioRouteList = null;
2272 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2274 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2276 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2277 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2279 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2281 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2282 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2284 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2286 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2287 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2289 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2292 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2294 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2295 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2297 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2299 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2300 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2302 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2304 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2305 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2307 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2310 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2312 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2313 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2315 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2317 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2318 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2320 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2322 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2323 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2325 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2331 VideoPlayerForm::SetActiveAudioRoute(const AudioRouteInfo& route)
2333 AppLogDebug("SetActiveAudioRoute");
2334 result r = __pAudioRouteManager->SetActiveAudioRoute(route);
2340 VideoPlayerForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
2342 BatteryLevel batteryLevel;
2343 bool isCharging = false;
2345 AppLogDebug("OnUserEventReceivedN");
2349 case REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED:
2351 Battery::GetCurrentLevel(batteryLevel);
2352 Battery::IsCharging(isCharging);
2354 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
2356 bool frameActivated = GetFrameActivated();
2358 if (isCharging == false && frameActivated == true)
2360 OnFormBackRequested(*this);
2372 VideoPlayerForm::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId,
2373 AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
2375 AppLogDebug("OnAppControlCompleteResponseReceived : %d", appControlResult);
2377 VideoPlayerApp* pVideoPlayerApp = static_cast<VideoPlayerApp*>(VideoPlayerApp::GetInstance());
2378 TryReturnVoid(pVideoPlayerApp != null, "pVideoPlayerApp is null");
2379 pVideoPlayerApp->SetFrameEnabled(true);
2383 VideoPlayerForm::OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value)
2385 PlayerState playState = PLAYER_STATE_ERROR;
2386 result r = E_FAILURE;
2388 __sliderMoved = true;
2390 playState = __pVideoPlayerPresentationModel->GetState();
2392 if (playState == PLAYER_STATE_PLAYING)
2394 result r = __pVideoPlayerPresentationModel->PausePlay();
2395 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
2396 __playingBeforeSlide = true;
2398 else if (playState == PLAYER_STATE_PAUSED)
2400 long seekTime = value * (__pVideoPlayerPresentationModel->GetDuration() / MAX_PROGRESS_RANGE);
2402 if (__pVideoPlayerPresentationModel->GetSeekCompleted())
2404 r = __pVideoPlayerPresentationModel->SeekTo(seekTime);
2405 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
2411 dateTime.AddSeconds(seekTime / MILLISECOND);
2412 r = currentTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
2413 TryReturnVoid(r == E_SUCCESS, "currentTime.Format() failed:%s", GetErrorMessage(r));
2415 __pCurrenTimeLabel->SetText(currentTime);
2416 __pCurrenTimeLabel->Invalidate(true);