|
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: Media Details Viewer |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 8 % |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <eikenv.h> |
|
23 #include <eiklabel.h> |
|
24 #include <AknUtils.h> |
|
25 #include <AknIconUtils.h> |
|
26 #include <StringLoader.h> |
|
27 #include <AknsDrawUtils.h> |
|
28 #include <gulicon.h> |
|
29 #include <gdi.h> |
|
30 #include <e32base.h> |
|
31 |
|
32 #include <mpxfiledetailscntlpluginif.h> |
|
33 #include <mpxvideoplaybackcontrols.rsg> |
|
34 #include <mpxvideoplaybackcontrols.mbg> |
|
35 #include <avkon.rsg> |
|
36 |
|
37 #include "mpxvideoplaybackcontrol.hrh" |
|
38 #include "mpxcommonvideoplaybackview.hrh" |
|
39 #include "mpxvideoplaybackmediadetailsviewer.h" |
|
40 #include "mpxvideoplaybackcontrolscontroller.h" |
|
41 #include "mpxvideoplaybackcontainer.h" |
|
42 |
|
43 // Constants |
|
44 _LIT(KHeadingValueSeperator, ": "); |
|
45 _LIT(KWidthHeightSeparator, " x "); |
|
46 _LIT(KLeftMargin, " " ); |
|
47 |
|
48 const TInt KMediaDetailsViewerMaxItems = 11; // used to determine the height of each item |
|
49 const TInt KMediaDetailsViewerItemMargin = 3; |
|
50 const TInt KMediaDetailsViewerVisibleCharacters = 30; |
|
51 const TInt KMediaDetailsViewerFilenameMedium = 45; |
|
52 const TInt KMediaDetailsViewerOffsetDivisorMedium = 12; |
|
53 const TInt KMediaDetailsViewerOffsetDivisorMax = 20; |
|
54 |
|
55 // UID of this interface |
|
56 const TUid KFileDetailsCntlPluginUid = {0x2002A59D}; |
|
57 const TUid KFileDetailsInterfaceUid = {0x2002A5A0}; |
|
58 // --------------------------------------------------------------------------- |
|
59 // Local function to cleanup an array |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 |
|
63 static void CleanupEcomArray( TAny* aArray ) |
|
64 { |
|
65 ( static_cast<RImplInfoPtrArray*>( aArray ) )->ResetAndDestroy(); |
|
66 ( static_cast<RImplInfoPtrArray*>( aArray ) )->Close(); |
|
67 } |
|
68 |
|
69 // ============================ MEMBER FUNCTIONS =================================================== |
|
70 |
|
71 CMPXVideoPlaybackMediaDetailsViewer::CMPXVideoPlaybackMediaDetailsViewer( |
|
72 CMPXVideoPlaybackControlsController* aController ) |
|
73 : iController( aController ) |
|
74 { |
|
75 } |
|
76 |
|
77 // ------------------------------------------------------------------------------------------------- |
|
78 // CMPXVideoPlaybackMediaDetailsViewer::ConstructL() |
|
79 // Symbian 2nd phase constructor can leave. |
|
80 // ------------------------------------------------------------------------------------------------- |
|
81 // |
|
82 void CMPXVideoPlaybackMediaDetailsViewer::ConstructL() |
|
83 { |
|
84 MPX_DEBUG(_L("CMPXVideoPlaybackMediaDetailsViewer::ConstructL()")); |
|
85 |
|
86 iViewerRect = CalculateViewerRect(); |
|
87 SetRect( TRect(0, 0, iViewerRect.Width(), iViewerRect.Height()) ); |
|
88 |
|
89 CreateLabelsL(); |
|
90 SkinChangeL(); |
|
91 |
|
92 iBackgroundBitmap = new ( ELeave ) CFbsBitmap(); |
|
93 TSize bitmapSize = Rect().Size(); |
|
94 User::LeaveIfError( iBackgroundBitmap->Create( bitmapSize, EColor16MA ) ); |
|
95 |
|
96 iScrollPosition = 0; |
|
97 iScrollingTextTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
98 iScrollingTextTimer->Start( |
|
99 0, |
|
100 175000, |
|
101 TCallBack( CMPXVideoPlaybackMediaDetailsViewer::ScrollFilenameTimer, this ) ); |
|
102 |
|
103 iShouldPauseScrolling = EFalse; |
|
104 |
|
105 } |
|
106 |
|
107 // ------------------------------------------------------------------------------------------------- |
|
108 // CMPXVideoPlaybackMediaDetailsViewer::NewL() |
|
109 // Two-phased constructor. |
|
110 // ------------------------------------------------------------------------------------------------- |
|
111 // |
|
112 CMPXVideoPlaybackMediaDetailsViewer* CMPXVideoPlaybackMediaDetailsViewer::NewL( |
|
113 CMPXVideoPlaybackControlsController* aController ) |
|
114 { |
|
115 MPX_DEBUG(_L("CMPXVideoPlaybackMediaDetailsViewer::NewL()")); |
|
116 |
|
117 CMPXVideoPlaybackMediaDetailsViewer* self = new ( ELeave ) CMPXVideoPlaybackMediaDetailsViewer( aController ); |
|
118 |
|
119 CleanupStack::PushL( self ); |
|
120 self->ConstructL(); |
|
121 CleanupStack::Pop(); |
|
122 return self; |
|
123 } |
|
124 |
|
125 // ------------------------------------------------------------------------------------------------- |
|
126 // CMPXVideoPlaybackMediaDetailsViewer::~CMPXVideoPlaybackMediaDetailsViewer() |
|
127 // Destructor. |
|
128 // ------------------------------------------------------------------------------------------------- |
|
129 // |
|
130 CMPXVideoPlaybackMediaDetailsViewer::~CMPXVideoPlaybackMediaDetailsViewer() |
|
131 { |
|
132 MPX_DEBUG(_L("CMPXVideoPlaybackMediaDetailsViewer::~CMPXVideoPlaybackMediaDetailsViewer()")); |
|
133 |
|
134 if ( iClipnameLabel ) |
|
135 { |
|
136 delete iClipnameLabel; |
|
137 iClipnameLabel = NULL; |
|
138 } |
|
139 |
|
140 if ( iTitleLabel ) |
|
141 { |
|
142 delete iTitleLabel; |
|
143 iTitleLabel = NULL; |
|
144 } |
|
145 |
|
146 if ( iArtistLabel ) |
|
147 { |
|
148 delete iArtistLabel; |
|
149 iArtistLabel = NULL; |
|
150 } |
|
151 |
|
152 if ( iFormatLabel ) |
|
153 { |
|
154 delete iFormatLabel; |
|
155 iFormatLabel = NULL; |
|
156 } |
|
157 |
|
158 if ( iResolutionLabel ) |
|
159 { |
|
160 delete iResolutionLabel; |
|
161 iResolutionLabel = NULL; |
|
162 } |
|
163 |
|
164 if ( iDurationLabel ) |
|
165 { |
|
166 delete iDurationLabel; |
|
167 iDurationLabel = NULL; |
|
168 } |
|
169 |
|
170 if ( iBitrateLabel ) |
|
171 { |
|
172 delete iBitrateLabel; |
|
173 iBitrateLabel = NULL; |
|
174 } |
|
175 |
|
176 if ( iLicenseLabel ) |
|
177 { |
|
178 delete iLicenseLabel; |
|
179 iLicenseLabel = NULL; |
|
180 } |
|
181 |
|
182 if ( iBackgroundBitmap ) |
|
183 { |
|
184 delete iBackgroundBitmap; |
|
185 iBackgroundBitmap = NULL; |
|
186 } |
|
187 |
|
188 if ( iScrollingTextTimer ) |
|
189 { |
|
190 iScrollingTextTimer->Cancel(); |
|
191 delete iScrollingTextTimer; |
|
192 iScrollingTextTimer = NULL; |
|
193 } |
|
194 |
|
195 if ( iAdditionalLabel ) |
|
196 { |
|
197 delete iAdditionalLabel; |
|
198 iAdditionalLabel = NULL; |
|
199 } |
|
200 |
|
201 if ( iAdditionalString ) |
|
202 { |
|
203 delete iAdditionalString; |
|
204 iAdditionalString = NULL; |
|
205 } |
|
206 } |
|
207 |
|
208 // ------------------------------------------------------------------------------------------------- |
|
209 // CMPXVideoPlaybackMediaDetailsViewer::HandlePointerEventL() |
|
210 // ------------------------------------------------------------------------------------------------- |
|
211 // |
|
212 void CMPXVideoPlaybackMediaDetailsViewer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
213 { |
|
214 MPX_DEBUG(_L("CMPXVideoPlaybackMediaDetailsViewer::HandlePointerEventL()")); |
|
215 |
|
216 switch ( aPointerEvent.iType ) |
|
217 { |
|
218 case TPointerEvent::EButton1Down: |
|
219 { |
|
220 break; |
|
221 } |
|
222 case TPointerEvent::EButton1Up: |
|
223 { |
|
224 TRect expandedRect; //make it a bit easier to click the License label |
|
225 |
|
226 if ( iLicenseLabel ) |
|
227 { |
|
228 expandedRect = TRect(iLicenseLabel->Rect().iTl, |
|
229 TPoint(iLicenseLabel->Rect().iBr.iX, |
|
230 iLicenseLabel->Rect().iBr.iY * 2 ) ); |
|
231 } |
|
232 |
|
233 if ( iLicenseLabel && expandedRect.Contains(aPointerEvent.iPosition) ) |
|
234 { |
|
235 LaunchDRMDetailsL(); |
|
236 } |
|
237 else |
|
238 { |
|
239 iController->HandleEventL( EMPXControlCmdCloseFileDetailsViewer ); |
|
240 } |
|
241 } |
|
242 } |
|
243 } |
|
244 |
|
245 // ------------------------------------------------------------------------------------------------- |
|
246 // CMPXVideoPlaybackMediaDetailsViewer::LaunchDRMDetailsL() |
|
247 // ------------------------------------------------------------------------------------------------- |
|
248 // |
|
249 void CMPXVideoPlaybackMediaDetailsViewer::LaunchDRMDetailsL() |
|
250 { |
|
251 iController->iContainer->HandleCommandL(EMPXPbvLaunchDRMDetails); |
|
252 } |
|
253 |
|
254 // ------------------------------------------------------------------------------------------------- |
|
255 // CMPXVideoPlaybackMediaDetailsViewer::SkinChangeL() |
|
256 // ------------------------------------------------------------------------------------------------- |
|
257 // |
|
258 void CMPXVideoPlaybackMediaDetailsViewer::SkinChangeL() |
|
259 { |
|
260 } |
|
261 |
|
262 |
|
263 // ------------------------------------------------------------------------------------------------- |
|
264 // CMPXVideoPlaybackMediaDetailsViewer::Draw() |
|
265 // ------------------------------------------------------------------------------------------------- |
|
266 // |
|
267 void CMPXVideoPlaybackMediaDetailsViewer::Draw( const TRect& aRect ) const |
|
268 { |
|
269 MPX_DEBUG(_L("CMPXVideoPlaybackMediaDetailsViewer::Draw()")); |
|
270 |
|
271 CWindowGc& gc = SystemGc(); |
|
272 gc.SetClippingRect( aRect ); |
|
273 |
|
274 this->DrawableWindow()->SetCornerType(EWindowCorner5); |
|
275 |
|
276 TRAP_IGNORE( UpdateBackgroundBitmapL() ); |
|
277 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
278 gc.BitBlt( Rect().iTl, iBackgroundBitmap ); |
|
279 |
|
280 TRAP_IGNORE( FormatLabelsL() ); |
|
281 |
|
282 gc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
283 } |
|
284 |
|
285 // ------------------------------------------------------------------------------------------------- |
|
286 // CMPXVideoPlaybackMediaDetailsViewer::FormatLabelsL() |
|
287 // ------------------------------------------------------------------------------------------------- |
|
288 // |
|
289 void CMPXVideoPlaybackMediaDetailsViewer::FormatLabelsL() const |
|
290 { |
|
291 // FORMAT LABELS |
|
292 |
|
293 |
|
294 TInt labelWidth = Rect().iBr.iX; |
|
295 TInt labelHeight = iController->iContainer->Rect().iBr.iY / KMediaDetailsViewerMaxItems; |
|
296 TInt rowsAdded = 0; |
|
297 |
|
298 // License |
|
299 if ( iController->FileDetails()->iDrmProtected ) |
|
300 { |
|
301 iLicenseLabel->SetExtent( TPoint(Rect().iTl.iX, Rect().iTl.iY + (labelHeight*rowsAdded) ) , |
|
302 TSize(labelWidth,labelHeight) ); |
|
303 HBufC* heading = iEikonEnv->AllocReadResourceL( R_MPX_LICENSE_HEADING ); |
|
304 TBuf<255> licenseField; |
|
305 licenseField.Append(KLeftMargin); |
|
306 licenseField.Append( *heading ); |
|
307 iLicenseLabel->OverrideColorL(EColorLabelText, KRgbDarkBlue); |
|
308 iLicenseLabel->SetTextL(licenseField); |
|
309 iLicenseLabel->SetAllMarginsTo(KMediaDetailsViewerItemMargin); |
|
310 iLicenseLabel->SetLabelAlignment(ELayoutAlignCenter); |
|
311 iLicenseLabel->SetUnderlining(ETrue); |
|
312 iLicenseLabel->MakeVisible( ETrue ); |
|
313 rowsAdded++; |
|
314 delete heading; |
|
315 } |
|
316 |
|
317 // Filename |
|
318 if ( iController->FileDetails()->iClipName ) |
|
319 { |
|
320 // file name gets populated by HandleScrollFilenameTimer method |
|
321 iClipnameLabel->SetExtent( TPoint(Rect().iTl.iX, Rect().iTl.iY + (labelHeight*rowsAdded) ) , |
|
322 TSize(labelWidth,labelHeight) ); |
|
323 iClipnameLabel->SetAllMarginsTo(KMediaDetailsViewerItemMargin); |
|
324 iClipnameLabel->MakeVisible( ETrue ); |
|
325 rowsAdded++; |
|
326 |
|
327 } |
|
328 |
|
329 // Mime Type (Format) |
|
330 if ( iController->FileDetails()->iMimeType ) |
|
331 { |
|
332 iFormatLabel->SetExtent( TPoint(Rect().iTl.iX, Rect().iTl.iY + (labelHeight*rowsAdded) ) , |
|
333 TSize(labelWidth,labelHeight) ); |
|
334 HBufC* heading = iEikonEnv->AllocReadResourceL( R_MPX_FORMAT_HEADING ); |
|
335 TBuf<255> formatField; |
|
336 formatField.Append(KLeftMargin); |
|
337 formatField.Append( *heading ); |
|
338 formatField.Append( KHeadingValueSeperator ); |
|
339 formatField.Append( *(iController->FileDetails()->iMimeType) ); |
|
340 iFormatLabel->SetTextL(formatField); |
|
341 iFormatLabel->SetAllMarginsTo(KMediaDetailsViewerItemMargin); |
|
342 iFormatLabel->MakeVisible( ETrue ); |
|
343 rowsAdded++; |
|
344 delete heading; |
|
345 } |
|
346 |
|
347 // Resolution |
|
348 if ( iController->FileDetails()->iVideoHeight && |
|
349 iController->FileDetails()->iVideoWidth ) |
|
350 { |
|
351 iResolutionLabel->SetExtent( TPoint(Rect().iTl.iX, Rect().iTl.iY + (labelHeight*rowsAdded) ) , |
|
352 TSize(labelWidth,labelHeight) ); |
|
353 HBufC* heading = iEikonEnv->AllocReadResourceL( R_MPX_RESOLUTION_HEADING ); |
|
354 TBuf<255> resolutionField; |
|
355 resolutionField.Append(KLeftMargin); |
|
356 resolutionField.Append( *heading ); |
|
357 resolutionField.Append( KHeadingValueSeperator ); |
|
358 resolutionField.AppendNum( iController->FileDetails()->iVideoWidth ); |
|
359 resolutionField.Append( KWidthHeightSeparator ); |
|
360 resolutionField.AppendNum( iController->FileDetails()->iVideoHeight); |
|
361 |
|
362 iResolutionLabel->SetTextL(resolutionField); |
|
363 iResolutionLabel->SetAllMarginsTo(KMediaDetailsViewerItemMargin); |
|
364 iResolutionLabel->MakeVisible( ETrue ); |
|
365 rowsAdded++; |
|
366 delete heading; |
|
367 } |
|
368 |
|
369 // Duration |
|
370 if ( iController->FileDetails()->iDuration > 0 ) |
|
371 { |
|
372 iDurationLabel->SetExtent( TPoint(Rect().iTl.iX, Rect().iTl.iY + (labelHeight*rowsAdded) ) , |
|
373 TSize(labelWidth,labelHeight) ); |
|
374 HBufC* heading = iEikonEnv->AllocReadResourceL( R_MPX_DURATION_HEADING ); |
|
375 TBuf<255> durationField; |
|
376 durationField.Append(KLeftMargin); |
|
377 durationField.Append( *heading ); |
|
378 durationField.Append( KHeadingValueSeperator ); |
|
379 |
|
380 TInt64 durationInSeconds = iController->FileDetails()->iDuration / 1000; |
|
381 |
|
382 HBufC* unitFormatString; |
|
383 if ( durationInSeconds < 3600 ) // one hour |
|
384 { |
|
385 unitFormatString = StringLoader::LoadLC(R_QTN_TIME_DURAT_MIN_SEC); |
|
386 } |
|
387 else |
|
388 { |
|
389 unitFormatString = StringLoader::LoadLC(R_QTN_TIME_DURAT_LONG); |
|
390 } |
|
391 |
|
392 TBuf<64> dur; |
|
393 TTime durTime = TTime(durationInSeconds * 1000000); |
|
394 durTime.FormatL(dur, *unitFormatString); |
|
395 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dur ); |
|
396 |
|
397 durationField.Append( dur ); |
|
398 iDurationLabel->SetTextL(durationField); |
|
399 iDurationLabel->SetAllMarginsTo(KMediaDetailsViewerItemMargin); |
|
400 iDurationLabel->MakeVisible( ETrue ); |
|
401 rowsAdded++; |
|
402 delete heading; |
|
403 CleanupStack::PopAndDestroy(); // unitFormatString |
|
404 } |
|
405 |
|
406 |
|
407 // Bitrate |
|
408 if ( iController->FileDetails()->iBitRate > 0 ) |
|
409 { |
|
410 iBitrateLabel->SetExtent( TPoint(Rect().iTl.iX, Rect().iTl.iY + (labelHeight*rowsAdded) ) , |
|
411 TSize(labelWidth,labelHeight) ); |
|
412 HBufC* heading = iEikonEnv->AllocReadResourceL( R_MPX_BITRATE_HEADING ); |
|
413 TBuf<255> bitrateField; |
|
414 bitrateField.Append(KLeftMargin); |
|
415 bitrateField.Append( *heading ); |
|
416 bitrateField.Append( KHeadingValueSeperator ); |
|
417 |
|
418 HBufC* formattedBitrate = |
|
419 StringLoader::LoadLC(R_MPX_BITRATE_UNITS,iController->FileDetails()->iBitRate / 1000 ); |
|
420 |
|
421 bitrateField.Append( *formattedBitrate ); |
|
422 iBitrateLabel->SetTextL(bitrateField); |
|
423 iBitrateLabel->SetAllMarginsTo(KMediaDetailsViewerItemMargin); |
|
424 iBitrateLabel->MakeVisible( ETrue ); |
|
425 rowsAdded++; |
|
426 delete heading; |
|
427 CleanupStack::PopAndDestroy(); // formattedBitrate |
|
428 } |
|
429 |
|
430 // Title |
|
431 if ( iController->FileDetails()->iTitle ) |
|
432 { |
|
433 iTitleLabel->SetExtent( TPoint(Rect().iTl.iX, Rect().iTl.iY + (labelHeight*rowsAdded) ) , |
|
434 TSize(labelWidth,labelHeight) ); |
|
435 HBufC* heading = iEikonEnv->AllocReadResourceL( R_MPX_TITLE_HEADING ); |
|
436 TBuf<255> titleField; |
|
437 titleField.Append(KLeftMargin); |
|
438 titleField.Append( *heading ); |
|
439 titleField.Append( KHeadingValueSeperator ); |
|
440 titleField.Append( *(iController->FileDetails()->iTitle) ); |
|
441 iTitleLabel->SetTextL(titleField); |
|
442 iTitleLabel->SetAllMarginsTo(KMediaDetailsViewerItemMargin); |
|
443 iTitleLabel->MakeVisible( ETrue ); |
|
444 rowsAdded++; |
|
445 |
|
446 delete heading; |
|
447 } |
|
448 |
|
449 // Artist |
|
450 if ( iController->FileDetails()->iArtist ) |
|
451 { |
|
452 iArtistLabel->SetExtent( TPoint(Rect().iTl.iX, Rect().iTl.iY + (labelHeight*rowsAdded) ) , |
|
453 TSize(labelWidth,labelHeight) ); |
|
454 HBufC* heading = iEikonEnv->AllocReadResourceL( R_MPX_ARTIST_HEADING ); |
|
455 TBuf<255> artistField; |
|
456 artistField.Append(KLeftMargin); |
|
457 artistField.Append( *heading ); |
|
458 artistField.Append( KHeadingValueSeperator ); |
|
459 artistField.Append( *(iController->FileDetails()->iArtist) ); |
|
460 iArtistLabel->SetTextL(artistField); |
|
461 iArtistLabel->SetAllMarginsTo(KMediaDetailsViewerItemMargin); |
|
462 iArtistLabel->MakeVisible( ETrue ); |
|
463 rowsAdded++; |
|
464 |
|
465 delete heading; |
|
466 } |
|
467 |
|
468 |
|
469 // Additional Label |
|
470 if ( iAdditionalString && iAdditionalString->Length() ) |
|
471 { |
|
472 iAdditionalLabel->SetExtent( TPoint(Rect().iTl.iX, Rect().iTl.iY + (labelHeight*rowsAdded) ) , |
|
473 TSize(labelWidth,labelHeight) ); |
|
474 |
|
475 TBuf<255> titleField; |
|
476 titleField.Append(KLeftMargin); |
|
477 titleField.Append( *iAdditionalString ); |
|
478 iAdditionalLabel->SetTextL(titleField); |
|
479 iAdditionalLabel->SetAllMarginsTo(KMediaDetailsViewerItemMargin); |
|
480 iAdditionalLabel->MakeVisible( ETrue ); |
|
481 rowsAdded++; |
|
482 } |
|
483 } |
|
484 |
|
485 // ------------------------------------------------------------------------------------------------- |
|
486 // CMPXVideoPlaybackMediaDetailsViewer::CountComponentControls() |
|
487 // ------------------------------------------------------------------------------------------------- |
|
488 // |
|
489 TInt CMPXVideoPlaybackMediaDetailsViewer::CountComponentControls() const |
|
490 { |
|
491 return 9; |
|
492 } |
|
493 |
|
494 // ------------------------------------------------------------------------------------------------- |
|
495 // CMPXVideoPlaybackMediaDetailsViewer::ComponentControl |
|
496 // ------------------------------------------------------------------------------------------------- |
|
497 // |
|
498 CCoeControl* CMPXVideoPlaybackMediaDetailsViewer::ComponentControl(TInt aIndex) const |
|
499 { |
|
500 CCoeControl* control = NULL; |
|
501 |
|
502 switch ( aIndex ) |
|
503 { |
|
504 case 0: |
|
505 control = iClipnameLabel; |
|
506 break; |
|
507 case 1: |
|
508 control = iTitleLabel; |
|
509 break; |
|
510 case 2: |
|
511 control = iArtistLabel; |
|
512 break; |
|
513 case 3: |
|
514 control = iFormatLabel; |
|
515 break; |
|
516 case 4: |
|
517 control = iResolutionLabel; |
|
518 break; |
|
519 case 5: |
|
520 control = iDurationLabel; |
|
521 break; |
|
522 case 6: |
|
523 control = iBitrateLabel; |
|
524 break; |
|
525 case 7: |
|
526 control = iLicenseLabel; |
|
527 break; |
|
528 case 8: |
|
529 control = iAdditionalLabel; |
|
530 break; |
|
531 default: |
|
532 break; |
|
533 } |
|
534 |
|
535 return control; |
|
536 } |
|
537 |
|
538 // ------------------------------------------------------------------------------------------------- |
|
539 // CMPXVideoPlaybackMediaDetailsViewer::Reset |
|
540 // ------------------------------------------------------------------------------------------------- |
|
541 // |
|
542 void CMPXVideoPlaybackMediaDetailsViewer::Reset() |
|
543 { |
|
544 } |
|
545 |
|
546 // ------------------------------------------------------------------------------------------------- |
|
547 // CMPXVideoPlaybackMediaDetailsViewer::CreateLabelsL |
|
548 // ------------------------------------------------------------------------------------------------- |
|
549 // |
|
550 void CMPXVideoPlaybackMediaDetailsViewer::CreateLabelsL() |
|
551 { |
|
552 // Licence / DRM |
|
553 iLicenseLabel = new (ELeave) CEikLabel; |
|
554 iLicenseLabel->SetContainerWindowL( *this ); |
|
555 iLicenseLabel->SetTextL( KNullDesC ); |
|
556 |
|
557 // Filename |
|
558 iClipnameLabel = new (ELeave) CEikLabel; |
|
559 iClipnameLabel->SetContainerWindowL( *this ); |
|
560 iClipnameLabel->SetTextL( KNullDesC ); |
|
561 |
|
562 // Title |
|
563 iTitleLabel = new (ELeave) CEikLabel; |
|
564 iTitleLabel->SetContainerWindowL( *this ); |
|
565 iTitleLabel->SetTextL( KNullDesC ); |
|
566 |
|
567 // Artist |
|
568 iArtistLabel = new (ELeave) CEikLabel; |
|
569 iArtistLabel->SetContainerWindowL( *this ); |
|
570 iArtistLabel->SetTextL( KNullDesC ); |
|
571 |
|
572 // Format |
|
573 iFormatLabel = new (ELeave) CEikLabel; |
|
574 iFormatLabel->SetContainerWindowL( *this ); |
|
575 iFormatLabel->SetTextL( KNullDesC ); |
|
576 |
|
577 // Resolution |
|
578 iResolutionLabel = new (ELeave) CEikLabel; |
|
579 iResolutionLabel->SetContainerWindowL( *this ); |
|
580 iResolutionLabel->SetTextL( KNullDesC ); |
|
581 |
|
582 // Duration |
|
583 iDurationLabel = new (ELeave) CEikLabel; |
|
584 iDurationLabel->SetContainerWindowL( *this ); |
|
585 iDurationLabel->SetTextL( KNullDesC ); |
|
586 |
|
587 // Bitrate |
|
588 iBitrateLabel = new (ELeave) CEikLabel; |
|
589 iBitrateLabel->SetContainerWindowL( *this ); |
|
590 iBitrateLabel->SetTextL( KNullDesC ); |
|
591 |
|
592 // Additional Labels |
|
593 iAdditionalLabel = new (ELeave) CEikLabel; |
|
594 iAdditionalLabel->SetContainerWindowL( *this ); |
|
595 iAdditionalLabel->SetTextL( KNullDesC ); |
|
596 |
|
597 } |
|
598 |
|
599 // ----------------------------------------------------------------------------- |
|
600 // CMPXVideoPlaybackMediaDetailsViewer::UpdateBackgroundBitmapL |
|
601 // Update background bitmap |
|
602 // ----------------------------------------------------------------------------- |
|
603 // |
|
604 void CMPXVideoPlaybackMediaDetailsViewer::UpdateBackgroundBitmapL() const |
|
605 { |
|
606 TSize bitmapSize = Rect().Size(); |
|
607 |
|
608 CFbsBitmapDevice* bgBitmapDevice = |
|
609 CFbsBitmapDevice::NewL( iBackgroundBitmap ); |
|
610 CleanupStack::PushL( bgBitmapDevice ); |
|
611 |
|
612 CFbsBitGc* bgBitGc( NULL ); |
|
613 User::LeaveIfError( bgBitmapDevice->CreateContext( bgBitGc ) ); |
|
614 CleanupStack::PushL( bgBitGc ); |
|
615 |
|
616 bgBitGc->SetBrushColor( TRgb(0x708090) ); // slate gray |
|
617 bgBitGc->Clear(); |
|
618 |
|
619 CleanupStack::PopAndDestroy( bgBitGc ); |
|
620 CleanupStack::PopAndDestroy( bgBitmapDevice ); |
|
621 |
|
622 // Dither alpha channel for semitransparency |
|
623 // |
|
624 // Scan line length in 32-bit words |
|
625 TInt scanLineLengthWord = CFbsBitmap::ScanLineLength( bitmapSize.iWidth, EColor16MA) / 4; |
|
626 |
|
627 iBackgroundBitmap->LockHeap(); |
|
628 TUint32* dataAddr = |
|
629 reinterpret_cast<TUint32*>( iBackgroundBitmap->DataAddress() ); |
|
630 for ( TInt y = 0; y < bitmapSize.iHeight; y++ ) |
|
631 { |
|
632 for ( TInt x = 0; x < bitmapSize.iWidth; x++ ) |
|
633 { |
|
634 if ( ( y + x ) & 1 ) |
|
635 { |
|
636 // Make this pixel transparent |
|
637 dataAddr[y * scanLineLengthWord + x] = 0x00000000; |
|
638 } |
|
639 } |
|
640 } |
|
641 |
|
642 iBackgroundBitmap->UnlockHeap(); |
|
643 } |
|
644 |
|
645 // ------------------------------------------------------------------------------------------------- |
|
646 // CMPXVideoPlaybackMediaDetailsViewer::ScrollFilenameTimer |
|
647 // ------------------------------------------------------------------------------------------------- |
|
648 // |
|
649 TInt CMPXVideoPlaybackMediaDetailsViewer::ScrollFilenameTimer( TAny* aPtr ) |
|
650 { |
|
651 static_cast<CMPXVideoPlaybackMediaDetailsViewer*>(aPtr)->HandleScrollFilenameTimerL(); |
|
652 return KErrNone; |
|
653 } |
|
654 |
|
655 // ------------------------------------------------------------------------------------------------- |
|
656 // CMPXVideoPlaybackMediaDetailsViewer::HandleScrollFilenameTimerL |
|
657 // ------------------------------------------------------------------------------------------------- |
|
658 // |
|
659 void CMPXVideoPlaybackMediaDetailsViewer::HandleScrollFilenameTimerL() |
|
660 { |
|
661 if (iController->FileDetails()->iClipName) |
|
662 { |
|
663 if ( iShouldPauseScrolling ) |
|
664 { |
|
665 iShouldPauseScrolling = EFalse; |
|
666 User::After( 2000000 ); // add a 2 second delay after each complete scrolling |
|
667 } |
|
668 |
|
669 TInt length = iController->FileDetails()->iClipName->Length(); |
|
670 |
|
671 HBufC* heading = iEikonEnv->AllocReadResourceL( R_MPX_FILENAME_HEADING ); |
|
672 TBuf<255> filenameField; |
|
673 filenameField.Append(KLeftMargin); |
|
674 filenameField.Append( *heading ); |
|
675 filenameField.Append( KHeadingValueSeperator ); |
|
676 |
|
677 if ( length >= KMediaDetailsViewerVisibleCharacters ) |
|
678 { |
|
679 filenameField.Append( |
|
680 iController->FileDetails()->iClipName->Mid(iScrollPosition, |
|
681 KMediaDetailsViewerVisibleCharacters) ); |
|
682 |
|
683 if ( iScrollPosition == (length - KMediaDetailsViewerVisibleCharacters) ) |
|
684 { |
|
685 iScrollPosition = 0; |
|
686 iShouldPauseScrolling = ETrue; |
|
687 } |
|
688 else |
|
689 { |
|
690 iScrollPosition++; |
|
691 } |
|
692 } |
|
693 else |
|
694 { |
|
695 filenameField.Append( *(iController->FileDetails()->iClipName) ); |
|
696 iScrollingTextTimer->Cancel(); // no need to keep the timer active |
|
697 } |
|
698 |
|
699 iClipnameLabel->SetTextL(filenameField); |
|
700 DrawNow(); |
|
701 |
|
702 delete heading; |
|
703 |
|
704 } |
|
705 } |
|
706 |
|
707 |
|
708 // ------------------------------------------------------------------------------------------------- |
|
709 // CMPXVideoPlaybackMediaDetailsViewer::NumOfItemsShownInViewer |
|
710 // ------------------------------------------------------------------------------------------------- |
|
711 // |
|
712 TInt CMPXVideoPlaybackMediaDetailsViewer::NumOfItemsShownInViewer() |
|
713 { |
|
714 TInt numOfItems = 0; |
|
715 |
|
716 if ( iController->FileDetails()->iDrmProtected ) |
|
717 { |
|
718 numOfItems++; |
|
719 } |
|
720 |
|
721 if ( iController->FileDetails()->iClipName ) |
|
722 { |
|
723 numOfItems++; |
|
724 } |
|
725 |
|
726 if ( iController->FileDetails()->iMimeType ) |
|
727 { |
|
728 numOfItems++; |
|
729 } |
|
730 |
|
731 if ( iController->FileDetails()->iVideoHeight && |
|
732 iController->FileDetails()->iVideoWidth ) |
|
733 { |
|
734 numOfItems++; |
|
735 } |
|
736 |
|
737 if ( iController->FileDetails()->iDuration > 0 ) |
|
738 { |
|
739 numOfItems++; |
|
740 } |
|
741 |
|
742 if ( iController->FileDetails()->iBitRate > 0 ) |
|
743 { |
|
744 numOfItems++; |
|
745 } |
|
746 |
|
747 if ( iController->FileDetails()->iTitle ) |
|
748 { |
|
749 numOfItems++; |
|
750 } |
|
751 |
|
752 if ( iController->FileDetails()->iArtist ) |
|
753 { |
|
754 numOfItems++; |
|
755 } |
|
756 |
|
757 // Additional File Details |
|
758 CMPXFileDetailsPlugin* addPlugin( NULL ); |
|
759 |
|
760 // Use the interface to load the ecom plugin |
|
761 TRAPD ( err, addPlugin = CMPXFileDetailsPlugin::NewL( KFileDetailsCntlPluginUid ) ); |
|
762 |
|
763 // If plugin loaded successfully |
|
764 if (!err ) |
|
765 { |
|
766 TPtrC addLabel; |
|
767 addLabel.Set( addPlugin->GetAdditionalLabelLC( iController->FileDetails()->iFourCCCode ) ); |
|
768 iAdditionalString = addLabel.AllocL(); |
|
769 |
|
770 if ( iAdditionalString->Length() ) |
|
771 { |
|
772 numOfItems++; |
|
773 } |
|
774 |
|
775 CleanupStack::PopAndDestroy(); // addLabel |
|
776 } |
|
777 |
|
778 delete addPlugin; |
|
779 |
|
780 return numOfItems; |
|
781 } |
|
782 |
|
783 // ------------------------------------------------------------------------------------------------- |
|
784 // CMPXVideoPlaybackMediaDetailsViewer::CalculateViewerRect |
|
785 // ------------------------------------------------------------------------------------------------- |
|
786 // |
|
787 TRect CMPXVideoPlaybackMediaDetailsViewer::CalculateViewerRect() |
|
788 { |
|
789 TInt numOfItems = NumOfItemsShownInViewer(); |
|
790 TRect viewerRect; |
|
791 |
|
792 // optimize viewer's width for the clipname |
|
793 TInt horizontalOffset = 0; |
|
794 TInt filenameLength = iController->FileDetails()->iClipName->Des().Length(); |
|
795 |
|
796 if ( filenameLength <= KMediaDetailsViewerFilenameMedium ) |
|
797 { |
|
798 horizontalOffset = |
|
799 iController->iContainer->Rect().iBr.iX / KMediaDetailsViewerOffsetDivisorMedium; |
|
800 } |
|
801 else |
|
802 { |
|
803 horizontalOffset = |
|
804 iController->iContainer->Rect().iBr.iX / KMediaDetailsViewerOffsetDivisorMax; |
|
805 } |
|
806 |
|
807 TInt eachItemHeight = |
|
808 iController->iContainer->Rect().iBr.iY / KMediaDetailsViewerMaxItems; |
|
809 |
|
810 TInt verticalHalf = iController->iContainer->Rect().iBr.iY / 2; |
|
811 |
|
812 TInt tLX = (iController->iContainer->Rect().iTl.iX) + horizontalOffset; |
|
813 TInt bRX = (iController->iContainer->Rect().iBr.iX) - horizontalOffset; |
|
814 |
|
815 TInt tLY = verticalHalf - ( eachItemHeight * numOfItems/2 ); |
|
816 |
|
817 // pad for the margins on top and bottom of viewer |
|
818 TInt bRY = verticalHalf + ( eachItemHeight * numOfItems/2 ) + (KMediaDetailsViewerItemMargin * 2); |
|
819 |
|
820 viewerRect = TRect( tLX, tLY, bRX, bRY ); |
|
821 |
|
822 return viewerRect; |
|
823 } |
|
824 |
|
825 // ------------------------------------------------------------------------------------------------- |
|
826 // CMPXVideoPlaybackMediaDetailsViewer::ViewerRect |
|
827 // ------------------------------------------------------------------------------------------------- |
|
828 // |
|
829 TRect CMPXVideoPlaybackMediaDetailsViewer::ViewerRect() |
|
830 { |
|
831 return iViewerRect; |
|
832 } |
|
833 |
|
834 |
|
835 |
|
836 // End of File |