author | Fionntina Carville <fionntinac@symbian.org> |
Mon, 15 Nov 2010 11:50:30 +0000 | |
branch | RCL_3 |
changeset 73 | f89a65650939 |
parent 70 | 375929f879c2 |
permissions | -rw-r--r-- |
57 | 1 |
/* |
2 |
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Progress bar control |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
70
375929f879c2
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
19 |
// Version : %version: e003sa33#24 % |
57 | 20 |
|
21 |
||
22 |
// INCLUDE FILES |
|
23 |
#include <eikenv.h> |
|
24 |
#include <gulicon.h> |
|
25 |
#include <AknUtils.h> |
|
26 |
#include <eiklabel.h> |
|
27 |
#include <StringLoader.h> |
|
28 |
#include <AknsDrawUtils.h> |
|
29 |
#include <aknlayoutscalable_apps.cdl.h> |
|
30 |
#include <aknlayoutscalable_avkon.cdl.h> |
|
31 |
#include <data_caging_path_literals.hrh> |
|
32 |
||
33 |
#include <mpxvideoplaybackcontrols.rsg> |
|
34 |
#include <mpxvideoplaybackcontrols.mbg> |
|
35 |
||
36 |
#include "mpxcommonvideoplaybackview.hrh" |
|
37 |
#include "mpxvideoplaybackprogressbar.h" |
|
38 |
#include "mpxvideoplaybackcontrolscontroller.h" |
|
39 |
#include "mpxvideoplaybackviewfiledetails.h" |
|
40 |
#include "mpxvideo_debug.h" |
|
41 |
||
42 |
#ifdef RD_TACTILE_FEEDBACK |
|
43 |
#include <touchfeedback.h> |
|
44 |
#endif //RD_TACTILE_FEEDBACK |
|
45 |
||
46 |
using namespace AknLayoutScalable_Apps; |
|
47 |
||
48 |
// CONSTANTS |
|
49 |
const TInt KMPXProgressSliderWidth = 20; |
|
50 |
const TInt KMPXSliderHeightOverProgresBar = 5; |
|
51 |
const TInt64 KMPXMicroSeconds = 1000000; |
|
52 |
const TInt KMPXOneHourInSeconds = 3600; |
|
53 |
||
54 |
const TInt KMPXProgressBarHeight = 41; |
|
55 |
||
56 |
// ============================ MEMBER FUNCTIONS =================================================== |
|
57 |
||
58 |
CMPXVideoPlaybackProgressBar::CMPXVideoPlaybackProgressBar( |
|
59 |
CMPXVideoPlaybackControlsController* aController ) |
|
60 |
: iController( aController ) |
|
61 |
, iPlaybackRatio( 0.0 ) |
|
62 |
, iDownloadRatio( 0.0 ) |
|
63 |
, iDragging( EFalse ) |
|
64 |
, iPointerEventStarted( EFalse ) |
|
65 |
, iWasPlaying ( EFalse ) |
|
66 |
, iOldDLSize(0) |
|
67 |
{ |
|
68 |
} |
|
69 |
||
70 |
// ------------------------------------------------------------------------------------------------- |
|
71 |
// CMPXVideoPlaybackProgressBar::ConstructL() |
|
72 |
// Symbian 2nd phase constructor can leave. |
|
73 |
// ------------------------------------------------------------------------------------------------- |
|
74 |
// |
|
75 |
void CMPXVideoPlaybackProgressBar::ConstructL( TRect aRect ) |
|
76 |
{ |
|
77 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::ConstructL()")); |
|
78 |
||
79 |
SetRect( TRect(0, 0, aRect.Width(), aRect.Height()) ); |
|
80 |
||
81 |
SetLayoutL(); |
|
82 |
SkinChangeL(); |
|
83 |
||
84 |
// |
|
85 |
// Read time format strings from AVKON resource |
|
86 |
// |
|
87 |
iMinSecFormatString = iEikonEnv->AllocReadResourceL(R_QTN_TIME_DURAT_MIN_SEC); |
|
88 |
iHourMinSecFormatString = iEikonEnv->AllocReadResourceL(R_QTN_TIME_DURAT_LONG); |
|
89 |
||
90 |
#ifdef RD_TACTILE_FEEDBACK |
|
91 |
iFeedback = MTouchFeedback::Instance(); |
|
92 |
#endif //RD_TACTILE_FEEDBACK |
|
93 |
} |
|
94 |
||
95 |
// ------------------------------------------------------------------------------------------------- |
|
96 |
// CMPXVideoPlaybackProgressBar::NewL() |
|
97 |
// Two-phased constructor. |
|
98 |
// ------------------------------------------------------------------------------------------------- |
|
99 |
// |
|
100 |
CMPXVideoPlaybackProgressBar* CMPXVideoPlaybackProgressBar::NewL( |
|
101 |
CMPXVideoPlaybackControlsController* aController, |
|
102 |
TRect aRect ) |
|
103 |
{ |
|
104 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::NewL()")); |
|
105 |
||
106 |
CMPXVideoPlaybackProgressBar* self = |
|
107 |
new ( ELeave ) CMPXVideoPlaybackProgressBar( aController ); |
|
108 |
||
109 |
CleanupStack::PushL( self ); |
|
110 |
self->ConstructL( aRect ); |
|
111 |
CleanupStack::Pop(); |
|
112 |
return self; |
|
113 |
} |
|
114 |
||
115 |
// ------------------------------------------------------------------------------------------------- |
|
116 |
// CMPXVideoPlaybackProgressBar::~CMPXVideoPlaybackProgressBar() |
|
117 |
// Destructor. |
|
118 |
// ------------------------------------------------------------------------------------------------- |
|
119 |
// |
|
120 |
CMPXVideoPlaybackProgressBar::~CMPXVideoPlaybackProgressBar() |
|
121 |
{ |
|
122 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::~CMPXVideoPlaybackProgressBar()")); |
|
123 |
||
124 |
if ( iMinSecFormatString ) |
|
125 |
{ |
|
126 |
delete iMinSecFormatString; |
|
127 |
iMinSecFormatString = NULL; |
|
128 |
} |
|
129 |
||
130 |
if ( iHourMinSecFormatString ) |
|
131 |
{ |
|
132 |
delete iHourMinSecFormatString; |
|
133 |
iHourMinSecFormatString = NULL; |
|
134 |
} |
|
135 |
||
136 |
if ( iLiveStreamingString ) |
|
137 |
{ |
|
138 |
delete iLiveStreamingString; |
|
139 |
iLiveStreamingString = NULL; |
|
140 |
} |
|
141 |
||
142 |
if ( iFrameIcon ) |
|
143 |
{ |
|
144 |
delete iFrameIcon; |
|
145 |
iFrameIcon = NULL; |
|
146 |
} |
|
147 |
||
148 |
if ( iPlaybackIcon ) |
|
149 |
{ |
|
150 |
delete iPlaybackIcon; |
|
151 |
iPlaybackIcon = NULL; |
|
152 |
} |
|
153 |
||
154 |
if ( iDownloadIcon ) |
|
155 |
{ |
|
156 |
delete iDownloadIcon; |
|
157 |
iDownloadIcon = NULL; |
|
158 |
} |
|
159 |
||
160 |
if ( iSliderIcon ) |
|
161 |
{ |
|
162 |
delete iSliderIcon; |
|
163 |
iSliderIcon = NULL; |
|
164 |
} |
|
165 |
||
166 |
if ( iSelectedSliderIcon ) |
|
167 |
{ |
|
168 |
delete iSelectedSliderIcon; |
|
169 |
iSelectedSliderIcon = NULL; |
|
170 |
} |
|
171 |
||
172 |
if ( iPositionLabel ) |
|
173 |
{ |
|
174 |
delete iPositionLabel; |
|
175 |
iPositionLabel = NULL; |
|
176 |
} |
|
177 |
||
178 |
if ( iDurationLabel ) |
|
179 |
{ |
|
180 |
delete iDurationLabel; |
|
181 |
iDurationLabel = NULL; |
|
182 |
} |
|
183 |
||
184 |
#ifdef RD_TACTILE_FEEDBACK |
|
185 |
if ( iFeedback ) |
|
186 |
{ |
|
187 |
iFeedback->RemoveFeedbackForControl( this ); |
|
188 |
} |
|
189 |
#endif //RD_TACTILE_FEEDBACK |
|
190 |
||
191 |
} |
|
192 |
||
193 |
// ------------------------------------------------------------------------------------------------- |
|
194 |
// CMPXVideoPlaybackProgressBar::HandleResourceChange() |
|
195 |
// ------------------------------------------------------------------------------------------------- |
|
196 |
// |
|
197 |
void CMPXVideoPlaybackProgressBar::HandleResourceChange( TInt aType ) |
|
198 |
{ |
|
199 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::HandleResourceChange(0x%X)"), aType); |
|
200 |
||
201 |
if ( aType == KAknsMessageSkinChange ) |
|
202 |
{ |
|
203 |
TRAP_IGNORE( SkinChangeL() ); |
|
204 |
} |
|
205 |
||
206 |
CCoeControl::HandleResourceChange( aType ); |
|
207 |
} |
|
208 |
||
209 |
// ------------------------------------------------------------------------------------------------- |
|
210 |
// CMPXVideoPlaybackProgressBar::SetLayout() |
|
211 |
// ------------------------------------------------------------------------------------------------- |
|
212 |
// |
|
213 |
void CMPXVideoPlaybackProgressBar::SetLayoutL() |
|
214 |
{ |
|
215 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::SetLayoutL()")); |
|
216 |
||
217 |
// |
|
218 |
// Calculate icon rects |
|
219 |
// |
|
220 |
TRect progressRect = Rect(); |
|
221 |
TInt topMarginHeight = ( progressRect.iBr.iY - KMPXProgressBarHeight ) / 2 - 10; |
|
222 |
progressRect.iTl.iY += topMarginHeight; |
|
223 |
progressRect.iBr.iY = progressRect.iTl.iY + KMPXProgressBarHeight; |
|
224 |
||
225 |
TAknLayoutRect seekBarFrameRect; |
|
226 |
seekBarFrameRect.LayoutRect( progressRect, mup_progress_pane_cp04().LayoutLine() ); |
|
227 |
||
228 |
iFrameIconRect = seekBarFrameRect.Rect(); |
|
229 |
||
230 |
iSliderRect.iTl.iY = iFrameIconRect.iTl.iY - KMPXSliderHeightOverProgresBar; |
|
231 |
iSliderRect.iBr.iY = iFrameIconRect.iBr.iY + KMPXSliderHeightOverProgresBar; |
|
232 |
||
233 |
// |
|
234 |
// Create labels |
|
235 |
// |
|
236 |
if ( iPositionLabel ) |
|
237 |
{ |
|
238 |
delete iPositionLabel; |
|
239 |
iPositionLabel = NULL; |
|
240 |
} |
|
241 |
||
242 |
iPositionLabel = new (ELeave) CEikLabel; |
|
243 |
AknLayoutUtils::LayoutLabel( iPositionLabel, |
|
244 |
progressRect, |
|
245 |
mp4_progress_pane_t1( 1 ).LayoutLine() ) ; |
|
246 |
||
247 |
iPositionLabel->SetContainerWindowL( *this ); |
|
248 |
iPositionLabel->SetTextL( KNullDesC ); |
|
249 |
iPositionLabel->MakeVisible( ETrue ); |
|
250 |
||
251 |
if ( iDurationLabel ) |
|
252 |
{ |
|
253 |
delete iDurationLabel; |
|
254 |
iDurationLabel = NULL; |
|
255 |
} |
|
256 |
||
257 |
iDurationLabel = new (ELeave) CEikLabel; |
|
258 |
||
259 |
AknLayoutUtils::LayoutLabel( iDurationLabel, |
|
260 |
progressRect, |
|
261 |
mp4_progress_pane_t2( 1 ).LayoutLine() ); |
|
262 |
||
263 |
iDurationLabel->SetContainerWindowL( *this ); |
|
264 |
iDurationLabel->SetTextL( KNullDesC ); |
|
265 |
iDurationLabel->MakeVisible( ETrue ); |
|
266 |
} |
|
267 |
||
268 |
// ------------------------------------------------------------------------------------------------- |
|
269 |
// CMPXVideoPlaybackProgressBar::SkinChangeL() |
|
270 |
// ------------------------------------------------------------------------------------------------- |
|
271 |
// |
|
272 |
void CMPXVideoPlaybackProgressBar::SkinChangeL() |
|
273 |
{ |
|
274 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::SkinChangeL()")); |
|
275 |
||
276 |
// |
|
277 |
// Create icons |
|
278 |
// |
|
279 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
280 |
||
281 |
TFileName iconsPath; |
|
282 |
iController->LocateBitmapFileL( iconsPath ); |
|
283 |
||
284 |
delete iFrameIcon; |
|
285 |
iFrameIcon = NULL; |
|
286 |
||
287 |
iFrameIcon = AknsUtils::CreateGulIconL( |
|
288 |
skin, |
|
289 |
KAknsIIDQgnGrafMup2BarFrame, |
|
290 |
iconsPath, |
|
291 |
EMbmMpxvideoplaybackcontrolsQgn_graf_mup2_bar_frame, |
|
292 |
EMbmMpxvideoplaybackcontrolsQgn_graf_mup2_bar_frame_mask); |
|
293 |
||
294 |
if ( iFrameIcon ) |
|
295 |
{ |
|
296 |
AknIconUtils::SetSize( iFrameIcon->Bitmap(), |
|
297 |
iFrameIconRect.Size(), |
|
298 |
EAspectRatioNotPreserved ); |
|
299 |
} |
|
300 |
||
301 |
delete iPlaybackIcon; |
|
302 |
iPlaybackIcon = NULL; |
|
303 |
||
304 |
iPlaybackIcon = AknsUtils::CreateGulIconL( |
|
305 |
skin, |
|
306 |
KAknsIIDQgnGrafMup2BarProgress2, |
|
307 |
iconsPath, |
|
308 |
EMbmMpxvideoplaybackcontrolsQgn_graf_mup2_bar_progress_2, |
|
309 |
EMbmMpxvideoplaybackcontrolsQgn_graf_mup2_bar_progress_2_mask); |
|
310 |
||
311 |
if ( iPlaybackIcon ) |
|
312 |
{ |
|
313 |
AknIconUtils::SetSize( iPlaybackIcon->Bitmap(), |
|
314 |
iFrameIconRect.Size(), |
|
315 |
EAspectRatioNotPreserved ); |
|
316 |
} |
|
317 |
||
318 |
UpdateProgressBarStateL( iController->FileDetails() ); |
|
319 |
} |
|
320 |
||
321 |
// ------------------------------------------------------------------------------------------------- |
|
322 |
// CMPXVideoPlaybackProgressBar::HandlePointerEventL() |
|
323 |
// ------------------------------------------------------------------------------------------------- |
|
324 |
// |
|
325 |
void CMPXVideoPlaybackProgressBar::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
326 |
{ |
|
327 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::HandlePointerEventL()")); |
|
328 |
||
329 |
TMPXPlaybackState state = iController->State(); |
|
330 |
||
331 |
// |
|
332 |
// Block pointer events in the following cases: |
|
333 |
// - The clip is not seekable |
|
334 |
// - The state is not playing/paused |
|
335 |
// - If TV-Out is connected and the clip is DRM protected |
|
336 |
// |
|
337 |
if ( iController->FileDetails()->iSeekable && |
|
338 |
( state == EPbStatePlaying || state == EPbStatePaused ) ) |
|
339 |
{ |
|
340 |
TReal ratio = (TReal) ( aPointerEvent.iPosition.iX - iFrameIconRect.iTl.iX )/ |
|
341 |
(TReal)( iFrameIconRect.Width() - KMPXProgressSliderWidth ); |
|
342 |
||
343 |
if ( ratio > 1.0 ) |
|
344 |
{ |
|
345 |
ratio = 1.0; |
|
346 |
} |
|
347 |
else if ( ratio < 0.0 ) |
|
348 |
{ |
|
349 |
ratio = 0.0; |
|
350 |
} |
|
351 |
||
352 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
353 |
{ |
|
354 |
HandleButtonDownEventL( ratio ); |
|
355 |
} |
|
356 |
else if ( aPointerEvent.iType == TPointerEvent::EDrag ) |
|
357 |
{ |
|
358 |
HandleDraggingEventL( ratio ); |
|
359 |
} |
|
360 |
else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
361 |
{ |
|
362 |
HandleButtonUpEventL( ratio ); |
|
363 |
} |
|
364 |
} |
|
365 |
} |
|
366 |
||
367 |
// ------------------------------------------------------------------------------------------------- |
|
368 |
// CMPXVideoPlaybackProgressBar::HandleButtonDownEventL |
|
369 |
// ------------------------------------------------------------------------------------------------- |
|
370 |
// |
|
371 |
void CMPXVideoPlaybackProgressBar::HandleButtonDownEventL( TReal aRatio ) |
|
372 |
{ |
|
373 |
MPX_ENTER_EXIT(_L("CMPXVideoPlaybackProgressBar::HandleButtonDownEventL()"), |
|
374 |
_L("ratio = %f"), aRatio ); |
|
375 |
||
376 |
iPointerEventStarted = ETrue; |
|
377 |
iWasPlaying = iController->State() == EPbStatePlaying ? ETrue : EFalse; |
|
378 |
||
379 |
if ( iWasPlaying ) |
|
380 |
{ |
|
381 |
iController->HandleCommandL( EMPXPbvCmdCustomPause ); |
|
382 |
} |
|
383 |
||
384 |
#ifdef RD_TACTILE_FEEDBACK |
|
385 |
if ( iFeedback ) |
|
386 |
{ |
|
387 |
#ifdef SYMBIAN_BUILD_GCE |
|
388 |
iFeedback->InstantFeedback( ETouchFeedbackSlider ); |
|
389 |
#else |
|
390 |
iFeedback->InstantFeedback( ETouchFeedbackBasic ); |
|
391 |
#endif //SYMBIAN_BUILD_GCE |
|
392 |
} |
|
393 |
#endif //RD_TACTILE_FEEDBACK |
|
394 |
||
395 |
iDragging = EFalse; |
|
396 |
||
397 |
// |
|
398 |
// Check for PDL using the download icon |
|
399 |
// |
|
400 |
if ( iDownloadIcon && ( aRatio > iDownloadRatio ) ) |
|
401 |
{ |
|
402 |
aRatio = iDownloadRatio; |
|
403 |
} |
|
404 |
||
405 |
PositionChangedL( aRatio * iDuration, ETrue ); |
|
406 |
} |
|
407 |
||
408 |
// ------------------------------------------------------------------------------------------------- |
|
409 |
// CMPXVideoPlaybackProgressBar::HandleDraggingEventL |
|
410 |
// ------------------------------------------------------------------------------------------------- |
|
411 |
// |
|
412 |
void CMPXVideoPlaybackProgressBar::HandleDraggingEventL( TReal aRatio ) |
|
413 |
{ |
|
414 |
MPX_ENTER_EXIT(_L("CMPXVideoPlaybackProgressBar::HandleDraggingEventL()"), |
|
415 |
_L("ratio = %f"), aRatio ); |
|
416 |
||
417 |
#ifdef RD_TACTILE_FEEDBACK |
|
418 |
if ( iFeedback ) |
|
419 |
{ |
|
420 |
#ifdef SYMBIAN_BUILD_GCE |
|
421 |
iFeedback->InstantFeedback( ETouchFeedbackSlider ); |
|
422 |
#else |
|
423 |
iFeedback->InstantFeedback( ETouchFeedbackSensitive ); |
|
424 |
#endif //SYMBIAN_BUILD_GCE |
|
425 |
} |
|
426 |
#endif //RD_TACTILE_FEEDBACK |
|
427 |
||
428 |
iDragging = ETrue; |
|
429 |
||
430 |
if ( iDownloadIcon && ( aRatio > iDownloadRatio ) ) |
|
431 |
{ |
|
432 |
aRatio = iDownloadRatio; |
|
433 |
} |
|
434 |
||
435 |
PositionChangedL( aRatio * iDuration, ETrue ); |
|
436 |
} |
|
437 |
||
438 |
// ------------------------------------------------------------------------------------------------- |
|
439 |
// CMPXVideoPlaybackProgressBar::HandleButtonUpEventL |
|
440 |
// ------------------------------------------------------------------------------------------------- |
|
441 |
// |
|
442 |
void CMPXVideoPlaybackProgressBar::HandleButtonUpEventL( TReal aRatio ) |
|
443 |
{ |
|
444 |
MPX_ENTER_EXIT(_L("CMPXVideoPlaybackProgressBar::HandleButtonUpEventL()"), |
|
445 |
_L("ratio = %f"), aRatio ); |
|
446 |
||
447 |
iDragging = EFalse; |
|
448 |
||
449 |
if ( ( ! iDownloadIcon && aRatio == 1.0 ) || |
|
450 |
( iDownloadIcon && aRatio == 1.0 && iDownloadRatio == 1.0 ) ) |
|
451 |
{ |
|
452 |
iController->HandleCommandL( EMPXPbvCmdEndOfClip ); |
|
453 |
} |
|
454 |
else |
|
455 |
{ |
|
456 |
if ( iDownloadIcon && ( aRatio >= iDownloadRatio ) ) |
|
457 |
{ |
|
458 |
aRatio = iDownloadRatio; |
|
459 |
} |
|
460 |
||
461 |
TInt position = (TInt)( aRatio * iDuration ); |
|
462 |
||
463 |
PositionChangedL( position, ETrue ); |
|
464 |
||
465 |
iController->HandleCommandL( EMPXPbvCmdSetPosition, position ); |
|
466 |
||
467 |
if ( iWasPlaying ) |
|
468 |
{ |
|
469 |
iWasPlaying = EFalse; |
|
470 |
iController->HandleCommandL( EMPXPbvCmdCustomPlay ); |
|
471 |
} |
|
472 |
} |
|
473 |
||
474 |
iPointerEventStarted = EFalse; |
|
475 |
} |
|
476 |
||
477 |
// ------------------------------------------------------------------------------------------------- |
|
478 |
// CMPXVideoPlaybackProgressBar::Draw() |
|
479 |
// ------------------------------------------------------------------------------------------------- |
|
480 |
// |
|
481 |
void CMPXVideoPlaybackProgressBar::Draw( const TRect& aRect ) const |
|
482 |
{ |
|
483 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::Draw()")); |
|
484 |
||
485 |
CWindowGc& gc = SystemGc(); |
|
486 |
gc.SetClippingRect( aRect ); |
|
487 |
||
488 |
if ( Window().DisplayMode() == EColor16MAP ) |
|
489 |
{ |
|
490 |
gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
491 |
gc.SetBrushColor( TRgb::Color16MAP( 255 ) ); |
|
492 |
gc.Clear( aRect ); |
|
493 |
} |
|
494 |
else if ( Window().DisplayMode() == EColor16MA ) |
|
495 |
{ |
|
496 |
gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
497 |
gc.SetBrushColor( TRgb::Color16MA( 0 ) ); |
|
498 |
gc.Clear( aRect ); |
|
499 |
} |
|
500 |
||
501 |
// |
|
502 |
// If it is live streaming, don't need to draw the progress bar |
|
503 |
// |
|
504 |
if ( ! iLiveStreamingString ) |
|
505 |
{ |
|
506 |
if ( iFrameIcon ) |
|
507 |
{ |
|
508 |
gc.BitBltMasked( iFrameIconRect.iTl, |
|
509 |
iFrameIcon->Bitmap(), |
|
510 |
TRect( iFrameIconRect.Size() ), |
|
511 |
iFrameIcon->Mask(), |
|
512 |
ETrue ); |
|
513 |
} |
|
514 |
||
515 |
if ( iDownloadIcon && iDownloadRatio ) |
|
516 |
{ |
|
517 |
gc.BitBltMasked( iDownloadRect.iTl, |
|
518 |
iDownloadIcon->Bitmap(), |
|
519 |
TRect( iDownloadRect.Size() ), |
|
520 |
iDownloadIcon->Mask(), |
|
521 |
ETrue ); |
|
522 |
} |
|
523 |
||
524 |
if ( iPlaybackIcon && iPlaybackRatio ) |
|
525 |
{ |
|
526 |
gc.BitBltMasked( iPlaybackRect.iTl, |
|
527 |
iPlaybackIcon->Bitmap(), |
|
528 |
TRect( iPlaybackRect.Size() ), |
|
529 |
iPlaybackIcon->Mask(), |
|
530 |
ETrue ); |
|
531 |
} |
|
532 |
||
533 |
if ( iSliderIcon && iSelectedSliderIcon && iController->State() != EPbStateStopped ) |
|
534 |
{ |
|
535 |
if ( iDragging ) |
|
536 |
{ |
|
537 |
gc.BitBltMasked( iSliderRect.iTl, |
|
538 |
iSelectedSliderIcon->Bitmap(), |
|
539 |
TRect( iSliderRect.Size() ), |
|
540 |
iSelectedSliderIcon->Mask(), |
|
541 |
ETrue ); |
|
542 |
} |
|
543 |
else |
|
544 |
{ |
|
545 |
gc.BitBltMasked( iSliderRect.iTl, |
|
546 |
iSliderIcon->Bitmap(), |
|
547 |
TRect( iSliderRect.Size() ), |
|
548 |
iSliderIcon->Mask(), |
|
549 |
ETrue ); |
|
550 |
} |
|
551 |
} |
|
552 |
} |
|
553 |
} |
|
554 |
||
555 |
// ------------------------------------------------------------------------------------------------- |
|
556 |
// CMPXVideoPlaybackProgressBar::CountComponentControls() |
|
557 |
// ------------------------------------------------------------------------------------------------- |
|
558 |
// |
|
559 |
TInt CMPXVideoPlaybackProgressBar::CountComponentControls() const |
|
560 |
{ |
|
561 |
return 2; |
|
562 |
} |
|
563 |
||
564 |
// ------------------------------------------------------------------------------------------------- |
|
565 |
// CMPXVideoPlaybackProgressBar::ComponentControl() |
|
566 |
// ------------------------------------------------------------------------------------------------- |
|
567 |
// |
|
568 |
CCoeControl* CMPXVideoPlaybackProgressBar::ComponentControl( TInt aIndex ) const |
|
569 |
{ |
|
570 |
CCoeControl* control = NULL; |
|
571 |
||
572 |
switch ( aIndex ) |
|
573 |
{ |
|
574 |
case 0: |
|
575 |
control = iPositionLabel; |
|
576 |
break; |
|
577 |
case 1: |
|
578 |
control = iDurationLabel; |
|
579 |
break; |
|
580 |
default: |
|
581 |
break; |
|
582 |
} |
|
583 |
||
584 |
return control; |
|
585 |
} |
|
586 |
||
587 |
// ------------------------------------------------------------------------------------------------- |
|
588 |
// CMPXVideoPlaybackProgressBar::DurationChangedL() |
|
589 |
// ------------------------------------------------------------------------------------------------- |
|
590 |
// |
|
591 |
void CMPXVideoPlaybackProgressBar::DurationChangedL( TInt aDuration ) |
|
592 |
{ |
|
593 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::DurationChangedL() [%d]"), aDuration); |
|
594 |
||
595 |
iDuration = aDuration; |
|
596 |
||
597 |
// |
|
598 |
// In live streaming case, |
|
599 |
// Will show "live streaming" text instead of remaining time |
|
600 |
// |
|
601 |
if ( iLiveStreamingString ) |
|
602 |
{ |
|
603 |
iDurationLabel->SetTextL( iLiveStreamingString->Des() ); |
|
604 |
} |
|
605 |
else |
|
606 |
{ |
|
607 |
if ( iDuration > 0 ) |
|
608 |
{ |
|
609 |
SetTextLWithReadableTimeL( iDuration, iDurationLabel ); |
|
610 |
} |
|
611 |
} |
|
612 |
} |
|
613 |
||
614 |
// ------------------------------------------------------------------------------------------------- |
|
615 |
// CMPXVideoPlaybackProgressBar::PositionChangedL() |
|
616 |
// ------------------------------------------------------------------------------------------------- |
|
617 |
// |
|
618 |
void CMPXVideoPlaybackProgressBar::PositionChangedL( TInt aPosition, TBool aUserChanged ) |
|
619 |
{ |
|
620 |
MPX_ENTER_EXIT(_L("CMPXVideoPlaybackProgressBar::PositionChangedL()"), |
|
621 |
_L("aPosition = %d, aUserChanged = %d"), aPosition, aUserChanged ); |
|
622 |
||
623 |
// |
|
624 |
// We will ignore position information which engine sent |
|
625 |
// after we issue SetPosition() |
|
626 |
// |
|
627 |
if ( aPosition == 0 || |
|
628 |
aUserChanged || |
|
629 |
(! iPointerEventStarted && iController->State() != EPbStatePaused ) ) |
|
630 |
{ |
|
631 |
TReal position = aPosition; |
|
632 |
||
633 |
if ( iDuration > 0 && position > iDuration ) |
|
634 |
{ |
|
635 |
position = iDuration; |
|
636 |
} |
|
637 |
||
638 |
SetTextLWithReadableTimeL( (TInt)position, iPositionLabel ); |
|
639 |
||
640 |
if ( ! iLiveStreamingString ) |
|
641 |
{ |
|
642 |
iPlaybackRatio = position / iDuration; |
|
643 |
iPlaybackRect = iFrameIconRect; |
|
644 |
||
645 |
if ( iSliderIcon ) |
|
646 |
{ |
|
647 |
iPlaybackRect.iBr.iX = |
|
648 |
KMPXProgressSliderWidth / 2 + iPlaybackRatio * |
|
649 |
( iFrameIconRect.Width() - KMPXProgressSliderWidth ); |
|
650 |
||
651 |
iSliderRect.iTl.iX = |
|
652 |
iPlaybackRect.iBr.iX - KMPXProgressSliderWidth/2; |
|
653 |
iSliderRect.iBr.iX = |
|
654 |
iPlaybackRect.iBr.iX + KMPXProgressSliderWidth/2; |
|
655 |
} |
|
656 |
else |
|
657 |
{ |
|
658 |
iPlaybackRect.iBr.iX = iPlaybackRatio * iFrameIconRect.Width(); |
|
659 |
} |
|
660 |
} |
|
661 |
||
662 |
if ( IsVisible() ) |
|
663 |
{ |
|
664 |
DrawNow(); |
|
665 |
} |
|
666 |
} |
|
667 |
} |
|
668 |
||
669 |
// ------------------------------------------------------------------------------------------------- |
|
670 |
// CMPXVideoPlaybackProgressBar::SetDownloadSize() |
|
671 |
// ------------------------------------------------------------------------------------------------- |
|
672 |
// |
|
673 |
void CMPXVideoPlaybackProgressBar::SetDownloadSize( TInt aSize ) |
|
674 |
{ |
|
675 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::SetDownloadSize() [%d]"), aSize ); |
|
676 |
||
677 |
iDownloadSize = aSize; |
|
678 |
} |
|
679 |
||
680 |
// ------------------------------------------------------------------------------------------------- |
|
681 |
// CMPXVideoPlaybackProgressBar::UpdateDownloadPosition() |
|
682 |
// ------------------------------------------------------------------------------------------------- |
|
683 |
// |
|
684 |
void CMPXVideoPlaybackProgressBar::UpdateDownloadPosition( TInt aSize ) |
|
685 |
{ |
|
686 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::UpdateDownloadPosition() [%d]"), aSize ); |
|
687 |
||
688 |
if ( iDownloadSize && ( aSize > iOldDLSize ) ) |
|
689 |
{ |
|
690 |
iOldDLSize = aSize; |
|
691 |
iDownloadRatio = (TReal)aSize/(TReal)iDownloadSize; |
|
692 |
||
693 |
iDownloadRect= iFrameIconRect; |
|
694 |
||
695 |
if ( iDownloadIcon && iDownloadRatio > 0.0 ) |
|
696 |
{ |
|
697 |
iDownloadRect.iBr.iX = iDownloadRatio * iFrameIconRect.Width(); |
|
698 |
} |
|
699 |
||
700 |
if ( IsVisible() ) |
|
701 |
{ |
|
702 |
DrawNow(); |
|
703 |
} |
|
704 |
} |
|
705 |
} |
|
706 |
||
707 |
// ------------------------------------------------------------------------------------------------- |
|
708 |
// CMPXVideoPlaybackProgressBar::SetTextLWithReadableTimeL() |
|
709 |
// ------------------------------------------------------------------------------------------------- |
|
710 |
// |
|
711 |
void CMPXVideoPlaybackProgressBar::SetTextLWithReadableTimeL( TInt aTime, CEikLabel* aLabel ) |
|
712 |
{ |
|
713 |
MPX_ENTER_EXIT(_L("CMPXVideoPlaybackProgressBar::SetTextLWithReadableTimeL()"), |
|
714 |
_L("aTime = %d"), aTime ); |
|
715 |
||
716 |
TBuf<16> text; |
|
717 |
||
718 |
TTime time = TTime( (TInt64)aTime * KMPXMicroSeconds ); |
|
719 |
||
720 |
if ( iDuration > 0 && iDuration < KMPXOneHourInSeconds ) |
|
721 |
{ |
|
722 |
// Format time to user readable format. (min:sec) |
|
723 |
time.FormatL( text, *iMinSecFormatString ); |
|
724 |
} |
|
725 |
else |
|
726 |
{ |
|
727 |
// Format time to user readable format. (hour:min:sec) |
|
728 |
time.FormatL( text, *iHourMinSecFormatString ); |
|
729 |
} |
|
730 |
||
731 |
if ( AknTextUtils::DigitModeQuery( AknTextUtils::EDigitModeShownToUser ) ) |
|
732 |
{ |
|
733 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( text ); |
|
734 |
} |
|
735 |
||
736 |
aLabel->SetTextL( text ); |
|
737 |
} |
|
738 |
||
739 |
// ------------------------------------------------------------------------------------------------- |
|
740 |
// CMPXVideoPlaybackProgressBar::UpdateProgressBarStateL() |
|
741 |
// ------------------------------------------------------------------------------------------------- |
|
742 |
// |
|
743 |
void CMPXVideoPlaybackProgressBar::UpdateProgressBarStateL( CMPXVideoPlaybackViewFileDetails* aDetails ) |
|
744 |
{ |
|
745 |
MPX_DEBUG(_L("CMPXVideoPlaybackProgressBar::UpdateProgressBarStateL()")); |
|
746 |
||
747 |
// |
|
748 |
// Update the duration in case it has not been initialized yet |
|
749 |
// |
|
750 |
DurationChangedL( (TReal)aDetails->iDuration / (TReal)KPbMilliMultiplier ); |
|
751 |
||
752 |
TFileName iconsPath; |
|
753 |
iController->LocateBitmapFileL( iconsPath ); |
|
754 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
755 |
||
756 |
if ( aDetails->iPlaybackMode == EMPXVideoProgressiveDownload ) |
|
757 |
{ |
|
758 |
delete iDownloadIcon; |
|
759 |
iDownloadIcon = NULL; |
|
760 |
||
761 |
iDownloadIcon = AknsUtils::CreateGulIconL( |
|
762 |
skin, |
|
763 |
KAknsIIDQgnGrafMup2BarProgress, |
|
764 |
iconsPath, |
|
765 |
EMbmMpxvideoplaybackcontrolsQgn_graf_mup2_bar_progress, |
|
766 |
EMbmMpxvideoplaybackcontrolsQgn_graf_mup2_bar_progress_mask ); |
|
767 |
||
768 |
if ( iDownloadIcon ) |
|
769 |
{ |
|
770 |
AknIconUtils::SetSize( iDownloadIcon->Bitmap(), |
|
771 |
iFrameIconRect.Size(), |
|
772 |
EAspectRatioNotPreserved ); |
|
773 |
} |
|
774 |
} |
|
70
375929f879c2
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
775 |
else if ( aDetails->iPlaybackMode == EMPXVideoLiveStreaming ) |
57 | 776 |
{ |
777 |
iLiveStreamingString = iEikonEnv->AllocReadResourceL( R_MPX_LIVE_STREAMING ); |
|
778 |
||
779 |
// |
|
780 |
// update labels to show live streaming text |
|
781 |
// |
|
782 |
iDurationLabel->SetTextL( iLiveStreamingString->Des() ); |
|
783 |
} |
|
784 |
||
785 |
if ( AknLayoutUtils::PenEnabled() && aDetails->iSeekable ) |
|
786 |
{ |
|
787 |
delete iSliderIcon; |
|
788 |
iSliderIcon = NULL; |
|
789 |
||
790 |
iSliderIcon = AknsUtils::CreateGulIconL( |
|
791 |
skin, |
|
792 |
KAknsIIDQgnGrafNsliderMarker, |
|
793 |
iconsPath, |
|
794 |
EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_marker, |
|
795 |
EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_marker_mask ); |
|
796 |
||
797 |
delete iSelectedSliderIcon; |
|
798 |
iSelectedSliderIcon = NULL; |
|
799 |
||
800 |
iSelectedSliderIcon = AknsUtils::CreateGulIconL( |
|
801 |
skin, |
|
802 |
KAknsIIDQgnGrafNsliderMarkerSelected, |
|
803 |
iconsPath, |
|
804 |
EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_marker_selected, |
|
805 |
EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_marker_selected_mask ); |
|
806 |
||
807 |
if ( iSliderIcon ) |
|
808 |
{ |
|
809 |
AknIconUtils::SetSize( |
|
810 |
iSliderIcon->Bitmap(), |
|
811 |
TSize( KMPXProgressSliderWidth, |
|
812 |
iFrameIconRect.Height() + KMPXSliderHeightOverProgresBar*2 ), |
|
813 |
EAspectRatioNotPreserved ); |
|
814 |
} |
|
815 |
||
816 |
if ( iSelectedSliderIcon ) |
|
817 |
{ |
|
818 |
AknIconUtils::SetSize( |
|
819 |
iSelectedSliderIcon->Bitmap(), |
|
820 |
TSize( KMPXProgressSliderWidth, |
|
821 |
iFrameIconRect.Height() + KMPXSliderHeightOverProgresBar*2 ), |
|
822 |
EAspectRatioNotPreserved ); |
|
823 |
} |
|
824 |
} |
|
825 |
else |
|
826 |
{ |
|
827 |
// |
|
828 |
// for non-seekable media, disable iSliderIcon and iSelectedSliderIcon |
|
829 |
// |
|
830 |
||
831 |
if ( iSliderIcon ) |
|
832 |
{ |
|
833 |
delete iSliderIcon; |
|
834 |
iSliderIcon = NULL; |
|
835 |
} |
|
836 |
||
837 |
if ( iSelectedSliderIcon ) |
|
838 |
{ |
|
839 |
delete iSelectedSliderIcon; |
|
840 |
iSelectedSliderIcon = NULL; |
|
841 |
} |
|
842 |
} |
|
843 |
} |
|
844 |
||
845 |
// ------------------------------------------------------------------------------------------------- |
|
846 |
// CMPXVideoPlaybackProgressBar::Reset |
|
847 |
// ------------------------------------------------------------------------------------------------- |
|
848 |
// |
|
849 |
void CMPXVideoPlaybackProgressBar::Reset() |
|
850 |
{ |
|
851 |
MPX_ENTER_EXIT(_L("CMPXVideoPlaybackProgressBar::Reset()")); |
|
852 |
||
853 |
if ( iPointerEventStarted || iDragging ) |
|
854 |
{ |
|
855 |
TPointerEvent event; |
|
856 |
event.iType = TPointerEvent::EButton1Up; |
|
857 |
event.iPosition.iX = iSliderRect.iTl.iX; |
|
858 |
||
859 |
MPX_TRAPD( err, HandlePointerEventL(event) ); |
|
860 |
} |
|
861 |
} |
|
862 |
||
863 |
// End of File |