2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file VpVideoPlayerForm.cpp
19 * @brief This is the implementation file for VideoPlayerForm class.
23 #include <FTelephony.h>
24 #include "VpSoundPathPopup.h"
25 #include "VpVideoPlayerApp.h"
26 #include "VpVideoPlayerForm.h"
27 #include "VpVideoPlayerPresentationModel.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Base::Runtime;
34 using namespace Tizen::Base::Utility;
35 using namespace Tizen::Content;
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Media;
38 using namespace Tizen::System;
39 using namespace Tizen::Telephony;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
44 static const int MIN_PROGRESS_RANGE = 0;
45 static const int MAX_PROGRESS_RANGE = 100;
47 static const int SHOW_CONTROL_DURATION = 5000;
49 static const int MILLISECOND = 1000;
50 static const int START_TIME = 0;
52 static const int X_BASE = 0;
53 static const int Y_BASE = 0;
54 static const int DIVIDE_BY_TWO = 2;
56 static const int X_NORMAL = 0;
57 static const int Y_NORMAL = 310;
58 static const int W_NORMAL = 720;
59 static const int H_NORMAL = 432;
61 static const int W_WVGA_PORTRAIT_HEIGHT = 1200;
62 static const int W_WVGA_LANDSCAPE_WIDTH = 1200;
64 static const int X_WVGA_PORTRAIT_CONTROLLER = 0;
65 static const int Y_WVGA_PORTRAIT_CONTROLLER = 974;
66 static const int W_WVGA_PORTRAIT_CONTROLLER = 720;
67 static const int H_WVGA_PORTRAIT_CONTROLLER = 226;
68 static const int X_WVGA_PORTRAIT_FIRST_LINE = 0;
69 static const int Y_WVGA_PORTRAIT_FIRST_LINE = 973;
70 static const int W_WVGA_PORTRAIT_FIRST_LINE = 720;
71 static const int H_WVGA_PORTRAIT_FIRST_LINE = 1;
72 static const int X_WVGA_PORTRAIT_CURRENT_TIME = 10;
73 static const int Y_WVGA_PORTRAIT_CURRENT_TIME = 1016;
74 static const int W_WVGA_PORTRAIT_CURRENT_TIME = 130;
75 static const int H_WVGA_PORTRAIT_CURRENT_TIME = 28;
76 static const int X_WVGA_PORTRAIT_SLIDER = 136;
77 static const int Y_WVGA_PORTRAIT_SLIDER = 974;
78 static const int W_WVGA_PORTRAIT_SLIDER = 460;
79 static const int H_WVGA_PORTRAIT_SLIDER = 112;
80 static const int X_WVGA_PORTRAIT_TOTAL_TIME = 580;
81 static const int Y_WVGA_PORTRAIT_TOTAL_TIME = 1016;
82 static const int W_WVGA_PORTRAIT_TOTAL_TIME = 130;
83 static const int H_WVGA_PORTRAIT_TOTAL_TIME = 28;
84 static const int X_WVGA_PORTRAIT_VERTICAL_LEFT_LINE = 136;
85 static const int Y_WVGA_PORTRAIT_VERTICAL_LEFT_LINE = 1086;
86 static const int W_WVGA_PORTRAIT_VERTICAL_LEFT_LINE = 1;
87 static const int H_WVGA_PORTRAIT_VERTICAL_LEFT_LINE = 114;
88 static const int X_WVGA_PORTRAIT_FASTREWIND_BTN = 148;
89 static const int Y_WVGA_PORTRAIT_FASTREWIND_BTN = 1086;
90 static const int W_WVGA_PORTRAIT_FASTREWIND_BTN = 136;
91 static const int H_WVGA_PORTRAIT_FASTREWIND_BTN = 114;
92 static const int X_WVGA_PORTRAIT_PLAYPAUSE_BTN = 292;
93 static const int Y_WVGA_PORTRAIT_PLAYPAUSE_BTN = 1086;
94 static const int W_WVGA_PORTRAIT_PLAYPAUSE_BTN = 136;
95 static const int H_WVGA_PORTRAIT_PLAYPAUSE_BTN = 114;
96 static const int X_WVGA_PORTRAIT_FASTFORWARD_BTN = 436;
97 static const int Y_WVGA_PORTRAIT_FASTFORWARD_BTN = 1086;
98 static const int W_WVGA_PORTRAIT_FASTFORWARD_BTN = 136;
99 static const int H_WVGA_PORTRAIT_FASTFORWARD_BTN = 114;
100 static const int X_WVGA_PORTRAIT_VERTICAL_RIGHT_LINE = 584;
101 static const int Y_WVGA_PORTRAIT_VERTICAL_RIGHT_LINE = 1086;
102 static const int W_WVGA_PORTRAIT_VERTICAL_RIGHT_LINE = 1;
103 static const int H_WVGA_PORTRAIT_VERTICAL_RIGHT_LINE = 114;
104 static const int X_WVGA_PORTRAIT_BACK_BTN = 584;
105 static const int Y_WVGA_PORTRAIT_BACK_BTN = 1086;
106 static const int W_WVGA_PORTRAIT_BACK_BTN = 136;
107 static const int H_WVGA_PORTRAIT_BACK_BTN = 114;
109 static const int X_WVGA_LANDSCAPE_CONTROLLER = 0;
110 static const int Y_WVGA_LANDSCAPE_CONTROLLER = 494;
111 static const int W_WVGA_LANDSCAPE_CONTROLLER = 1200;
112 static const int H_WVGA_LANDSCAPE_CONTROLLER = 226;
113 static const int X_WVGA_LANDSCAPE_FIRST_LINE = 0;
114 static const int Y_WVGA_LANDSCAPE_FIRST_LINE = 493;
115 static const int W_WVGA_LANDSCAPE_FIRST_LINE = 1200;
116 static const int H_WVGA_LANDSCAPE_FIRST_LINE = 1;
117 static const int X_WVGA_LANDSCAPE_CURRENT_TIME = 20;
118 static const int Y_WVGA_LANDSCAPE_CURRENT_TIME = 537;
119 static const int W_WVGA_LANDSCAPE_CURRENT_TIME = 130;
120 static const int H_WVGA_LANDSCAPE_CURRENT_TIME = 26;
121 static const int X_WVGA_LANDSCAPE_SLIDER = 140;
122 static const int Y_WVGA_LANDSCAPE_SLIDER = 494;
123 static const int W_WVGA_LANDSCAPE_SLIDER = 940;
124 static const int H_WVGA_LANDSCAPE_SLIDER = 112;
125 static const int X_WVGA_LANDSCAPE_TOTAL_TIME = 1060;
126 static const int Y_WVGA_LANDSCAPE_TOTAL_TIME = 537;
127 static const int W_WVGA_LANDSCAPE_TOTAL_TIME = 130;
128 static const int H_WVGA_LANDSCAPE_TOTAL_TIME = 26;
129 static const int X_WVGA_LANDSCAPE_VERTICAL_LEFT_LINE = 212;
130 static const int Y_WVGA_LANDSCAPE_VERTICAL_LEFT_LINE = 606;
131 static const int W_WVGA_LANDSCAPE_VERTICAL_LEFT_LINE = 2;
132 static const int H_WVGA_LANDSCAPE_VERTICAL_LEFT_LINE = 114;
133 static const int X_WVGA_LANDSCAPE_FASTREWIND_BTN = 236;
134 static const int Y_WVGA_LANDSCAPE_FASTREWIND_BTN = 606;
135 static const int W_WVGA_LANDSCAPE_FASTREWIND_BTN = 136;
136 static const int H_WVGA_LANDSCAPE_FASTREWIND_BTN = 114;
137 static const int X_WVGA_LANDSCAPE_PLAYPAUSE_BTN = 552;
138 static const int Y_WVGA_LANDSCAPE_PLAYPAUSE_BTN = 606;
139 static const int W_WVGA_LANDSCAPE_PLAYPAUSE_BTN = 136;
140 static const int H_WVGA_LANDSCAPE_PLAYPAUSE_BTN = 114;
141 static const int X_WVGA_LANDSCAPE_FASTFORWARD_BTN = 858;
142 static const int Y_WVGA_LANDSCAPE_FASTFORWARD_BTN = 606;
143 static const int W_WVGA_LANDSCAPE_FASTFORWARD_BTN = 136;
144 static const int H_WVGA_LANDSCAPE_FASTFORWARD_BTN = 114;
145 static const int X_WVGA_LANDSCAPE_VERTICAL_RIGHT_LINE = 1016;
146 static const int Y_WVGA_LANDSCAPE_VERTICAL_RIGHT_LINE = 606;
147 static const int W_WVGA_LANDSCAPE_VERTICAL_RIGHT_LINE = 2;
148 static const int H_WVGA_LANDSCAPE_VERTICAL_RIGHT_LINE = 114;
149 static const int X_WVGA_LANDSCAPE_BACK_BTN = 1064;
150 static const int Y_WVGA_LANDSCAPE_BACK_BTN = 606;
151 static const int W_WVGA_LANDSCAPE_BACK_BTN = 136;
152 static const int H_WVGA_LANDSCAPE_BACK_BTN = 114;
154 static const int X_HVGA_PORTRAIT_CONTROLLER = 0;
155 static const int Y_HVGA_PORTRAIT_CONTROLLER = 1054;
156 static const int W_HVGA_PORTRAIT_CONTROLLER = 720;
157 static const int H_HVGA_PORTRAIT_CONTROLLER = 226;
158 static const int X_HVGA_PORTRAIT_FIRST_LINE = 0;
159 static const int Y_HVGA_PORTRAIT_FIRST_LINE = 1053;
160 static const int W_HVGA_PORTRAIT_FIRST_LINE = 720;
161 static const int H_HVGA_PORTRAIT_FIRST_LINE = 1;
162 static const int X_HVGA_PORTRAIT_CURRENT_TIME = 10;
163 static const int Y_HVGA_PORTRAIT_CURRENT_TIME = 1096;
164 static const int W_HVGA_PORTRAIT_CURRENT_TIME = 130;
165 static const int H_HVGA_PORTRAIT_CURRENT_TIME = 28;
166 static const int X_HVGA_PORTRAIT_SLIDER = 136;
167 static const int Y_HVGA_PORTRAIT_SLIDER = 1054;
168 static const int W_HVGA_PORTRAIT_SLIDER = 460;
169 static const int H_HVGA_PORTRAIT_SLIDER = 112;
170 static const int X_HVGA_PORTRAIT_TOTAL_TIME = 580;
171 static const int Y_HVGA_PORTRAIT_TOTAL_TIME = 1096;
172 static const int W_HVGA_PORTRAIT_TOTAL_TIME = 130;
173 static const int H_HVGA_PORTRAIT_TOTAL_TIME = 28;
174 static const int X_HVGA_PORTRAIT_VERTICAL_LEFT_LINE = 136;
175 static const int Y_HVGA_PORTRAIT_VERTICAL_LEFT_LINE = 1166;
176 static const int W_HVGA_PORTRAIT_VERTICAL_LEFT_LINE = 1;
177 static const int H_HVGA_PORTRAIT_VERTICAL_LEFT_LINE = 114;
178 static const int X_HVGA_PORTRAIT_FASTREWIND_BTN = 148;
179 static const int Y_HVGA_PORTRAIT_FASTREWIND_BTN = 1166;
180 static const int W_HVGA_PORTRAIT_FASTREWIND_BTN = 136;
181 static const int H_HVGA_PORTRAIT_FASTREWIND_BTN = 114;
182 static const int X_HVGA_PORTRAIT_PLAYPAUSE_BTN = 292;
183 static const int Y_HVGA_PORTRAIT_PLAYPAUSE_BTN = 1166;
184 static const int W_HVGA_PORTRAIT_PLAYPAUSE_BTN = 136;
185 static const int H_HVGA_PORTRAIT_PLAYPAUSE_BTN = 114;
186 static const int X_HVGA_PORTRAIT_FASTFORWARD_BTN = 436;
187 static const int Y_HVGA_PORTRAIT_FASTFORWARD_BTN = 1166;
188 static const int W_HVGA_PORTRAIT_FASTFORWARD_BTN = 136;
189 static const int H_HVGA_PORTRAIT_FASTFORWARD_BTN = 114;
190 static const int X_HVGA_PORTRAIT_VERTICAL_RIGHT_LINE = 584;
191 static const int Y_HVGA_PORTRAIT_VERTICAL_RIGHT_LINE = 1166;
192 static const int W_HVGA_PORTRAIT_VERTICAL_RIGHT_LINE = 1;
193 static const int H_HVGA_PORTRAIT_VERTICAL_RIGHT_LINE = 114;
194 static const int X_HVGA_PORTRAIT_BACK_BTN = 584;
195 static const int Y_HVGA_PORTRAIT_BACK_BTN = 1166;
196 static const int W_HVGA_PORTRAIT_BACK_BTN = 136;
197 static const int H_HVGA_PORTRAIT_BACK_BTN = 114;
199 static const int X_HVGA_LANDSCAPE_CONTROLLER = 0;
200 static const int Y_HVGA_LANDSCAPE_CONTROLLER = 494;
201 static const int W_HVGA_LANDSCAPE_CONTROLLER = 1280;
202 static const int H_HVGA_LANDSCAPE_CONTROLLER = 226;
203 static const int X_HVGA_LANDSCAPE_FIRST_LINE = 0;
204 static const int Y_HVGA_LANDSCAPE_FIRST_LINE = 493;
205 static const int W_HVGA_LANDSCAPE_FIRST_LINE = 1280;
206 static const int H_HVGA_LANDSCAPE_FIRST_LINE = 1;
207 static const int X_HVGA_LANDSCAPE_CURRENT_TIME = 20;
208 static const int Y_HVGA_LANDSCAPE_CURRENT_TIME = 537;
209 static const int W_HVGA_LANDSCAPE_CURRENT_TIME = 130;
210 static const int H_HVGA_LANDSCAPE_CURRENT_TIME = 26;
211 static const int X_HVGA_LANDSCAPE_SLIDER = 160;
212 static const int Y_HVGA_LANDSCAPE_SLIDER = 494;
213 static const int W_HVGA_LANDSCAPE_SLIDER = 960;
214 static const int H_HVGA_LANDSCAPE_SLIDER = 112;
215 static const int X_HVGA_LANDSCAPE_TOTAL_TIME = 1130;
216 static const int Y_HVGA_LANDSCAPE_TOTAL_TIME = 537;
217 static const int W_HVGA_LANDSCAPE_TOTAL_TIME = 130;
218 static const int H_HVGA_LANDSCAPE_TOTAL_TIME = 26;
219 static const int X_HVGA_LANDSCAPE_VERTICAL_LEFT_LINE = 212;
220 static const int Y_HVGA_LANDSCAPE_VERTICAL_LEFT_LINE = 606;
221 static const int W_HVGA_LANDSCAPE_VERTICAL_LEFT_LINE = 2;
222 static const int H_HVGA_LANDSCAPE_VERTICAL_LEFT_LINE = 114;
223 static const int X_HVGA_LANDSCAPE_FASTREWIND_BTN = 286;
224 static const int Y_HVGA_LANDSCAPE_FASTREWIND_BTN = 606;
225 static const int W_HVGA_LANDSCAPE_FASTREWIND_BTN = 136;
226 static const int H_HVGA_LANDSCAPE_FASTREWIND_BTN = 114;
227 static const int X_HVGA_LANDSCAPE_PLAYPAUSE_BTN = 572;
228 static const int Y_HVGA_LANDSCAPE_PLAYPAUSE_BTN = 606;
229 static const int W_HVGA_LANDSCAPE_PLAYPAUSE_BTN = 136;
230 static const int H_HVGA_LANDSCAPE_PLAYPAUSE_BTN = 114;
231 static const int X_HVGA_LANDSCAPE_FASTFORWARD_BTN = 858;
232 static const int Y_HVGA_LANDSCAPE_FASTFORWARD_BTN = 606;
233 static const int W_HVGA_LANDSCAPE_FASTFORWARD_BTN = 136;
234 static const int H_HVGA_LANDSCAPE_FASTFORWARD_BTN = 114;
235 static const int X_HVGA_LANDSCAPE_VERTICAL_RIGHT_LINE = 1066;
236 static const int Y_HVGA_LANDSCAPE_VERTICAL_RIGHT_LINE = 606;
237 static const int W_HVGA_LANDSCAPE_VERTICAL_RIGHT_LINE = 2;
238 static const int H_HVGA_LANDSCAPE_VERTICAL_RIGHT_LINE = 114;
239 static const int X_HVGA_LANDSCAPE_BACK_BTN = 1144;
240 static const int Y_HVGA_LANDSCAPE_BACK_BTN = 606;
241 static const int W_HVGA_LANDSCAPE_BACK_BTN = 136;
242 static const int H_HVGA_LANDSCAPE_BACK_BTN = 114;
244 static const int COLOR_THUMB_RED = 0;
245 static const int COLOR_THUMB_GREEN = 0;
246 static const int COLOR_THUMB_BLUE = 0;
247 static const int COLOR_THUMB_ALPHA = 0;
249 static const int MESSAGEBOX_DISPLAY_TIME_3_SEC = 3000;
251 static const wchar_t* INIT_TIME = L"00:00:00";
253 static const RequestId REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU = 111;
254 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU = 112;
255 static const RequestId REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU = 113;
256 static const RequestId REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED = 114;
258 void DestroyPresentationModelInstance(void)
260 delete VideoPlayerPresentationModel::GetInstance();
263 VideoPlayerForm::VideoPlayerForm(void)
264 : __pOverlayPanel(null)
265 , __screenMode(SCREEN_MODE_NORMAL)
266 , __pSoundPathPopup(null)
267 , __pUiControlTimer(null)
268 , __pAudioRouteManager(null)
269 , __pPlayPauseButton(null)
270 , __pFastForwardButton(null)
271 , __pFastRewindButton(null)
272 , __pBackButton(null)
273 , __pButtonLeftItem(null)
274 , __pButtonRightItem(null)
276 , __pControlLabel(null)
277 , __pCurrenTimeLabel(null)
278 , __pFirstLineLabel(null)
279 , __pTotalTimeLabel(null)
280 , __pVerticalLeftLine(null)
281 , __pVerticalRightLine(null)
283 , __actionTouchLongPressed(false)
284 , __setPauseState(false)
285 , __isControlVisibleState(true)
286 , __audioRouteMode(0)
287 , __pVideoPlayerPresentationModel(null)
289 for (int count = 0; count < OUTPUT_AUDIO_ROUTE_MAX; ++count)
291 __availableAudioRoute[count] = false;
295 VideoPlayerForm::~VideoPlayerForm(void)
300 VideoPlayerForm::Initialize(void)
302 AppLogDebug("Initialize");
303 Construct(L"IDL_MAIN_FORM");
307 VideoPlayerForm::SetScreenMode(const ScreenMode mode, bool destroyOverlay)
309 result r = E_SUCCESS;
311 Rectangle clientRect = GetClientAreaBounds();
315 case SCREEN_MODE_NORMAL:
317 bool modified = false;
319 Rectangle rect = Rectangle(X_NORMAL, Y_NORMAL, W_NORMAL, H_NORMAL);
321 if ((clientRect.width - rect.width) <= X_BASE)
327 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
330 if ((clientRect.height - rect.height) <= Y_BASE)
336 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
339 if (destroyOverlay == true)
341 if (__pOverlayPanel != null)
343 __pOverlayPanel->RemoveTouchEventListener(*this);
344 RemoveControl(*__pOverlayPanel);
345 __pOverlayPanel = null;
348 __pOverlayPanel = new (std::nothrow) OverlayPanel();
349 r = __pOverlayPanel->Construct(rect);
350 TryCatch(r == E_SUCCESS, , "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
352 r = AddControl(*__pOverlayPanel);
353 TryCatch(r == E_SUCCESS, , "AddControl(*__pOverlayPanel) failed:%s", GetErrorMessage(r));
355 __pOverlayPanel->AddTouchEventListener(*this);
359 __pOverlayPanel->SetBounds(rect);
362 OverlayRegion::EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_GREATER_THAN, rect, modified);
363 AppLogDebug("SCREEN_MODE_NORMAL : [%d][%d][%d][%d]", rect.x, rect.y, rect.width, rect.height);
365 SetControlAlwaysAtBottom(*__pOverlayPanel, true);
367 __screenMode = SCREEN_MODE_NORMAL;
371 case SCREEN_MODE_FULL:
373 bool modified = false;
375 Rectangle rect = Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height);
376 AppLogDebug("SetScreenMode [%d] [%d]", rect.height, rect.width);
378 if (destroyOverlay == true)
380 if (__pOverlayPanel != null)
382 __pOverlayPanel->RemoveTouchEventListener(*this);
383 RemoveControl(*__pOverlayPanel);
384 __pOverlayPanel = null;
387 __pOverlayPanel = new (std::nothrow) OverlayPanel();
388 r = __pOverlayPanel->Construct(rect);
389 TryCatch(r == E_SUCCESS, , "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
391 r = AddControl(*__pOverlayPanel);
392 TryCatch(r == E_SUCCESS, , "AddControl(*__pOverlayPanel) failed:%s", GetErrorMessage(r));
394 __pOverlayPanel->AddTouchEventListener(*this);
398 __pOverlayPanel->SetBounds(rect);
401 OverlayRegion::EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_GREATER_THAN, rect, modified);
402 AppLogDebug("SCREEN_MODE_FULL : [%d][%d][%d][%d]", rect.x, rect.y, rect.width, rect.height);
404 SetControlAlwaysAtBottom(*__pOverlayPanel, true);
406 __screenMode = SCREEN_MODE_FULL;
410 case SCREEN_MODE_FIT:
412 bool modified = false;
414 Rectangle rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
415 __pVideoPlayerPresentationModel->GetMediaPathName());
417 if ((clientRect.width - rect.width) <= X_BASE)
423 rect.x = (clientRect.width - rect.width) / DIVIDE_BY_TWO;
426 if ((clientRect.height - rect.height) <= Y_BASE)
432 rect.y = (clientRect.height - rect.height) / DIVIDE_BY_TWO;
435 if (destroyOverlay == true)
437 if (__pOverlayPanel != null)
439 __pOverlayPanel->RemoveTouchEventListener(*this);
440 RemoveControl(*__pOverlayPanel);
441 __pOverlayPanel = null;
444 __pOverlayPanel = new (std::nothrow) OverlayPanel();
445 r = __pOverlayPanel->Construct(rect);
446 TryCatch(r == E_SUCCESS, , "__pOverlayPanel->Construct() failed:%s", GetErrorMessage(r));
448 r = AddControl(*__pOverlayPanel);
449 TryCatch(r == E_SUCCESS, , "AddControl(*__pOverlayPanel) failed:%s", GetErrorMessage(r));
451 __pOverlayPanel->AddTouchEventListener(*this);
455 __pOverlayPanel->SetBounds(rect);
458 OverlayRegion::EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_GREATER_THAN, rect, modified);
459 AppLogDebug("SCREEN_MODE_FULL : [%d][%d][%d][%d]", rect.x, rect.y, rect.width, rect.height);
461 SetControlAlwaysAtBottom(*__pOverlayPanel, true);
463 __screenMode = SCREEN_MODE_FIT;
474 RemoveControl(*__pOverlayPanel);
475 __pOverlayPanel = null;
476 __screenMode = SCREEN_MODE_NORMAL;
482 VideoPlayerForm::OnInitializing(void)
484 result r = E_FAILURE;
486 Bitmap* pBitmapScreenMode = null;
487 Bitmap* pBitmapSoundPath = null;
488 Bitmap* pSliderThumbNormalBitmap = null;
489 Bitmap* pSliderThumbPressedBitmap = null;
490 Bitmap* pSliderThumbDisableBitmap = null;
492 AppLogDebug("OnInitializing");
494 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
496 AddOrientationEventListener(*this);
497 AddKeyEventListener(*this);
498 AddTouchEventListener(*this);
500 r = SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER, true);
501 TryCatch(r == E_SUCCESS, , "SetActionBarsTranslucent() failed:%s", GetErrorMessage(r));
503 __pAudioRouteManager = AudioRouteManager::GetInstance();
504 __pAudioRouteManager->SetAudioRouteEventListener(this);
506 SetScreenMode(SCREEN_MODE_NORMAL, true);
508 __pVideoPlayerPresentationModel = VideoPlayerPresentationModel::GetInstance();
509 TryCatch(__pVideoPlayerPresentationModel != null, r = E_SYSTEM, "__pVideoPlayerPresentationModel is null");
511 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
512 __pVideoPlayerPresentationModel->InitializePlayer();
514 __pVideoPlayerPresentationModel->SetVideoPlayerEventListener(this);
518 InitAudioRouteList();
520 __pHeader = GetHeader();
522 __pButtonLeftItem = new (std::nothrow) ButtonItem();
523 __pButtonRightItem = new (std::nothrow) ButtonItem();
525 r = __pButtonLeftItem->Construct(BUTTON_ITEM_STYLE_ICON, IDA_BUTTON_FULLSCREEN);
526 TryCatch(r == E_SUCCESS, , "buttonLeftItem->Construct() Failed:%s", GetErrorMessage(r));
528 r = __pButtonRightItem->Construct(BUTTON_ITEM_STYLE_ICON, IDA_BUTTON_SOUNDPATH);
529 TryCatch(r == E_SUCCESS, , "buttonRightItem->Construct() Failed:%s", GetErrorMessage(r));
531 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
533 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
534 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
535 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
537 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
539 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
540 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
541 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
545 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
546 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
547 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
549 __pButtonLeftItem->SetActionId(IDA_BUTTON_FULLSCREEN);
550 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
552 pBitmapSoundPath = pAppResource->GetBitmapN(L"T01_icon_title_soundpath.png");
553 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapSoundPath);
554 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
556 __pButtonRightItem->SetActionId(IDA_BUTTON_SOUNDPATH);
557 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
560 __pHeader->AddActionEventListener(*this);
561 __pHeader->AddTouchEventListener(*this);
563 __pPlayPauseButton = static_cast<Button*>(GetControl("IDC_BUTTON_PLAY"));
564 TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
565 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
566 __pPlayPauseButton->AddActionEventListener(*this);
567 __pPlayPauseButton->AddTouchEventListener(*this);
569 __pFastRewindButton = static_cast<Button*>(GetControl("IDC_BUTTON_FASTREWIND"));
570 TryCatch(__pFastRewindButton != null, r = E_SYSTEM, "__pFastRewindButton is null");
571 __pFastRewindButton->SetActionId(IDA_BUTTON_FASTREWIND);
572 __pFastRewindButton->AddActionEventListener(*this);
573 __pFastRewindButton->AddTouchEventListener(*this);
575 __pFastForwardButton = static_cast<Button*>(GetControl("IDC_BUTTON_FASTFORWARD"));
576 TryCatch(__pFastForwardButton != null, r = E_SYSTEM, "__pFastForwardButton is null");
577 __pFastForwardButton->SetActionId(IDA_BUTTON_FASTFORWARD);
578 __pFastForwardButton->AddActionEventListener(*this);
579 __pFastForwardButton->AddTouchEventListener(*this);
581 __pBackButton = static_cast<Button*>(GetControl("IDC_BUTTON_BACK"));
582 TryCatch(__pBackButton != null, r = E_SYSTEM, "__pBackButton is null");
583 __pBackButton->SetActionId(IDA_BUTTON_BACK);
584 __pBackButton->AddActionEventListener(*this);
585 __pBackButton->AddTouchEventListener(*this);
587 __pSlider = static_cast<Slider*>(GetControl("IDC_SLIDER"));
588 TryCatch(__pSlider != null, r = E_SYSTEM, "__pSlider is null");
589 __pSlider->SetEnabled(true);
590 __pSlider->SetRange(MIN_PROGRESS_RANGE, MAX_PROGRESS_RANGE);
591 __pSlider->SetValue(MIN_PROGRESS_RANGE);
592 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL,
593 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
594 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED,
595 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
596 __pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED,
597 Color(COLOR_THUMB_RED, COLOR_THUMB_GREEN, COLOR_THUMB_BLUE, COLOR_THUMB_ALPHA));
599 pSliderThumbNormalBitmap = pAppResource->GetBitmapN(L"T01_controller_progress_handle.png");
600 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *pSliderThumbNormalBitmap);
601 TryCatch(r == E_SUCCESS, , "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
603 pSliderThumbPressedBitmap = pAppResource->GetBitmapN(L"T01_controller_progress_handle_press.png");
604 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *pSliderThumbPressedBitmap);
605 TryCatch(r == E_SUCCESS, , "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
607 pSliderThumbDisableBitmap = pAppResource->GetBitmapN(L"T01_controller_progress_handle.png");
608 r = __pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_DISABLED, *pSliderThumbDisableBitmap);
609 TryCatch(r == E_SUCCESS, , "__pSlider->SetThumbBitmap() Failed:%s", GetErrorMessage(r));
611 __pSlider->AddAdjustmentEventListener(*this);
612 __pSlider->AddTouchEventListener(*this);
614 __pCurrenTimeLabel = static_cast<Label*>(GetControl("IDC_LABEL_CURRENTTIME"));
615 TryCatch(__pCurrenTimeLabel != null, r = E_SYSTEM, "__pCurrenTimeLabel is null");
616 __pCurrenTimeLabel->AddTouchEventListener(*this);
618 __pCurrenTimeLabel->SetText(INIT_TIME);
620 __pTotalTimeLabel = static_cast<Label*>(GetControl("IDC_LABEL_FULLTIME"));
621 TryCatch(__pTotalTimeLabel != null, r = E_SYSTEM, "__pTotalTimeLabel is null");
622 __pTotalTimeLabel->AddTouchEventListener(*this);
624 __pTotalTimeLabel->SetText(INIT_TIME);
626 __pControlLabel = static_cast<Label*>(GetControl("IDC_LABEL_BOTTOM_CONTROL_PANEL"));
627 TryCatch(__pControlLabel != null, r = E_SYSTEM, "__pControlLabel is null");
629 __pFirstLineLabel = static_cast<Label*>(GetControl("IDC_LABEL_LINE1"));
630 TryCatch(__pFirstLineLabel != null, r = E_SYSTEM, "__pFirstLineLabel is null");
632 __pVerticalLeftLine = static_cast<Label*>(GetControl("IDC_LABEL_VERTICAL_LINE_LEFT"));
633 TryCatch(__pVerticalLeftLine != null, r = E_SYSTEM, "__pVerticalLeftLine is null");
635 __pVerticalRightLine = static_cast<Label*>(GetControl("IDC_LABEL_VERTICAL_LINE_RIGHT"));
636 TryCatch(__pVerticalRightLine != null, r = E_SYSTEM, "__pVerticalRightLine is null");
640 delete pBitmapScreenMode;
641 delete pBitmapSoundPath;
642 delete pSliderThumbNormalBitmap;
643 delete pSliderThumbPressedBitmap;
644 delete pSliderThumbDisableBitmap;
649 delete pBitmapScreenMode;
650 delete pBitmapSoundPath;
651 delete pSliderThumbNormalBitmap;
652 delete pSliderThumbPressedBitmap;
653 delete pSliderThumbDisableBitmap;
655 DestroyPresentationModelInstance();
661 VideoPlayerForm::OnTerminating(void)
663 AppLogDebug("OnTerminating");
665 DestroyPresentationModelInstance();
667 delete __pButtonLeftItem;
668 __pButtonLeftItem = null;
670 delete __pButtonRightItem;
671 __pButtonRightItem = null;
673 RemoveControl(*__pOverlayPanel);
674 __pOverlayPanel = null;
676 delete __pSoundPathPopup;
677 __pSoundPathPopup = null;
683 VideoPlayerForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
685 result r = E_FAILURE;
686 AppLogDebug("OnSceneActivatedN");
689 Bitmap* pBitmapScreenMode = null;
691 Rectangle rect(0, 0, 0, 0);
693 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
696 CheckLowBatteryStatus();
698 r = __pVideoPlayerPresentationModel->StartPlay();
699 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->StartPlay() failed:%s", GetErrorMessage(r));
701 GetTotalTime(totalTime);
703 AppLogDebug("totalTime [%ls]", totalTime.GetPointer());
705 __pTotalTimeLabel->SetText(totalTime);
706 __pTotalTimeLabel->Invalidate(true);
708 String mediaPathName = __pVideoPlayerPresentationModel->GetMediaPathName();
709 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(mediaPathName);
711 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
713 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
715 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
717 __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
718 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
722 __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
723 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
727 r = PowerManager::KeepScreenOnState(true, false);
728 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
730 delete pBitmapScreenMode;
731 pBitmapScreenMode = null;
735 VideoPlayerForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
737 result r = E_FAILURE;
739 AppLogDebug("OnSceneDeactivated");
741 r = __pVideoPlayerPresentationModel->PausePlay();
742 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->PausePlay() failed:%s", GetErrorMessage(r));
744 r = PowerManager::KeepScreenOnState(false);
745 TryReturnVoid(r == E_SUCCESS, "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
749 VideoPlayerForm::OnPlayOpened(result r)
751 AppLogDebug("OnPlayOpened");
755 VideoPlayerForm::OnPlayEndOfClip(bool playNextContent)
757 result r = E_FAILURE;
759 Bitmap* pPlayBitmap = null;
760 Bitmap* pBitmapScreenMode = null;
761 Bitmap* pBitmapSoundPath = null;
763 AppLogDebug("OnPlayEndOfClip : %d", playNextContent);
765 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
767 if (__pSoundPathPopup != null)
769 if (__pSoundPathPopup->GetShowState() == true)
771 __pSoundPathPopup->SetShowState(false);
775 __pUiControlTimer->Cancel();
777 UpdateProgressBar(START_TIME);
779 __pCurrenTimeLabel->SetText(INIT_TIME);
780 __pCurrenTimeLabel->Invalidate(true);
782 pPlayBitmap = pAppResource->GetBitmapN(L"T01_icon_toolbar_play.png");
783 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
784 __pPlayPauseButton->SetNormalBackgroundBitmap(*pPlayBitmap);
788 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
790 __pSlider->SetEnabled(false);
792 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
794 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
795 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
797 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
801 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
802 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
804 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
807 if (playNextContent == true)
809 SetScreenMode(SCREEN_MODE_NORMAL, true);
810 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
811 __pVideoPlayerPresentationModel->InitializePlayer();
813 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
815 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
816 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
817 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
819 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
821 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
822 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
823 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
827 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
828 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
829 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
831 __pButtonLeftItem->SetActionId(IDA_BUTTON_FULLSCREEN);
832 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
834 pBitmapSoundPath = pAppResource->GetBitmapN(L"T01_icon_title_soundpath.png");
835 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapSoundPath);
836 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
838 __pButtonRightItem->SetActionId(IDA_BUTTON_SOUNDPATH);
839 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
842 __pSlider->SetEnabled(true);
844 r = __pVideoPlayerPresentationModel->StartPlay();
845 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->StartPlay() Failed:%s", GetErrorMessage(r));
847 r = PowerManager::KeepScreenOnState(true, false);
848 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
852 r = PowerManager::KeepScreenOnState(false);
853 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
862 VideoPlayerForm::OnPlayBuffering(int percent)
864 AppLogDebug("OnPlayBuffering");
868 VideoPlayerForm::OnPlayErrorOccurred(PlayerErrorReason r)
870 MessageBox messageBox;
871 String messageBoxString;
873 AppResource* pAppResource = null;
875 AppLogDebug("OnPlayErrorOccurred [%d]", r);
879 case PLAYER_ERROR_INVALID_DATA:
881 if ((__pVideoPlayerPresentationModel->GetMediaPathName().EndsWith(L"flv") == true)
882 || (__pVideoPlayerPresentationModel->GetMediaPathName().EndsWith(L"FLV") == true))
884 pAppResource = Application::GetInstance()->GetAppResource();
885 pAppResource->GetString(IDS_COM_POP_UNSUPPORTED_FILE_TYPE, messageBoxString);
887 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_OK, MESSAGEBOX_DISPLAY_TIME_3_SEC);
888 messageBox.ShowAndWait(modalResult);
890 AppLogDebug("OnPlayErrorOccurred : pApp->Terminate");
891 UiApp* pApp = UiApp::GetInstance();
897 case PLAYER_ERROR_DEVICE_FAILED:
899 pAppResource = Application::GetInstance()->GetAppResource();
900 pAppResource->GetString(IDS_VPL_POP_UNABLE_TO_PLAY_VIDEO_ERROR_OCCURRED, messageBoxString);
902 messageBox.Construct(L"", messageBoxString, MSGBOX_STYLE_OK, MESSAGEBOX_DISPLAY_TIME_3_SEC);
903 messageBox.ShowAndWait(modalResult);
905 AppLogDebug("OnPlayErrorOccurred : pApp->Terminate");
906 UiApp* pApp = UiApp::GetInstance();
917 VideoPlayerForm::OnPlayInterrupted(void)
919 AppLogDebug("OnPlayInterrupted");
923 VideoPlayerForm::OnPlayReleased(void)
925 AppLogDebug("OnPlayReleased");
929 VideoPlayerForm::OnActionPerformed(const Control& source, int actionId)
931 result r = E_FAILURE;
936 Bitmap* pBitmapScreenMode = null;
938 PlayerState playState = PLAYER_STATE_ERROR;
939 AppLogDebug("OnActionPerformed : %d", actionId);
941 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
943 playState = __pVideoPlayerPresentationModel->GetState();
945 Rectangle clientRect = GetClientAreaBounds();
949 case IDA_BUTTON_PLAY:
951 __setPauseState = false;
953 if ((__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_ENDOFCLIP))
955 if (__pVideoPlayerPresentationModel->GetCurrentMediaIndex() != __pVideoPlayerPresentationModel->GetPreviousMediaIndex())
957 SetScreenMode(SCREEN_MODE_NORMAL, true);
958 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
960 __pVideoPlayerPresentationModel->InitializePlayer();
963 r = __pVideoPlayerPresentationModel->StartPlay();
964 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->StartPlay() failed:%s",
967 __pSlider->SetEnabled(true);
969 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
970 __pVideoPlayerPresentationModel->GetMediaPathName());
972 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
974 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
976 if (__screenMode == SCREEN_MODE_NORMAL)
978 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
980 else if (__screenMode == SCREEN_MODE_FULL)
982 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
987 if (__screenMode == SCREEN_MODE_FIT)
989 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
991 else if (__screenMode == SCREEN_MODE_NORMAL)
993 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
997 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
1001 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1002 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
1004 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1008 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
1010 if (__screenMode == SCREEN_MODE_NORMAL)
1012 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
1014 else if (__screenMode == SCREEN_MODE_FULL)
1016 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
1021 if (__screenMode == SCREEN_MODE_FIT)
1023 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
1025 else if (__screenMode == SCREEN_MODE_NORMAL)
1027 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
1031 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
1035 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1036 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
1038 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1041 r = PowerManager::KeepScreenOnState(true, false);
1042 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
1044 delete pBitmapScreenMode;
1045 pBitmapScreenMode = null;
1049 case IDA_BUTTON_PAUSE:
1051 __setPauseState = true;
1053 r = __pVideoPlayerPresentationModel->PausePlay();
1054 TryCatch(r == E_SUCCESS, , "__pVideoPlayerPresentationModel->PausePlay() failed:%s",
1055 GetErrorMessage(r));
1057 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
1059 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
1060 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
1062 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1066 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
1067 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
1069 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1072 r = PowerManager::KeepScreenOnState(false);
1073 TryCatch(r == E_SUCCESS, , "PowerManager::KeepScreenOnState() failed:%s", GetErrorMessage(r));
1077 case IDA_BUTTON_FULLSCREEN:
1079 if (playState == PLAYER_STATE_PLAYING)
1081 __pUiControlTimer->Cancel();
1082 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1089 rect = __pVideoPlayerPresentationModel->GetVideoInfoN(
1090 __pVideoPlayerPresentationModel->GetMediaPathName());
1092 switch (__screenMode)
1094 case SCREEN_MODE_FIT:
1096 r = SetScreenMode(SCREEN_MODE_FULL, true);
1097 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
1099 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
1100 __pVideoPlayerPresentationModel->SetRenderingBuffer();
1102 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
1104 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
1106 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1107 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s", GetErrorMessage(r));
1109 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1113 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1114 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s", GetErrorMessage(r));
1116 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1119 delete pBitmapScreenMode;
1120 pBitmapScreenMode = null;
1124 case SCREEN_MODE_FULL:
1126 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
1128 r = SetScreenMode(SCREEN_MODE_NORMAL, true);
1129 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
1131 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
1132 __pVideoPlayerPresentationModel->SetRenderingBuffer();
1134 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
1136 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
1138 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1139 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s",
1140 GetErrorMessage(r));
1142 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1146 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1147 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s",
1148 GetErrorMessage(r));
1150 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1155 r = SetScreenMode(SCREEN_MODE_NORMAL, true);
1156 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
1158 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
1159 __pVideoPlayerPresentationModel->SetRenderingBuffer();
1161 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
1163 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
1165 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1166 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s",
1167 GetErrorMessage(r));
1169 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1173 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1174 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s",
1175 GetErrorMessage(r));
1177 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1181 delete pBitmapScreenMode;
1182 pBitmapScreenMode = null;
1186 case SCREEN_MODE_NORMAL:
1188 if (rect.width > W_NORMAL || rect.height > W_NORMAL)
1190 r = SetScreenMode(SCREEN_MODE_FULL, true);
1191 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
1193 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
1194 __pVideoPlayerPresentationModel->SetRenderingBuffer();
1196 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
1198 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
1200 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1201 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s",
1202 GetErrorMessage(r));
1204 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1208 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1209 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s",
1210 GetErrorMessage(r));
1212 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1217 r = SetScreenMode(SCREEN_MODE_FIT, true);
1218 TryCatch(r == E_SUCCESS, , "SetScreenMode() failed:%s", GetErrorMessage(r));
1220 __pVideoPlayerPresentationModel->SetOverlayPanel(__pOverlayPanel);
1221 __pVideoPlayerPresentationModel->SetRenderingBuffer();
1223 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
1225 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
1227 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1228 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon failed:%s",
1229 GetErrorMessage(r));
1231 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1235 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
1236 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon failed:%s",
1237 GetErrorMessage(r));
1239 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1243 delete pBitmapScreenMode;
1244 pBitmapScreenMode = null;
1254 case IDA_BUTTON_SOUNDPATH:
1256 if (__pSoundPathPopup == null)
1258 PlayerSoundPathPopupInit();
1261 if (playState == PLAYER_STATE_PLAYING)
1263 __pUiControlTimer->Cancel();
1264 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1266 __pSoundPathPopup->ShowPopup(true);
1270 case IDA_BUTTON_FASTFORWARD:
1272 if (__actionTouchLongPressed == true)
1274 __actionTouchLongPressed = false;
1278 if (playState == PLAYER_STATE_PLAYING)
1280 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1283 __pVideoPlayerPresentationModel->Forward();
1287 case IDA_BUTTON_FASTREWIND:
1289 if (__actionTouchLongPressed == true)
1291 __actionTouchLongPressed = false;
1295 if (playState == PLAYER_STATE_PLAYING)
1297 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1300 __pVideoPlayerPresentationModel->Rewind();
1304 case IDA_BUTTON_BACK:
1306 Application::GetInstance()->Terminate();
1315 delete pBitmapScreenMode;
1316 pBitmapScreenMode = null;
1320 VideoPlayerForm::OnTouchPressed(const Control& source, const Point& currentPosition,
1321 const TouchEventInfo& touchInfo)
1323 AppLogDebug("OnTouchPressed");
1324 __pUiControlTimer->Cancel();
1328 VideoPlayerForm::OnTouchReleased(const Control& source, const Point& currentPosition,
1329 const TouchEventInfo& touchInfo)
1331 result r = E_FAILURE;
1333 PlayerState playState = PLAYER_STATE_ERROR;
1335 AppLogDebug("OnTouchReleased");
1337 ChangedControlPos();
1339 if ((&source == __pFastForwardButton
1340 || &source == __pFastRewindButton)
1341 && __actionTouchLongPressed == true)
1343 __pVideoPlayerPresentationModel->StopFastForwardRewind();
1346 playState = __pVideoPlayerPresentationModel->GetState();
1348 if (playState != PLAYER_STATE_PAUSED)
1350 if ((source.GetName() == L"IDL_MAIN_FORM" || source.GetHashCode() == __pOverlayPanel->GetHashCode())
1351 && playState == PLAYER_STATE_PLAYING)
1353 if (__isControlVisibleState == true)
1361 r = __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1362 TryReturnVoid(r == E_SUCCESS, "__pUiControlTimer->Start() failed:%s", GetErrorMessage(r));
1369 VideoPlayerForm::OnTouchLongPressed(const Control& source, const Point& currentPosition,
1370 const TouchEventInfo& touchInfo)
1372 AppLogDebug("OnTouchLongPressed");
1374 if (&source == __pFastForwardButton)
1376 __actionTouchLongPressed = true;
1378 if (__setPauseState == true)
1380 __pVideoPlayerPresentationModel->FastForward(false);
1384 __pVideoPlayerPresentationModel->FastForward(true);
1387 else if (&source == __pFastRewindButton)
1389 __actionTouchLongPressed = true;
1391 if (__setPauseState == true)
1393 __pVideoPlayerPresentationModel->FastRewind(false);
1397 __pVideoPlayerPresentationModel->FastRewind(true);
1403 VideoPlayerForm::OnTouchMoved(const Control& source, const Point& currentPosition,
1404 const TouchEventInfo& touchInfo)
1409 VideoPlayerForm::OnTouchFocusIn(const Control& source, const Point& currentPosition,
1410 const TouchEventInfo& touchInfo)
1415 VideoPlayerForm::OnTouchFocusOut(const Control& source, const Point& currentPosition,
1416 const TouchEventInfo& touchInfo)
1421 VideoPlayerForm::OnTimerExpired(Timer& timer)
1423 if (timer.GetHashCode() == __pUiControlTimer->GetHashCode())
1425 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1433 VideoPlayerForm::OnAdjustmentValueChanged(const Control& source, int adjustment)
1435 result r = E_FAILURE;
1438 AppLogDebug("OnAdjustmentValueChanged : %d", adjustment);
1440 if (adjustment >= MIN_PROGRESS_RANGE && adjustment < MAX_PROGRESS_RANGE)
1442 seekTime = adjustment * (__pVideoPlayerPresentationModel->GetDuration() / MAX_PROGRESS_RANGE);
1444 r = __pVideoPlayerPresentationModel->SeekTo(seekTime);
1445 TryReturnVoid(r == E_SUCCESS, "__pVideoPlayerPresentationModel->SeekTo() failed:%s", GetErrorMessage(r));
1447 UpdateProgressBar(adjustment);
1450 if (__pVideoPlayerPresentationModel->GetState() == PLAYER_STATE_PLAYING)
1452 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1457 VideoPlayerForm::OnKeyPressed(const Control& source, KeyCode keyCode)
1459 AppLogDebug("OnKeyPressed Control : %ls, KeyCode : %d", source.GetName().GetPointer(), keyCode);
1461 if (keyCode == KEY_SIDE_UP || keyCode == KEY_SIDE_DOWN)
1468 VideoPlayerForm::OnKeyReleased(const Control& source, KeyCode keyCode)
1473 VideoPlayerForm::OnKeyLongPressed(const Control& source, KeyCode keyCode)
1478 VideoPlayerForm::UpdateProgressBar(const int currentPlayTime)
1480 TryReturnVoid(__pSlider, "__pSlider is null");
1482 __pSlider->SetValue(currentPlayTime);
1483 __pSlider->Invalidate(true);
1487 VideoPlayerForm::InitTimer(void)
1489 __pUiControlTimer = new (std::nothrow) Timer();
1490 __pUiControlTimer->Construct(*this);
1494 VideoPlayerForm::DeleteTimer(void)
1496 if (__pUiControlTimer != null)
1498 __pUiControlTimer->Cancel();
1499 delete __pUiControlTimer;
1500 __pUiControlTimer = null;
1505 VideoPlayerForm::SetPlayPauseButtonImage(PlayerState playState)
1507 result r = E_SUCCESS;
1509 Bitmap* pPlayBitmap = null;
1510 Bitmap* pPauseBitmap = null;
1512 AppLogDebug("SetPlayPauseButtonImage : %d", playState);
1514 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1516 __pPlayPauseButton = static_cast<Button*>(GetControl("IDC_BUTTON_PLAY"));
1517 TryCatch(__pPlayPauseButton != null, r = E_SYSTEM, "__pPlayPauseButton is null");
1519 if (playState == PLAYER_STATE_PLAYING)
1521 pPauseBitmap = pAppResource->GetBitmapN(L"T01_icon_toolbar_pause.png");
1522 TryCatch(pPauseBitmap != null, r = E_SYSTEM, "pPauseBitmap is null");
1524 __pPlayPauseButton->SetNormalBackgroundBitmap(*pPauseBitmap);
1526 __pPlayPauseButton->SetActionId(IDA_BUTTON_PAUSE);
1527 __pPlayPauseButton->Invalidate(true);
1529 delete pPauseBitmap;
1533 pPlayBitmap = pAppResource->GetBitmapN(L"T01_icon_toolbar_play.png");
1534 TryCatch(pPlayBitmap != null, r = E_SYSTEM, "pPlayBitmap is null");
1536 __pPlayPauseButton->SetNormalBackgroundBitmap(*pPlayBitmap);
1538 __pPlayPauseButton->SetActionId(IDA_BUTTON_PLAY);
1539 __pPlayPauseButton->Invalidate(true);
1551 VideoPlayerForm::GetTotalTime(String& totalTime)
1553 result r = E_FAILURE;
1556 dateTime.AddSeconds(__pVideoPlayerPresentationModel->GetDuration() / MILLISECOND);
1557 r = totalTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1558 TryReturnVoid(r == E_SUCCESS, "totalTime.Format() failed:%s", GetErrorMessage(r));
1562 VideoPlayerForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1564 AppLogDebug("OnOrientationChanged");
1566 SetScreenMode(__screenMode, false);
1568 switch (orientationStatus)
1570 case ORIENTATION_STATUS_PORTRAIT:
1572 ChangedControlPos();
1576 case ORIENTATION_STATUS_LANDSCAPE:
1578 case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
1580 ChangedControlPos();
1590 VideoPlayerForm::PlayerSoundPathPopupInit(void)
1592 int tempAudioRouteMode = 0;
1593 int currentOutputDevice = 0;
1594 tempAudioRouteMode = __audioRouteMode;
1595 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1597 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
1598 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
1600 __pSoundPathPopup = new (std::nothrow) SoundPathPopup();
1601 result r = __pSoundPathPopup->Construct(currentOutputDevice,
1602 __pAudioRouteManager->GetActiveBluetoothA2dpName(), tempAudioRouteMode);
1603 TryReturnVoid(r == E_SUCCESS, "__pSoundPathPopup->Construct() failed:%s", GetErrorMessage(r));
1607 VideoPlayerForm::CreateMessageBox(const String& title, const String& message, MessageBoxStyle style,
1608 unsigned long timeout)
1613 VideoPlayerForm::ShowControl(bool setShow)
1615 AppLogDebug("ShowControl");
1617 if (setShow == true)
1619 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR|FORM_ACTION_BAR_HEADER, true);
1621 __pPlayPauseButton->SetShowState(true);
1622 __pFastForwardButton->SetShowState(true);
1623 __pFastRewindButton->SetShowState(true);
1624 __pBackButton->SetShowState(true);
1625 __pCurrenTimeLabel->SetShowState(true);
1626 __pTotalTimeLabel->SetShowState(true);
1627 __pSlider->SetShowState(true);
1628 __pControlLabel->SetShowState(true);
1629 __pFirstLineLabel->SetShowState(true);
1630 __pVerticalLeftLine->SetShowState(true);
1631 __pVerticalRightLine->SetShowState(true);
1633 __isControlVisibleState = true;
1639 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR|FORM_ACTION_BAR_HEADER, false);
1641 __pPlayPauseButton->SetShowState(false);
1642 __pFastForwardButton->SetShowState(false);
1643 __pFastRewindButton->SetShowState(false);
1644 __pBackButton->SetShowState(false);
1645 __pCurrenTimeLabel->SetShowState(false);
1646 __pTotalTimeLabel->SetShowState(false);
1647 __pSlider->SetShowState(false);
1648 __pControlLabel->SetShowState(false);
1649 __pFirstLineLabel->SetShowState(false);
1650 __pVerticalLeftLine->SetShowState(false);
1651 __pVerticalRightLine->SetShowState(false);
1653 __isControlVisibleState = false;
1658 VideoPlayerForm::ChangedControlPos(void)
1660 AppLogDebug("ChangedControlPos");
1662 switch (GetOrientationStatus())
1664 case ORIENTATION_STATUS_PORTRAIT:
1666 if (GetClientAreaBounds().height <= W_WVGA_PORTRAIT_HEIGHT)
1668 __pControlLabel->SetBounds(X_WVGA_PORTRAIT_CONTROLLER, Y_WVGA_PORTRAIT_CONTROLLER, W_WVGA_PORTRAIT_CONTROLLER, H_WVGA_PORTRAIT_CONTROLLER);
1669 __pFirstLineLabel->SetBounds(X_WVGA_PORTRAIT_FIRST_LINE, Y_WVGA_PORTRAIT_FIRST_LINE, W_WVGA_PORTRAIT_FIRST_LINE, H_WVGA_PORTRAIT_FIRST_LINE);
1671 __pCurrenTimeLabel->SetBounds(X_WVGA_PORTRAIT_CURRENT_TIME, Y_WVGA_PORTRAIT_CURRENT_TIME, W_WVGA_PORTRAIT_CURRENT_TIME, H_WVGA_PORTRAIT_CURRENT_TIME);
1672 __pSlider->SetBounds(X_WVGA_PORTRAIT_SLIDER, Y_WVGA_PORTRAIT_SLIDER, W_WVGA_PORTRAIT_SLIDER, H_WVGA_PORTRAIT_SLIDER);
1673 __pTotalTimeLabel->SetBounds(X_WVGA_PORTRAIT_TOTAL_TIME, Y_WVGA_PORTRAIT_TOTAL_TIME, W_WVGA_PORTRAIT_TOTAL_TIME, H_WVGA_PORTRAIT_TOTAL_TIME);
1675 __pVerticalLeftLine->SetBounds(X_WVGA_PORTRAIT_VERTICAL_LEFT_LINE, Y_WVGA_PORTRAIT_VERTICAL_LEFT_LINE, W_WVGA_PORTRAIT_VERTICAL_LEFT_LINE,H_WVGA_PORTRAIT_VERTICAL_LEFT_LINE);
1676 __pFastRewindButton->SetBounds(X_WVGA_PORTRAIT_FASTREWIND_BTN, Y_WVGA_PORTRAIT_FASTREWIND_BTN, W_WVGA_PORTRAIT_FASTREWIND_BTN, H_WVGA_PORTRAIT_FASTREWIND_BTN);
1677 __pPlayPauseButton->SetBounds(X_WVGA_PORTRAIT_PLAYPAUSE_BTN, Y_WVGA_PORTRAIT_PLAYPAUSE_BTN, W_WVGA_PORTRAIT_PLAYPAUSE_BTN, H_WVGA_PORTRAIT_PLAYPAUSE_BTN);
1678 __pFastForwardButton->SetBounds(X_WVGA_PORTRAIT_FASTFORWARD_BTN, Y_WVGA_PORTRAIT_FASTFORWARD_BTN, W_WVGA_PORTRAIT_FASTFORWARD_BTN, H_WVGA_PORTRAIT_FASTFORWARD_BTN);
1679 __pVerticalRightLine->SetBounds(X_WVGA_PORTRAIT_VERTICAL_RIGHT_LINE, Y_WVGA_PORTRAIT_VERTICAL_RIGHT_LINE, W_WVGA_PORTRAIT_VERTICAL_RIGHT_LINE, H_WVGA_PORTRAIT_VERTICAL_RIGHT_LINE);
1680 __pBackButton->SetBounds(X_WVGA_PORTRAIT_BACK_BTN, Y_WVGA_PORTRAIT_BACK_BTN, W_WVGA_PORTRAIT_BACK_BTN, H_WVGA_PORTRAIT_BACK_BTN);
1684 __pControlLabel->SetBounds(X_HVGA_PORTRAIT_CONTROLLER, Y_HVGA_PORTRAIT_CONTROLLER, W_HVGA_PORTRAIT_CONTROLLER, H_HVGA_PORTRAIT_CONTROLLER);
1685 __pFirstLineLabel->SetBounds(X_HVGA_PORTRAIT_FIRST_LINE, Y_HVGA_PORTRAIT_FIRST_LINE, W_HVGA_PORTRAIT_FIRST_LINE, H_HVGA_PORTRAIT_FIRST_LINE);
1687 __pCurrenTimeLabel->SetBounds(X_HVGA_PORTRAIT_CURRENT_TIME, Y_HVGA_PORTRAIT_CURRENT_TIME, W_HVGA_PORTRAIT_CURRENT_TIME, H_HVGA_PORTRAIT_CURRENT_TIME);
1688 __pSlider->SetBounds(X_HVGA_PORTRAIT_SLIDER, Y_HVGA_PORTRAIT_SLIDER, W_HVGA_PORTRAIT_SLIDER, H_HVGA_PORTRAIT_SLIDER);
1689 __pTotalTimeLabel->SetBounds(X_HVGA_PORTRAIT_TOTAL_TIME, Y_HVGA_PORTRAIT_TOTAL_TIME, W_HVGA_PORTRAIT_TOTAL_TIME, H_HVGA_PORTRAIT_TOTAL_TIME);
1691 __pVerticalLeftLine->SetBounds(X_HVGA_PORTRAIT_VERTICAL_LEFT_LINE, Y_HVGA_PORTRAIT_VERTICAL_LEFT_LINE, W_HVGA_PORTRAIT_VERTICAL_LEFT_LINE, H_HVGA_PORTRAIT_VERTICAL_LEFT_LINE);
1692 __pFastRewindButton->SetBounds(X_HVGA_PORTRAIT_FASTREWIND_BTN, Y_HVGA_PORTRAIT_FASTREWIND_BTN, W_HVGA_PORTRAIT_FASTREWIND_BTN, H_HVGA_PORTRAIT_FASTREWIND_BTN);
1693 __pPlayPauseButton->SetBounds(X_HVGA_PORTRAIT_PLAYPAUSE_BTN, Y_HVGA_PORTRAIT_PLAYPAUSE_BTN, W_HVGA_PORTRAIT_PLAYPAUSE_BTN, H_HVGA_PORTRAIT_PLAYPAUSE_BTN);
1694 __pFastForwardButton->SetBounds(X_HVGA_PORTRAIT_FASTFORWARD_BTN, Y_HVGA_PORTRAIT_FASTFORWARD_BTN, W_HVGA_PORTRAIT_FASTFORWARD_BTN, H_HVGA_PORTRAIT_FASTFORWARD_BTN);
1695 __pVerticalRightLine->SetBounds(X_HVGA_PORTRAIT_VERTICAL_RIGHT_LINE, Y_HVGA_PORTRAIT_VERTICAL_RIGHT_LINE, W_HVGA_PORTRAIT_VERTICAL_RIGHT_LINE, H_HVGA_PORTRAIT_VERTICAL_RIGHT_LINE);
1696 __pBackButton->SetBounds(X_HVGA_PORTRAIT_BACK_BTN, Y_HVGA_PORTRAIT_BACK_BTN, W_HVGA_PORTRAIT_BACK_BTN, H_HVGA_PORTRAIT_BACK_BTN);
1701 case ORIENTATION_STATUS_LANDSCAPE:
1703 case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
1705 if (GetClientAreaBounds().width <= W_WVGA_LANDSCAPE_WIDTH)
1707 __pControlLabel->SetBounds(X_WVGA_LANDSCAPE_CONTROLLER, Y_WVGA_LANDSCAPE_CONTROLLER, W_WVGA_LANDSCAPE_CONTROLLER, H_WVGA_LANDSCAPE_CONTROLLER);
1708 __pFirstLineLabel->SetBounds(X_WVGA_LANDSCAPE_FIRST_LINE, Y_WVGA_LANDSCAPE_FIRST_LINE, W_WVGA_LANDSCAPE_FIRST_LINE, H_WVGA_LANDSCAPE_FIRST_LINE);
1710 __pCurrenTimeLabel->SetBounds(X_WVGA_LANDSCAPE_CURRENT_TIME, Y_WVGA_LANDSCAPE_CURRENT_TIME, W_WVGA_LANDSCAPE_CURRENT_TIME, H_WVGA_LANDSCAPE_CURRENT_TIME);
1711 __pSlider->SetBounds(X_WVGA_LANDSCAPE_SLIDER, Y_WVGA_LANDSCAPE_SLIDER, W_WVGA_LANDSCAPE_SLIDER, H_WVGA_LANDSCAPE_SLIDER);
1712 __pTotalTimeLabel->SetBounds(X_WVGA_LANDSCAPE_TOTAL_TIME, Y_WVGA_LANDSCAPE_TOTAL_TIME, W_WVGA_LANDSCAPE_TOTAL_TIME, H_WVGA_LANDSCAPE_TOTAL_TIME);
1714 __pVerticalLeftLine->SetBounds(X_WVGA_LANDSCAPE_VERTICAL_LEFT_LINE, Y_WVGA_LANDSCAPE_VERTICAL_LEFT_LINE, W_WVGA_LANDSCAPE_VERTICAL_LEFT_LINE, H_WVGA_LANDSCAPE_VERTICAL_LEFT_LINE);
1715 __pFastRewindButton->SetBounds(X_WVGA_LANDSCAPE_FASTREWIND_BTN, Y_WVGA_LANDSCAPE_FASTREWIND_BTN, W_WVGA_LANDSCAPE_FASTREWIND_BTN, H_WVGA_LANDSCAPE_FASTREWIND_BTN);
1716 __pPlayPauseButton->SetBounds(X_WVGA_LANDSCAPE_PLAYPAUSE_BTN, Y_WVGA_LANDSCAPE_PLAYPAUSE_BTN, W_WVGA_LANDSCAPE_PLAYPAUSE_BTN, H_WVGA_LANDSCAPE_PLAYPAUSE_BTN);
1717 __pFastForwardButton->SetBounds(X_WVGA_LANDSCAPE_FASTFORWARD_BTN, Y_WVGA_LANDSCAPE_FASTFORWARD_BTN, W_WVGA_LANDSCAPE_FASTFORWARD_BTN, H_WVGA_LANDSCAPE_FASTFORWARD_BTN);
1718 __pVerticalRightLine->SetBounds(X_WVGA_LANDSCAPE_VERTICAL_RIGHT_LINE, Y_WVGA_LANDSCAPE_VERTICAL_RIGHT_LINE, W_WVGA_LANDSCAPE_VERTICAL_RIGHT_LINE, H_WVGA_LANDSCAPE_VERTICAL_RIGHT_LINE);
1719 __pBackButton->SetBounds(X_WVGA_LANDSCAPE_BACK_BTN, Y_WVGA_LANDSCAPE_BACK_BTN, W_WVGA_LANDSCAPE_BACK_BTN, H_WVGA_LANDSCAPE_BACK_BTN);
1723 __pControlLabel->SetBounds(X_HVGA_LANDSCAPE_CONTROLLER, Y_HVGA_LANDSCAPE_CONTROLLER, W_HVGA_LANDSCAPE_CONTROLLER, H_HVGA_LANDSCAPE_CONTROLLER);
1724 __pFirstLineLabel->SetBounds(X_HVGA_LANDSCAPE_FIRST_LINE, Y_HVGA_LANDSCAPE_FIRST_LINE, W_HVGA_LANDSCAPE_FIRST_LINE, H_HVGA_LANDSCAPE_FIRST_LINE);
1726 __pCurrenTimeLabel->SetBounds(X_HVGA_LANDSCAPE_CURRENT_TIME, Y_HVGA_LANDSCAPE_CURRENT_TIME, W_HVGA_LANDSCAPE_CURRENT_TIME, H_HVGA_LANDSCAPE_CURRENT_TIME);
1727 __pSlider->SetBounds(X_HVGA_LANDSCAPE_SLIDER, Y_HVGA_LANDSCAPE_SLIDER, W_HVGA_LANDSCAPE_SLIDER, H_HVGA_LANDSCAPE_SLIDER);
1728 __pTotalTimeLabel->SetBounds(X_HVGA_LANDSCAPE_TOTAL_TIME, Y_HVGA_LANDSCAPE_TOTAL_TIME, W_HVGA_LANDSCAPE_TOTAL_TIME, H_HVGA_LANDSCAPE_TOTAL_TIME);
1730 __pVerticalLeftLine->SetBounds(X_HVGA_LANDSCAPE_VERTICAL_LEFT_LINE, Y_HVGA_LANDSCAPE_VERTICAL_LEFT_LINE, W_HVGA_LANDSCAPE_VERTICAL_LEFT_LINE, H_HVGA_LANDSCAPE_VERTICAL_LEFT_LINE);
1731 __pFastRewindButton->SetBounds(X_HVGA_LANDSCAPE_FASTREWIND_BTN, Y_HVGA_LANDSCAPE_FASTREWIND_BTN, W_HVGA_LANDSCAPE_FASTREWIND_BTN, H_HVGA_LANDSCAPE_FASTREWIND_BTN);
1732 __pPlayPauseButton->SetBounds(X_HVGA_LANDSCAPE_PLAYPAUSE_BTN, Y_HVGA_LANDSCAPE_PLAYPAUSE_BTN, W_HVGA_LANDSCAPE_PLAYPAUSE_BTN, H_HVGA_LANDSCAPE_PLAYPAUSE_BTN);
1733 __pFastForwardButton->SetBounds(X_HVGA_LANDSCAPE_FASTFORWARD_BTN, Y_HVGA_LANDSCAPE_FASTFORWARD_BTN, W_HVGA_LANDSCAPE_FASTFORWARD_BTN, H_HVGA_LANDSCAPE_FASTFORWARD_BTN);
1734 __pVerticalRightLine->SetBounds(X_HVGA_LANDSCAPE_VERTICAL_RIGHT_LINE, Y_HVGA_LANDSCAPE_VERTICAL_RIGHT_LINE, W_HVGA_LANDSCAPE_VERTICAL_RIGHT_LINE, H_HVGA_LANDSCAPE_VERTICAL_RIGHT_LINE);
1735 __pBackButton->SetBounds(X_HVGA_LANDSCAPE_BACK_BTN, Y_HVGA_LANDSCAPE_BACK_BTN, W_HVGA_LANDSCAPE_BACK_BTN, H_HVGA_LANDSCAPE_BACK_BTN);
1746 VideoPlayerForm::ShowControlByFrameActivated(void)
1748 Bitmap* pPlayBitmap = null;
1750 AppLogDebug("ShowControlByFrameActivated");
1752 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1754 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR|FORM_ACTION_BAR_HEADER, true);
1756 pPlayBitmap = pAppResource->GetBitmapN(L"T01_icon_toolbar_play.png");
1757 __pPlayPauseButton->SetNormalBackgroundBitmap(*pPlayBitmap);
1759 __pPlayPauseButton->SetShowState(true);
1760 __pFastRewindButton->SetShowState(true);
1761 __pFastForwardButton->SetShowState(true);
1762 __pBackButton->SetShowState(true);
1763 __pSlider->SetShowState(true);
1764 __pCurrenTimeLabel->SetShowState(true);
1765 __pTotalTimeLabel->SetShowState(true);
1766 __pControlLabel->SetShowState(true);
1767 __pFirstLineLabel->SetShowState(true);
1768 __pVerticalLeftLine->SetShowState(true);
1769 __pVerticalRightLine->SetShowState(true);
1774 CheckLowBatteryStatus();
1780 VideoPlayerForm::CancelTimerByFrameDeactivated(void)
1782 result r = E_FAILURE;
1784 AppLogDebug("CancelTimerByFrameDeactivated");
1786 __pUiControlTimer->Cancel();
1788 __setPauseState = true;
1790 if (__audioRouteMode == AUDIO_ROUTE_SPEAKER_ONLY)
1792 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
1793 TryReturnVoid(r == E_SUCCESS, "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
1795 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
1799 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
1800 TryReturnVoid(r == E_SUCCESS, "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
1802 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
1807 VideoPlayerForm::OnPlayContentChanged(const String& fileName)
1811 AppLogDebug("OnPlayContentChanged");
1813 GetTotalTime(totalTime);
1815 __pHeader->SetTitleText(fileName);
1816 __pHeader->Invalidate(true);
1818 __pTotalTimeLabel->SetText(totalTime);
1819 __pTotalTimeLabel->Invalidate(true);
1823 VideoPlayerForm::OnPlayTimeChanged(int currentProgressPos, String& playTime)
1825 AppLogDebug("OnPlayTimeChanged");
1827 __pSlider->SetValue(currentProgressPos);
1828 __pSlider->Invalidate(true);
1830 __pCurrenTimeLabel->SetText(playTime);
1831 __pCurrenTimeLabel->Invalidate(true);
1835 VideoPlayerForm::OnPlayStateChanged(PlayerState playState)
1837 AppLogDebug("OnPlayStateChanged");
1839 SetPlayPauseButtonImage(playState);
1841 if (playState == PLAYER_STATE_PLAYING)
1843 __pUiControlTimer->Start(SHOW_CONTROL_DURATION);
1847 __pUiControlTimer->Cancel();
1853 VideoPlayerForm::CheckLowBatteryStatus(void)
1857 bool isCharging = false;
1858 BatteryLevel batteryLevel;
1860 AppLogDebug("CheckLowBatteryStatus");
1862 Battery::GetCurrentLevel(batteryLevel);
1863 Battery::IsCharging(isCharging);
1865 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
1867 if (isCharging == false)
1869 msgBox.Construct(L"", L"Unable to video play.Low battery", MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
1870 msgBox.ShowAndWait(result);
1874 case MSGBOX_RESULT_CLOSE:
1876 AppLogDebug("MSGBOX_RESULT_CLOSE");
1877 OnFormBackRequested(*this);
1889 VideoPlayerForm::CheckCallStatus(void)
1893 int modalResult = 0;
1894 result r = E_FAILURE;
1896 AppLogDebug("CheckCallStatus");
1898 CallManager* pCallManager = new (std::nothrow) CallManager();
1900 r = pCallManager->Construct();
1901 TryCatch(r == E_SUCCESS, , "pCallManager->Construct() failed : %s", GetErrorMessage(r));
1903 if (pCallManager->GetCurrentCallStatus() != CALL_STATUS_IDLE
1904 && pCallManager->GetCurrentCallStatus() != CALL_STATUS_UNDEFINED)
1906 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1907 pAppResource->GetString(L"IDS_VPL_BODY_UNABLE_TO_PLAY_VIDEO_DURING_CALL", dispString);
1909 msgBox.Construct(L"", dispString, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_3_SEC);
1910 msgBox.ShowAndWait(modalResult);
1912 switch (modalResult)
1914 case MSGBOX_RESULT_CLOSE:
1916 AppLogDebug("MSGBOX_RESULT_CLOSE");
1917 OnFormBackRequested(*this);
1927 delete pCallManager;
1928 pCallManager = null;
1932 VideoPlayerForm::OnFormBackRequested(Form& source)
1934 result r = E_FAILURE;
1936 AppLogDebug("OnFormBackRequested");
1938 UiApp* pApp = UiApp::GetInstance();
1939 TryReturnVoid(pApp != null, "pApp is null");
1941 r = pApp->Terminate();
1942 TryReturnVoid(r == E_SUCCESS, "Failed Terminate [%s]", GetErrorMessage(r));
1946 VideoPlayerForm::OnActiveAudioRouteChanged(const AudioRouteInfo& route)
1948 Color BtnColor(0, 0, 0, 0);
1949 int currentOutputAudioDevice = 0;
1950 Bitmap* pBitmapScreenMode = null;
1951 Bitmap* pBitmapSoundPath = null;
1952 ArrayList* pArgs = null;
1953 result r = E_FAILURE;
1955 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
1957 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1959 AppLogDebug("OnActiveAudioRouteChanged");
1961 switch (route.GetOutputAudioDevice())
1963 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
1965 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
1966 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1968 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1970 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
1971 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1973 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
1975 if (__pSoundPathPopup != null)
1977 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1980 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
1981 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
1983 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
1989 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
1991 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
1992 &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
1994 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
1996 if (__pSoundPathPopup != null)
1998 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2001 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2003 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_WIRED_ACCESSORY_MENU,
2007 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2008 &&(__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2010 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2012 if (__pHeader->GetButtonStatus(BUTTON_POSITION_LEFT) == BUTTON_ITEM_STATUS_DISABLED)
2014 if (__screenMode == SCREEN_MODE_FIT)
2016 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
2017 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2018 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2020 else if (__screenMode == SCREEN_MODE_NORMAL)
2022 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
2023 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2024 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2028 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
2029 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2030 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2033 __pButtonLeftItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2034 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2035 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
2038 pBitmapSoundPath = pAppResource->GetBitmapN(L"T01_icon_title_soundpath.png");
2039 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapSoundPath);
2040 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2042 __pButtonRightItem->SetActionId(IDA_BUTTON_SOUNDPATH);
2043 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2044 __pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
2046 if (__pSoundPathPopup != null)
2048 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2049 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2051 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2054 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2055 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
2057 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2063 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2065 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2066 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
2068 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2070 if (__screenMode == SCREEN_MODE_FIT)
2072 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2073 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2075 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
2076 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2077 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2079 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2081 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2082 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2083 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2085 else if (__screenMode == SCREEN_MODE_NORMAL)
2087 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2088 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2090 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
2091 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2092 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2094 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2096 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2097 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2098 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2102 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2103 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2105 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
2106 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2107 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2109 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2111 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2112 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2113 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2116 if (__pSoundPathPopup != null)
2118 if (__pSoundPathPopup->GetShowState() == true)
2120 __pSoundPathPopup->SetShowState(false);
2124 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2125 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false))
2127 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2129 if (__screenMode == SCREEN_MODE_FIT)
2131 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
2132 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2133 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2135 else if (__screenMode == SCREEN_MODE_NORMAL)
2137 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
2138 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2139 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2143 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
2144 r = __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2145 TryCatch(r == E_SUCCESS, , "__pButtonLeftItem->SetIcon() Failed:%s", GetErrorMessage(r));
2148 __pButtonLeftItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2149 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2150 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
2152 pBitmapSoundPath = pAppResource->GetBitmapN(L"T01_icon_title_soundpath.png");
2153 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapSoundPath);
2154 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2156 __pButtonRightItem->SetActionId(IDA_BUTTON_SOUNDPATH);
2157 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2158 __pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
2160 if (__pSoundPathPopup != null)
2162 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2163 currentOutputAudioDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2165 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2168 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2169 pArgs->Add(*(new (std::nothrow) Integer(currentOutputAudioDevice)));
2171 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2181 delete pBitmapSoundPath;
2182 pBitmapSoundPath = null;
2185 delete pBitmapSoundPath;
2186 pBitmapSoundPath = null;
2190 VideoPlayerForm::OnAudioRouteAdded(const AudioRouteInfo& route)
2192 AppLogDebug("OnAudioRouteAdded");
2194 switch (route.GetOutputAudioDevice())
2196 case OUTPUT_AUDIO_DEVICE_NONE:
2198 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2202 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2204 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2208 case OUTPUT_AUDIO_DEVICE_RECEIVER:
2210 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2214 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2216 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2220 case OUTPUT_AUDIO_DEVICE_BT_SCO:
2222 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2226 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2228 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = true;
2238 VideoPlayerForm::OnAudioRouteRemoved(const AudioRouteInfo& route)
2240 result r = E_FAILURE;
2241 ArrayList* pArgs = null;
2242 Bitmap* pBitmapScreenMode = null;
2243 int currentOutputDevice = 0;
2244 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2246 AppLogDebug("OnAudioRouteRemoved");
2248 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
2250 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2252 switch (route.GetOutputAudioDevice())
2254 case OUTPUT_AUDIO_DEVICE_NONE:
2256 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = false;
2260 case OUTPUT_AUDIO_DEVICE_SPEAKER:
2262 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = false;
2266 case OUTPUT_AUDIO_DEVICE_RECEIVER:
2268 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = false;
2272 case OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY:
2274 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = false;
2278 case OUTPUT_AUDIO_DEVICE_BT_SCO:
2280 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = false;
2284 case OUTPUT_AUDIO_DEVICE_BT_A2DP:
2286 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] = false;
2294 if (currentAudioRoute.GetOutputAudioDevice() != route.GetOutputAudioDevice())
2296 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2298 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2299 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2301 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2303 if (__pSoundPathPopup != null)
2305 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2308 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2309 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2311 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2315 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2317 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2318 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2320 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2322 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2323 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2325 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2327 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2328 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2330 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2332 if (__pSoundPathPopup != null)
2334 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2335 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2337 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2340 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2341 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2343 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2347 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2349 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2350 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2352 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2354 if (__pSoundPathPopup != null)
2356 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2359 pArgs->Add(*(new (std::nothrow) String(__pAudioRouteManager->GetActiveBluetoothA2dpName())));
2360 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2362 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_BLUETOOTHA2DP_AND_SPEAKER_MENU, pArgs);
2365 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2366 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2368 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2370 if (__pSoundPathPopup != null)
2372 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2373 currentOutputDevice = static_cast<int>(currentAudioRoute.GetOutputAudioDevice());
2375 pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
2378 pArgs->Add(*(new (std::nothrow) Integer(__audioRouteMode)));
2379 pArgs->Add(*(new (std::nothrow) Integer(currentOutputDevice)));
2381 __pSoundPathPopup->SendUserEvent(REQUEST_UPDATE_WIRED_ACCESSORY_AND_SPEAKER_MENU, pArgs);
2384 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2385 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2387 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2389 if (__screenMode == SCREEN_MODE_FIT)
2391 __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2393 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode03.png");
2394 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2395 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2397 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2399 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2400 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2401 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2403 else if (__screenMode == SCREEN_MODE_NORMAL)
2405 __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2407 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode01.png");
2408 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2409 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2411 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2413 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2414 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2415 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2419 __pButtonLeftItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, null);
2421 pBitmapScreenMode = pAppResource->GetBitmapN(L"T01_icon_title_screenmode02.png");
2422 r = __pButtonRightItem->SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapScreenMode);
2423 TryCatch(r == E_SUCCESS, , "__pButtonRightItem->SetIcon() Failed:%s", GetErrorMessage(r));
2425 __pButtonRightItem->SetActionId(IDA_BUTTON_FULLSCREEN);
2427 __pHeader->SetButton(BUTTON_POSITION_LEFT, *__pButtonLeftItem);
2428 __pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pButtonRightItem);
2429 __pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
2432 if (__pSoundPathPopup != null)
2434 if (__pSoundPathPopup->GetShowState() == true)
2436 __pSoundPathPopup->SetShowState(false);
2443 delete pBitmapScreenMode;
2444 pBitmapScreenMode = null;
2447 delete pBitmapScreenMode;
2448 pBitmapScreenMode = null;
2452 VideoPlayerForm::InitAudioRouteList(void)
2454 AppLogDebug("InitAudioRouteList");
2457 IList* availableAudioRouteList = null;
2458 AudioRouteInfo* tempRouteInfo = null;
2459 AudioRouteInfo availableRouteInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2460 AudioRouteInfo currentAudioRoute(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
2462 availableAudioRouteList = __pAudioRouteManager->GetAvailableAudioRouteListN();
2464 for (listCount = 0; listCount < availableAudioRouteList->GetCount(); ++listCount)
2466 tempRouteInfo = static_cast<AudioRouteInfo*>(availableAudioRouteList->GetAt(listCount));
2467 availableRouteInfo = *tempRouteInfo;
2469 if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_NONE)
2471 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_NONE] = true;
2473 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2475 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] = true;
2477 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_RECEIVER)
2479 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_RECEIVER] = true;
2481 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2483 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] = true;
2485 else if (availableRouteInfo.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_SCO)
2487 __availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_SCO] = true;
2491 __availableAudioRoute[OUTPUT_AUDIO_DEVICE_BT_A2DP] = true;
2495 currentAudioRoute = __pAudioRouteManager->GetActiveAudioRoute();
2497 if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_BT_A2DP)
2499 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2500 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2502 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2504 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true)
2505 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2507 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2509 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false)
2510 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2512 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2515 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_WIRED_ACCESSORY)
2517 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2518 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2520 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2522 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2523 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == false))
2525 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_WIRED_ACCESSORY;
2527 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2528 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_SPEAKER] == true))
2530 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2533 else if (currentAudioRoute.GetOutputAudioDevice() == OUTPUT_AUDIO_DEVICE_SPEAKER)
2535 if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == true)
2536 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2538 __audioRouteMode = AUDIO_ROUTE_BT_A2DP_AND_SPEAKER;
2540 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2541 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == true))
2543 __audioRouteMode = AUDIO_ROUTE_WIRED_ACCESSORY_AND_SPEAKER;
2545 else if ((__availableAudioRoute[OUTPUT_AUDIO_ROUTE_BT_A2DP] == false)
2546 && (__availableAudioRoute[OUTPUT_AUDIO_ROUTE_WIRED_ACCESSORY] == false))
2548 __audioRouteMode = AUDIO_ROUTE_SPEAKER_ONLY;
2554 VideoPlayerForm::SetActiveAudioRoute(const AudioRouteInfo& route)
2556 AppLogDebug("SetActiveAudioRoute");
2557 result r = __pAudioRouteManager->SetActiveAudioRoute(route);
2563 VideoPlayerForm::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
2565 BatteryLevel batteryLevel;
2567 AppLogDebug("OnUserEventReceivedN");
2571 case REQUEST_VIDEO_EVENT_BATTERY_LEVEL_CHANGED:
2573 Battery::GetCurrentLevel(batteryLevel);
2575 if (batteryLevel == BATTERY_CRITICAL || batteryLevel == BATTERY_EMPTY)
2577 OnFormBackRequested(*this);