|
1 /* |
|
2 * Copyright (c) 2006 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: This class manages progress download |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <f32plugin.h> |
|
21 #include <AudioPreference.h> |
|
22 #include <badesca.h> |
|
23 #include <apgcli.h> |
|
24 #include <mmf/common/mmfcontrollerframeworkbase.h> |
|
25 #include <mmf/common/mmfmeta.h> |
|
26 #include <mpxcommandgeneraldefs.h> |
|
27 #include <mpxmedia.h> |
|
28 #include <mpxplaybackpluginobserver.h> |
|
29 #include <mpxmediaaudiodefs.h> |
|
30 #include <mpxmediamusicdefs.h> |
|
31 #include <mpxmediageneraldefs.h> |
|
32 #include <mpxmediadrmdefs.h> |
|
33 #include <mpxcmn.h> |
|
34 #include <mpxdrmmediautility.h> |
|
35 #include <mpxprivatecrkeys.h> |
|
36 #include <mpxcenrepwatcher.h> |
|
37 #include <mpxlog.h> |
|
38 |
|
39 #include "mpxprogressdownload.h" |
|
40 |
|
41 |
|
42 // CONSTANTS |
|
43 const TUid KProgressDownloadUid={0x101FFC09}; |
|
44 const TInt KProgressPlayEndThreshold=8000000; // 8 seconds, in milliseconds |
|
45 |
|
46 _LIT(KMMFMetaEntryAuthor, "author"); // For WMA progressive download |
|
47 |
|
48 // ============================ LOCAL FUNCTIONS ============================== |
|
49 LOCAL_C TInt Balance(TInt aMMFBalance) |
|
50 { |
|
51 return (aMMFBalance-KMMFBalanceCenter) * |
|
52 (EPbBalanceMaxRight-EPbBalanceMaxLeft) / |
|
53 (KMMFBalanceMaxRight-KMMFBalanceMaxLeft); |
|
54 } |
|
55 |
|
56 LOCAL_C TInt MMFBalance(TInt aBalance) |
|
57 { |
|
58 return KMMFBalanceCenter+(KMMFBalanceMaxRight-KMMFBalanceMaxLeft)/ |
|
59 (EPbBalanceMaxRight-EPbBalanceMaxLeft)*aBalance; |
|
60 } |
|
61 |
|
62 |
|
63 // ============================ MEMBER FUNCTIONS ============================== |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // Two-phased constructor. |
|
67 // ---------------------------------------------------------------------------- |
|
68 // |
|
69 CMPXProgressDownload* CMPXProgressDownload::NewL(TAny* /*aInitParams*/) |
|
70 { |
|
71 CMPXProgressDownload* p=new(ELeave)CMPXProgressDownload(); |
|
72 CleanupStack::PushL(p); |
|
73 p->ConstructL(); |
|
74 CleanupStack::Pop(p); |
|
75 return p; |
|
76 } |
|
77 |
|
78 // ---------------------------------------------------------------------------- |
|
79 // Symbian 2nd phase constructor can leave. |
|
80 // ---------------------------------------------------------------------------- |
|
81 // |
|
82 void CMPXProgressDownload::ConstructL() |
|
83 { |
|
84 iVolumeWatcher = CMPXCenRepWatcher::NewL(KCRUidMPXSettings, |
|
85 KMPXPlaybackVolume, |
|
86 this); |
|
87 iMuteWatcher = CMPXCenRepWatcher::NewL(KCRUidMPXSettings, |
|
88 KMPXPlaybackMute, |
|
89 this); |
|
90 iFeatureFlag = EPbFeatureBalance | EPbFeatureVolumeRamp; |
|
91 iDrmMediaUtility = CMPXDrmMediaUtility::NewL(); |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // C++ constructor |
|
96 // ---------------------------------------------------------------------------- |
|
97 // |
|
98 CMPXProgressDownload::CMPXProgressDownload() |
|
99 {} |
|
100 |
|
101 // ---------------------------------------------------------------------------- |
|
102 // Destructor |
|
103 // ---------------------------------------------------------------------------- |
|
104 // |
|
105 CMPXProgressDownload::~CMPXProgressDownload() |
|
106 { |
|
107 delete iMuteWatcher; |
|
108 delete iVolumeWatcher; |
|
109 if ( iDrmMediaUtility ) |
|
110 { |
|
111 if ( EPbDlStateDownloadCompleted == iDownloadState ) |
|
112 { |
|
113 TRAP_IGNORE( ConsumeRightsL( ContentAccess::EStop ) ); |
|
114 } |
|
115 delete iDrmMediaUtility; |
|
116 } |
|
117 if (iPdPlayer) |
|
118 { |
|
119 iPdPlayer->Close(); |
|
120 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPActive,EFalse,KErrNone); |
|
121 delete iPdPlayer; |
|
122 } |
|
123 delete iPdUtil; |
|
124 delete iPdPath; |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // Initializes a song for playback |
|
129 // ---------------------------------------------------------------------------- |
|
130 // |
|
131 void CMPXProgressDownload::InitialiseL(const TDesC& aSong) |
|
132 { |
|
133 MPX_DEBUG2("CMPXProgressDownload::InitialiseL(%S) entering", &aSong ); |
|
134 |
|
135 // Re-initialize ProgressiveDownloadUtility to make sure multiple sequential |
|
136 // downloads work |
|
137 delete iPdPlayer; |
|
138 iPdPlayer = NULL; |
|
139 delete iPdUtil; |
|
140 iPdUtil = NULL; |
|
141 iPdUtil = CProgressiveDownloadUtility::NewL(); |
|
142 |
|
143 iPdPlayer = iPdUtil->OpenL( aSong, *this ); |
|
144 delete iPdPath; |
|
145 iPdPath = NULL; |
|
146 iPdPath = aSong.AllocL(); |
|
147 iDownloadState = EPbDlStateBuffering; |
|
148 iState = EStateInitialising; |
|
149 iConsumeStarted = EFalse; |
|
150 |
|
151 MPX_DEBUG1("CMPXProgressDownload::InitialiseL() exiting"); |
|
152 } |
|
153 |
|
154 // ---------------------------------------------------------------------------- |
|
155 // Initializes a song for playback |
|
156 // ---------------------------------------------------------------------------- |
|
157 // |
|
158 void CMPXProgressDownload::InitialiseL(RFile& aSong) |
|
159 { |
|
160 MPX_DEBUG1("CMPXProgressDownload::InitialiseL(RFile) entering"); |
|
161 |
|
162 // Re-initialize ProgressiveDownloadUtility to make sure multiple sequential |
|
163 // downloads work |
|
164 delete iPdPlayer; |
|
165 iPdPlayer = NULL; |
|
166 delete iPdUtil; |
|
167 iPdUtil = NULL; |
|
168 iPdUtil = CProgressiveDownloadUtility::NewL(); |
|
169 |
|
170 iPdPlayer = iPdUtil->OpenL( aSong, *this ); |
|
171 delete iPdPath; |
|
172 iPdPath = NULL; |
|
173 TFileName filename; |
|
174 aSong.FullName(filename); |
|
175 iPdPath = filename.AllocL(); |
|
176 iDownloadState = EPbDlStateBuffering; |
|
177 iState = EStateInitialising; |
|
178 iConsumeStarted = EFalse; |
|
179 |
|
180 MPX_DEBUG1("CMPXProgressDownload::InitialiseL() exiting"); |
|
181 } |
|
182 |
|
183 // ---------------------------------------------------------------------------- |
|
184 // Executes a command on the selected song |
|
185 // ---------------------------------------------------------------------------- |
|
186 // |
|
187 void CMPXProgressDownload::CommandL(TMPXPlaybackCommand aCmd, TInt /*aData*/) |
|
188 { |
|
189 MPX_DEBUG2("CMPXProgressDownload::CommandL(%d) entering", aCmd); |
|
190 |
|
191 if (iPdPlayer) |
|
192 { |
|
193 switch(aCmd) |
|
194 { |
|
195 case EPbCmdPlay: |
|
196 { |
|
197 if ( EPbDlStateDownloadCompleted == iDownloadState ) |
|
198 { |
|
199 if (iConsumeStarted) |
|
200 { |
|
201 ConsumeRightsL( ContentAccess::EContinue ); |
|
202 } |
|
203 else |
|
204 { |
|
205 MPX_TRAPD( AEErr, ConsumeRightsL( ContentAccess::EPlay ) ); |
|
206 if (AEErr == KErrDiskFull) |
|
207 { |
|
208 iDrmMediaUtility->Close(); |
|
209 iPdPlayer->Close(); |
|
210 iState = EStateNotInitialised; |
|
211 iDownloadState = EPbDlStateNotDownloading; |
|
212 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPClosed, |
|
213 0, KErrDiskFull); |
|
214 break; |
|
215 } |
|
216 iConsumeStarted = ETrue; |
|
217 } |
|
218 } |
|
219 iPdPlayer->Play(); |
|
220 iState = EStateInitialised; |
|
221 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPPlaying, |
|
222 0, KErrNone); |
|
223 break; |
|
224 } |
|
225 case EPbCmdPause: |
|
226 if ( EPbDlStateDownloadCompleted == iDownloadState && iConsumeStarted ) |
|
227 { |
|
228 ConsumeRightsL( ContentAccess::EPause ); |
|
229 } |
|
230 iPdPlayer->Pause(); |
|
231 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPPaused, |
|
232 0, KErrNone); |
|
233 break; |
|
234 case EPbCmdStop: |
|
235 if ( EPbDlStateDownloadCompleted == iDownloadState && iConsumeStarted ) |
|
236 { |
|
237 ConsumeRightsL( ContentAccess::EStop ); |
|
238 iConsumeStarted = EFalse; |
|
239 } |
|
240 iDrmMediaUtility->Close(); |
|
241 iPdPlayer->Stop(); |
|
242 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPStopped, |
|
243 0, KErrNone); |
|
244 break; |
|
245 case EPbCmdClose: |
|
246 if ( EPbDlStateDownloadCompleted == iDownloadState && iConsumeStarted ) |
|
247 { |
|
248 ConsumeRightsL( ContentAccess::EStop ); |
|
249 iConsumeStarted = EFalse; |
|
250 } |
|
251 iDrmMediaUtility->Close(); |
|
252 iPdPlayer->Close(); |
|
253 iState = EStateNotInitialised; |
|
254 iDownloadState = EPbDlStateNotDownloading; |
|
255 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPClosed, |
|
256 0, KErrNone); |
|
257 break; |
|
258 } |
|
259 } |
|
260 |
|
261 MPX_DEBUG1("CMPXProgressDownload::CommandL() exiting"); |
|
262 } |
|
263 |
|
264 // ---------------------------------------------------------------------------- |
|
265 // Executes a command |
|
266 // ---------------------------------------------------------------------------- |
|
267 // |
|
268 void CMPXProgressDownload::CommandL( CMPXCommand& aCmd ) |
|
269 { |
|
270 MPX_FUNC("CMPXProgressDownload::CommandL(CMPXCommand)"); |
|
271 |
|
272 ASSERT( aCmd.IsSupported( KMPXCommandGeneralId )); |
|
273 TInt id( aCmd.ValueTObjectL<TInt>( KMPXCommandGeneralId )); |
|
274 if ( KMPXCommandIdPlaybackPD == id ) |
|
275 { |
|
276 ASSERT(aCmd.IsSupported(KMPXCommandPlaybackGeneralType)); |
|
277 TMPXPlaybackPdCommand cmd( |
|
278 static_cast<TMPXPlaybackPdCommand>( |
|
279 aCmd.ValueTObjectL<TInt>(KMPXCommandPlaybackGeneralType))); |
|
280 switch ( cmd ) |
|
281 { |
|
282 case ( EPbCmdStartPd ): |
|
283 { |
|
284 ASSERT( aCmd.IsSupported( KMPXCommandPlaybackPDTransactionID )); |
|
285 iTransactionId = aCmd.ValueTObjectL<TUint>( KMPXCommandPlaybackPDTransactionID ); |
|
286 break; |
|
287 } |
|
288 case ( EPbCmdFinishPd ): |
|
289 { |
|
290 iObs->HandlePluginEvent( |
|
291 MMPXPlaybackPluginObserver::EPPlayComplete, |
|
292 0, |
|
293 KErrNone); |
|
294 break; |
|
295 } |
|
296 case ( EPbCmdHandlePdEvent ): |
|
297 { |
|
298 ASSERT( aCmd.IsSupported( KMPXCommandPlaybackPDTransactionID ) && |
|
299 aCmd.IsSupported( KMPXCommandPlaybackPDEvent ) && |
|
300 aCmd.IsSupported( KMPXCommandPlaybackGeneralData )); |
|
301 TUint transId( aCmd.ValueTObjectL<TUint>( KMPXCommandPlaybackPDTransactionID )); |
|
302 TBrCtlDownloadEvent event( |
|
303 aCmd.ValueTObjectL<TBrCtlDownloadEvent>( KMPXCommandPlaybackPDEvent )); |
|
304 TUint val( aCmd.ValueTObjectL<TUint>( KMPXCommandPlaybackGeneralData )); |
|
305 HandleDownloadEventL( transId, event, val ); |
|
306 break; |
|
307 } |
|
308 case ( EPbCmdGetPdStatus ): |
|
309 { |
|
310 aCmd.SetTObjectValueL<TUint>( |
|
311 KMPXCommandPlaybackPDTransactionID, |
|
312 iTransactionId ); |
|
313 aCmd.SetTObjectValueL<TMPXPlaybackPdDownloadState>( |
|
314 KMPXCommandPlaybackPDState, |
|
315 static_cast<TMPXPlaybackPdDownloadState>(iDownloadState)); |
|
316 aCmd.SetTObjectValueL<TInt>( |
|
317 KMPXCommandPlaybackPDDownloadedBytes, |
|
318 iDownloadBytes ); |
|
319 aCmd.SetTObjectValueL<TInt>( |
|
320 KMPXCommandPlaybackPDTotalBytes, |
|
321 iDownloadSize ); |
|
322 break; |
|
323 } |
|
324 case ( EPbCmdPausePd ): |
|
325 { |
|
326 iObs->HandlePluginEvent( |
|
327 MMPXPlaybackPluginObserver::EPDownloadCmdPauseDownload, |
|
328 iTransactionId, |
|
329 KErrNone ); |
|
330 break; |
|
331 } |
|
332 case ( EPbCmdResumePd ): |
|
333 { |
|
334 iObs->HandlePluginEvent( |
|
335 MMPXPlaybackPluginObserver::EPDownloadCmdResumeDownload, |
|
336 iTransactionId, |
|
337 KErrNone ); |
|
338 break; |
|
339 } |
|
340 case ( EPbCmdCancelPd ): |
|
341 { |
|
342 iObs->HandlePluginEvent( |
|
343 MMPXPlaybackPluginObserver::EPDownloadCmdCancelDownload, |
|
344 iTransactionId, |
|
345 KErrNone); |
|
346 break; |
|
347 } |
|
348 default: |
|
349 break; |
|
350 } |
|
351 } |
|
352 } |
|
353 |
|
354 // ---------------------------------------------------------------------------- |
|
355 // Sets a property of the plugin |
|
356 // ---------------------------------------------------------------------------- |
|
357 // |
|
358 void CMPXProgressDownload::SetL(TMPXPlaybackProperty aProperty, TInt aValue) |
|
359 { |
|
360 MPX_DEBUG3("CMPXProgressDownload::SetL(%d, %d) entering", aProperty, aValue); |
|
361 |
|
362 TBool isSupported=ETrue; |
|
363 switch(aProperty) |
|
364 { |
|
365 case EPbPropertyVolume: |
|
366 { |
|
367 SetVolume( aValue ); |
|
368 break; |
|
369 } |
|
370 case EPbPropertyVolumeRamp: |
|
371 iPdPlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(TInt64(aValue))); |
|
372 break; |
|
373 case EPbPropertyMute: |
|
374 SetMute( aValue ); |
|
375 break; |
|
376 case EPbPropertyBalance: |
|
377 iPdPlayer->SetBalance(MMFBalance(aValue)); |
|
378 break; |
|
379 case EPbPropertyPosition: |
|
380 { |
|
381 TInt64 pos(aValue); |
|
382 pos *= KPbMilliMultiplier; |
|
383 iPdPlayer->SetPosition(pos); |
|
384 } |
|
385 break; |
|
386 default: |
|
387 isSupported=EFalse; |
|
388 } |
|
389 |
|
390 if (!isSupported) |
|
391 { |
|
392 User::Leave(KErrNotSupported); |
|
393 } |
|
394 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPSetComplete, |
|
395 aProperty, KErrNone); |
|
396 |
|
397 MPX_DEBUG1("CMPXProgressDownload::SetL() exiting"); |
|
398 } |
|
399 |
|
400 // ---------------------------------------------------------------------------- |
|
401 // Gets a property of the plugin (async) |
|
402 // ---------------------------------------------------------------------------- |
|
403 // |
|
404 void CMPXProgressDownload::PropertyL(TMPXPlaybackProperty aProperty) const |
|
405 { |
|
406 MPX_DEBUG2("CMPXProgressDownload::ValueL(%d) entering", aProperty); |
|
407 |
|
408 TBool isSupported=ETrue; |
|
409 TInt value=KErrNotFound; |
|
410 TInt err(KErrNone); |
|
411 switch(aProperty) |
|
412 { |
|
413 case EPbPropertyVolume: |
|
414 { |
|
415 value = iVolumeWatcher->CurrentValueL(); |
|
416 break; |
|
417 } |
|
418 case EPbPropertyMaxVolume: |
|
419 value=iPdPlayer->MaxVolume(); |
|
420 break; |
|
421 case EPbPropertyMute: |
|
422 value = iMuteWatcher->CurrentValueL(); |
|
423 break; |
|
424 case EPbPropertyBalance: |
|
425 err = iPdPlayer->GetBalance(value); |
|
426 value=Balance(value); |
|
427 break; |
|
428 case EPbPropertyDuration: |
|
429 { |
|
430 TTimeIntervalMicroSeconds duration = iPdPlayer->Duration(); |
|
431 value = duration.Int64() / KPbMilliMultiplier; |
|
432 } |
|
433 break; |
|
434 case EPbPropertyPosition: |
|
435 { |
|
436 TTimeIntervalMicroSeconds pos; |
|
437 iPdPlayer->GetPosition(pos); |
|
438 value = pos.Int64() / KPbMilliMultiplier; |
|
439 } |
|
440 break; |
|
441 case EPbPropertySupportedFeatures: |
|
442 value = iFeatureFlag; |
|
443 break; |
|
444 default: |
|
445 isSupported=EFalse; |
|
446 } |
|
447 if (!isSupported) |
|
448 { |
|
449 User::Leave(KErrNotSupported); |
|
450 } |
|
451 iObs->HandleProperty(aProperty,value,err); |
|
452 |
|
453 MPX_DEBUG1("CMPXProgressDownload::ValueL() exiting"); |
|
454 } |
|
455 |
|
456 // ---------------------------------------------------------------------------- |
|
457 // Gets a list of sub players, UPnP only |
|
458 // ---------------------------------------------------------------------------- |
|
459 // |
|
460 void CMPXProgressDownload::SubPlayerNamesL() |
|
461 { |
|
462 iObs->HandleSubPlayerNames(KProgressDownloadUid, NULL, ETrue, KErrNone); |
|
463 } |
|
464 |
|
465 // ---------------------------------------------------------------------------- |
|
466 // Select a sub player |
|
467 // ---------------------------------------------------------------------------- |
|
468 // |
|
469 void CMPXProgressDownload::SelectSubPlayerL(TInt /*aIndex*/) |
|
470 { |
|
471 User::Leave(KErrNotSupported); |
|
472 } |
|
473 |
|
474 // ---------------------------------------------------------------------------- |
|
475 // Returns current sub player name |
|
476 // ---------------------------------------------------------------------------- |
|
477 // |
|
478 const TDesC& CMPXProgressDownload::SubPlayerName() |
|
479 { |
|
480 return KNullDesC; //No subplayer name for local playback |
|
481 } |
|
482 |
|
483 // ---------------------------------------------------------------------------- |
|
484 // Current sub player index |
|
485 // ---------------------------------------------------------------------------- |
|
486 // |
|
487 TInt CMPXProgressDownload::SubPlayerIndex() const |
|
488 { |
|
489 return KErrNotFound; |
|
490 } |
|
491 |
|
492 // ---------------------------------------------------------------------------- |
|
493 // Gets media properties |
|
494 // ---------------------------------------------------------------------------- |
|
495 // |
|
496 void CMPXProgressDownload::MediaL(const TArray<TMPXAttribute>& aAttrs) |
|
497 { |
|
498 MPX_DEBUG1("CMPXProgressDownload::MediaL() entering"); |
|
499 |
|
500 RArray<TInt> suppIds; |
|
501 CleanupClosePushL(suppIds); |
|
502 suppIds.AppendL(KMPXMediaIdMusic); |
|
503 suppIds.AppendL(KMPXMediaIdGeneral); |
|
504 suppIds.AppendL(KMPXMediaIdAudio); |
|
505 CMPXMedia* media=CMPXMedia::NewL(suppIds.Array()); |
|
506 CleanupStack::PopAndDestroy(&suppIds); |
|
507 CleanupStack::PushL(media); |
|
508 |
|
509 TUint attrG(0); // General attributes |
|
510 TUint attrA(0); // Audio attributes |
|
511 TUint attrM(0); // Music attributes |
|
512 TUint attrD(0); // DRM attributes |
|
513 |
|
514 for (TInt i=aAttrs.Count(); --i>=0;) |
|
515 { |
|
516 TMPXAttribute attr(aAttrs[i]); |
|
517 if (attr.ContentId() == KMPXMediaIdGeneral) |
|
518 { |
|
519 attrG |= attr.AttributeId(); |
|
520 } |
|
521 else if (attr.ContentId() == KMPXMediaIdMusic) |
|
522 { |
|
523 attrM |= attr.AttributeId(); |
|
524 } |
|
525 else if (attr.ContentId() == KMPXMediaIdAudio) |
|
526 { |
|
527 attrA |= attr.AttributeId(); |
|
528 } |
|
529 else if ( attr.ContentId() == KMPXMediaIdDrm ) |
|
530 { |
|
531 attrD |= attr.AttributeId(); |
|
532 } |
|
533 } |
|
534 |
|
535 // Get number of metadata |
|
536 TInt metaCount = 0; |
|
537 |
|
538 // Get metadata from MMF |
|
539 TInt error = iPdPlayer->GetNumberOfMetaDataEntries(metaCount); |
|
540 MPX_DEBUG3("CMPXProgressDownload::MediaL(): metaCount = %d, error = %d", metaCount, error); |
|
541 CMMFMetaDataEntry* metaData = NULL; |
|
542 |
|
543 if (!error) |
|
544 { |
|
545 if ( metaCount > 0 ) |
|
546 { |
|
547 for (TInt i = 0; i < metaCount; ++i) |
|
548 { |
|
549 metaData = iPdPlayer->GetMetaDataEntryL(i); |
|
550 CleanupStack::PushL(metaData); |
|
551 |
|
552 if (metaData->Name().CompareF(KMMFMetaEntrySongTitle()) == 0 && |
|
553 attrG & EMPXMediaGeneralTitle) |
|
554 { // TODO to check request |
|
555 if ( metaData->Value().Length() > 0 ) |
|
556 { |
|
557 media->SetTextValueL( |
|
558 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralTitle), |
|
559 metaData->Value()); |
|
560 } |
|
561 else if ( iPdPath ) |
|
562 { |
|
563 TParsePtrC ptr( *iPdPath ); |
|
564 media->SetTextValueL( |
|
565 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralTitle), |
|
566 ptr.Name() ); |
|
567 } |
|
568 else |
|
569 { |
|
570 media->SetTextValueL( |
|
571 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralTitle), |
|
572 KNullDesC ); |
|
573 } |
|
574 } |
|
575 else if( ( metaData->Name().CompareF( KMMFMetaEntryArtist() ) == 0 || |
|
576 metaData->Name().CompareF( KMMFMetaEntryAuthor() ) == 0 ) && |
|
577 attrM & EMPXMediaMusicArtist) |
|
578 { |
|
579 media->SetTextValueL( |
|
580 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicArtist), |
|
581 metaData->Value()); |
|
582 } |
|
583 else if (metaData->Name().CompareF(KMMFMetaEntryAlbum()) == 0 && |
|
584 attrM & EMPXMediaMusicAlbum) |
|
585 { |
|
586 media->SetTextValueL( |
|
587 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicAlbum), |
|
588 metaData->Value()); |
|
589 } |
|
590 else if (metaData->Name().CompareF(KMMFMetaEntryYear()) == 0 && |
|
591 attrM & EMPXMediaMusicYear) |
|
592 { |
|
593 TInt year; |
|
594 TLex lex( metaData->Value() ); |
|
595 lex.Val( year ); |
|
596 |
|
597 TDateTime dt; |
|
598 dt.SetYear( year ); |
|
599 TTime time( dt ); |
|
600 |
|
601 media->SetTObjectValueL( |
|
602 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicYear), |
|
603 time.Int64()); |
|
604 } |
|
605 else if (metaData->Name().CompareF(KMMFMetaEntryComment()) == 0 && |
|
606 attrG & EMPXMediaGeneralComment) |
|
607 { |
|
608 media->SetTextValueL( |
|
609 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralComment), |
|
610 metaData->Value()); |
|
611 } |
|
612 else if (metaData->Name().CompareF(KMMFMetaEntryComposer()) == 0 && |
|
613 attrM & EMPXMediaMusicComposer) |
|
614 { |
|
615 media->SetTextValueL( |
|
616 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicComposer), |
|
617 metaData->Value()); |
|
618 } |
|
619 else if (metaData->Name().CompareF(KMMFMetaEntryAlbumTrack()) == 0 && |
|
620 attrM & EMPXMediaMusicAlbumTrack) |
|
621 { |
|
622 media->SetTextValueL( |
|
623 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicAlbumTrack), |
|
624 metaData->Value()); |
|
625 } |
|
626 else if (metaData->Name().CompareF(KMMFMetaEntryGenre()) == 0 && |
|
627 attrM & EMPXMediaMusicGenre) |
|
628 { |
|
629 media->SetTextValueL( |
|
630 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicGenre), |
|
631 metaData->Value()); |
|
632 } |
|
633 //else if (metaData->Name().CompareF(KMMFMetaEntryWOAF()) == 0 && |
|
634 // attrM & EMPXMediaMusicGenre) |
|
635 // { |
|
636 //media->SetTextValueL( |
|
637 // TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicGenre), |
|
638 // metaData->Value()); |
|
639 //} |
|
640 else if (metaData->Name().CompareF(KMMFMetaEntryAPIC()) == 0 && |
|
641 attrM & EMPXMediaMusicAlbumArtFileName) |
|
642 { |
|
643 // TODO check collection if user defined album art available |
|
644 media->SetTextValueL( |
|
645 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicAlbumArtFileName), |
|
646 *iPdPath); |
|
647 } |
|
648 CleanupStack::PopAndDestroy(metaData); |
|
649 metaData = NULL; |
|
650 } |
|
651 } |
|
652 else // metaCount == 0 |
|
653 { |
|
654 // no metadata available, use file path for a couple of the attributes |
|
655 if ( attrG & EMPXMediaGeneralTitle ) |
|
656 { // TODO to check request |
|
657 MPX_DEBUG2( "CMPXProgressDownload::MediaL() iPdPath = 0x%x", iPdPath ); |
|
658 if ( iPdPath ) |
|
659 { |
|
660 TParsePtrC ptr( *iPdPath ); |
|
661 media->SetTextValueL( |
|
662 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralTitle), |
|
663 ptr.Name() ); |
|
664 } |
|
665 else |
|
666 { |
|
667 media->SetTextValueL( |
|
668 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralTitle), |
|
669 KNullDesC ); |
|
670 } |
|
671 } |
|
672 if ( ( attrM & EMPXMediaMusicAlbumArtFileName ) && iPdPath ) |
|
673 { |
|
674 // TODO check collection if user defined album art available |
|
675 media->SetTextValueL( |
|
676 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicAlbumArtFileName), |
|
677 *iPdPath); |
|
678 } |
|
679 } |
|
680 } |
|
681 else // if error, then use the file path to display (for the Active Idle case) |
|
682 { |
|
683 if ( attrG & EMPXMediaGeneralTitle ) |
|
684 { |
|
685 MPX_DEBUG2( "**** CMPXProgressDownload::MediaL() iPdPath = 0x%x", iPdPath ); |
|
686 if ( iPdPath ) |
|
687 { |
|
688 TParsePtrC ptr( *iPdPath ); |
|
689 media->SetTextValueL( |
|
690 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralTitle), |
|
691 ptr.Name() ); |
|
692 } |
|
693 else |
|
694 { |
|
695 media->SetTextValueL( |
|
696 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralTitle), |
|
697 KNullDesC ); |
|
698 } |
|
699 } |
|
700 } |
|
701 |
|
702 |
|
703 if (attrG & EMPXMediaGeneralUri) |
|
704 { |
|
705 media->SetTextValueL( |
|
706 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralUri), |
|
707 *iPdPath); |
|
708 } |
|
709 |
|
710 if (attrG & EMPXMediaGeneralDuration) |
|
711 { |
|
712 TTimeIntervalMicroSeconds duration = iPdPlayer->Duration(); |
|
713 media->SetTObjectValueL<TInt>( |
|
714 TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralDuration), |
|
715 duration.Int64() / KPbMilliMultiplier); |
|
716 } |
|
717 |
|
718 // Set bitrate |
|
719 TPckgBuf<TMMFAudioConfig> data; |
|
720 |
|
721 const TMMFMessageDestinationPckg |
|
722 destinationPckg(KUidInterfaceMMFAudioController); |
|
723 |
|
724 if (attrA & EMPXMediaAudioBitrate) |
|
725 { |
|
726 error = iPdPlayer->CustomCommandSync(destinationPckg, |
|
727 EMMFAudioControllerGetSourceBitRate, KNullDesC8, KNullDesC8, data); |
|
728 if (!error) |
|
729 { |
|
730 media->SetTObjectValueL<TInt>( |
|
731 TMPXAttribute(KMPXMediaIdAudio, EMPXMediaAudioBitrate), |
|
732 data().iSampleRate); |
|
733 } |
|
734 } |
|
735 |
|
736 if (attrA & EMPXMediaAudioSamplerate) |
|
737 { |
|
738 |
|
739 // Set sampling rate |
|
740 error = iPdPlayer->CustomCommandSync(destinationPckg, |
|
741 EMMFAudioControllerGetSourceSampleRate, KNullDesC8, KNullDesC8, data); |
|
742 if (!error) |
|
743 { |
|
744 media->SetTObjectValueL<TInt>( |
|
745 KMPXMediaAudioSamplerate, |
|
746 data().iSampleRate); |
|
747 } |
|
748 } |
|
749 |
|
750 if (attrG & EMPXMediaGeneralSize) |
|
751 { |
|
752 RFs fs; |
|
753 User::LeaveIfError(fs.Connect()); |
|
754 CleanupClosePushL(fs); |
|
755 TEntry entry; |
|
756 fs.Entry(iPdPath->Des(), entry); |
|
757 media->SetTObjectValueL<TInt>( |
|
758 TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralSize), |
|
759 entry.iSize); |
|
760 CleanupStack::PopAndDestroy(&fs); |
|
761 } |
|
762 |
|
763 if (attrG & EMPXMediaGeneralMimeType) |
|
764 { |
|
765 RApaLsSession aps; |
|
766 error = aps.Connect(); // always fail in console test |
|
767 if (KErrNone == error) |
|
768 { |
|
769 CleanupClosePushL(aps); |
|
770 TDataType dataType; |
|
771 TUid ignore; |
|
772 if(aps.AppForDocument(iPdPath->Des(),ignore,dataType)==KErrNone) |
|
773 { |
|
774 media->SetTextValueL( |
|
775 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralMimeType), |
|
776 dataType.Des()); |
|
777 } |
|
778 CleanupStack::PopAndDestroy(&aps); |
|
779 } // Notes, STIF console test always fail |
|
780 } |
|
781 |
|
782 // Set DRM info |
|
783 // Only try to get DRM info if the song has completed downloading |
|
784 MPX_DEBUG2("CMPXProgressDownload::MediaL(): iDownloadState = %d", iDownloadState); |
|
785 if ( EPbDlStateDownloadCompleted == iDownloadState ) |
|
786 { |
|
787 const CMPXMedia* drmMedia( iDrmMediaUtility->GetMediaL( attrD )); |
|
788 if ( drmMedia ) |
|
789 { |
|
790 TInt count( drmMedia->Count() ); |
|
791 for ( TInt i = 0; i < count; i++ ) |
|
792 { |
|
793 TUint attrId( drmMedia->Attribute(i).AttributeId() ); |
|
794 if ( attrD & attrId ) |
|
795 { |
|
796 TMPXAttribute mpxAtt( KMPXMediaIdDrm, attrId ); |
|
797 switch ( attrId ) |
|
798 { |
|
799 case EMPXMediaDrmType: |
|
800 case EMPXMediaDrmRightsStatus: |
|
801 case EMPXMediaDrmRightsType: |
|
802 case EMPXMediaDrmCount: |
|
803 { |
|
804 TInt val( |
|
805 drmMedia->ValueTObjectL<TInt>( mpxAtt )); |
|
806 media->SetTObjectValueL( mpxAtt, val ); |
|
807 break; |
|
808 } |
|
809 case EMPXMediaDrmProtected: |
|
810 case EMPXMediaDrmSendingAllowed: |
|
811 case EMPXMediaDrmCanSetAutomated: |
|
812 case EMPXMediaDrmHasInfoUrl: |
|
813 case EMPXMediaDrmHasPreviewUrl: |
|
814 case EMPXMediaDrmAboutToExpire: |
|
815 { |
|
816 TBool val( |
|
817 drmMedia->ValueTObjectL<TBool>( mpxAtt )); |
|
818 media->SetTObjectValueL( mpxAtt, val ); |
|
819 break; |
|
820 } |
|
821 case EMPXMediaDrmStartTime: |
|
822 case EMPXMediaDrmEndTime: |
|
823 case EMPXMediaDrmIntervalStartTime: |
|
824 case EMPXMediaDrmAccumulatedTime: |
|
825 { |
|
826 TInt64 val( |
|
827 drmMedia->ValueTObjectL<TInt64>( mpxAtt )); |
|
828 media->SetTObjectValueL( mpxAtt, val ); |
|
829 break; |
|
830 } |
|
831 case EMPXMediaDrmInterval: |
|
832 { |
|
833 TTimeIntervalSeconds val( |
|
834 drmMedia->ValueTObjectL<TTimeIntervalSeconds>(mpxAtt)); |
|
835 media->SetTObjectValueL( mpxAtt, val ); |
|
836 break; |
|
837 } |
|
838 default: |
|
839 { |
|
840 break; |
|
841 } |
|
842 } // end switch (attriId) |
|
843 } // end if ( attrD & attrId ) |
|
844 } |
|
845 } |
|
846 } |
|
847 |
|
848 iObs->HandleMedia(*media, KErrNone); |
|
849 CleanupStack::PopAndDestroy(media); |
|
850 |
|
851 MPX_DEBUG1("CMPXProgressDownload::MediaL() exiting"); |
|
852 } |
|
853 |
|
854 // ---------------------------------------------------------------------------- |
|
855 // Cancel request |
|
856 // ---------------------------------------------------------------------------- |
|
857 // |
|
858 void CMPXProgressDownload::CancelRequest() |
|
859 { |
|
860 } |
|
861 |
|
862 // ---------------------------------------------------------------------------- |
|
863 // File open complete event |
|
864 // ---------------------------------------------------------------------------- |
|
865 // |
|
866 void CMPXProgressDownload::MapcInitComplete(TInt aError, |
|
867 const TTimeIntervalMicroSeconds& aDuration) |
|
868 { |
|
869 MPX_DEBUG2("CMPXProgressDownload::MapcInitComplete(%d) entering", aError); |
|
870 |
|
871 iState = EStateInitialised; |
|
872 |
|
873 // Restore volume level |
|
874 if ( KErrNone == aError ) |
|
875 { |
|
876 TInt currentVol( 0 ); |
|
877 MPX_TRAPD( volError, currentVol = iVolumeWatcher->CurrentValueL() ); |
|
878 if ( volError == KErrNone ) |
|
879 { |
|
880 SetVolume( currentVol ); |
|
881 TBool mute( EFalse); |
|
882 MPX_TRAPD( muteError, mute = iMuteWatcher->CurrentValueL() ); |
|
883 if ( muteError == KErrNone && mute ) |
|
884 { |
|
885 SetMute(mute); |
|
886 } |
|
887 } |
|
888 } |
|
889 |
|
890 if ( iPdPlayer ) |
|
891 { |
|
892 MMMFDRMCustomCommand* drmCustom = iPdPlayer->GetDRMCustomCommand(); |
|
893 if ( drmCustom ) |
|
894 { |
|
895 drmCustom->DisableAutomaticIntent( ETrue ); |
|
896 } |
|
897 } |
|
898 if ( EPbDlStateDownloadCompleted == iDownloadState ) |
|
899 { |
|
900 TRAP_IGNORE( iDrmMediaUtility->InitL( *iPdPath )); |
|
901 } |
|
902 |
|
903 if ( EPbDlStateBuffering == iDownloadState ) |
|
904 { |
|
905 iDownloadState = EPbDlStateDownloading; |
|
906 TRAP_IGNORE( |
|
907 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPDownloadStateChanged, |
|
908 iDownloadState, aError)); |
|
909 } |
|
910 |
|
911 TRAP_IGNORE( |
|
912 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPActive, |
|
913 ETrue,aError); |
|
914 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPInitialised, |
|
915 aDuration.Int64()/KPbMilliMultiplier,aError); |
|
916 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPPaused, |
|
917 0,aError)); |
|
918 |
|
919 MPX_DEBUG1("CMPXProgressDownload::MapcInitComplete() exiting"); |
|
920 } |
|
921 |
|
922 // ---------------------------------------------------------------------------- |
|
923 // File play complete event |
|
924 // ---------------------------------------------------------------------------- |
|
925 // |
|
926 void CMPXProgressDownload::MapcPlayComplete(TInt aError) |
|
927 { |
|
928 MPX_DEBUG2("CMPXProgressDownload::MapcPlayComplete(%d) entering", aError); |
|
929 |
|
930 iState = EStateNotInitialised; |
|
931 |
|
932 // START WORKAROUND |
|
933 // Check if error is KErrDied and played to the end, then just |
|
934 // treat that as a normal play complete and overwrite the error |
|
935 // handling here |
|
936 // NOTE: This is only a temporary workaround for S60 3.1. |
|
937 // S60 3.2 will have a proper fix in the PD Utility |
|
938 if ( KErrDied == aError ) |
|
939 { |
|
940 MPX_DEBUG2("MPXProgressDownload::MapcPlayComplete(): iDownloadState = %d", iDownloadState); |
|
941 if ( EPbDlStateDownloadCompleted == iDownloadState ) |
|
942 { |
|
943 TTimeIntervalMicroSeconds dur( iPdPlayer->Duration() ); |
|
944 TTimeIntervalMicroSeconds pos; |
|
945 iPdPlayer->GetPosition(pos); |
|
946 if ( Abs( dur.Int64() - pos.Int64() ) < KProgressPlayEndThreshold && |
|
947 dur.Int64() > KProgressPlayEndThreshold ) |
|
948 { |
|
949 MPX_DEBUG1("CMPXProgressDownload::MapcPlayComplete(): Resetting error to KErrNone"); |
|
950 aError = KErrNone; |
|
951 } |
|
952 } |
|
953 } |
|
954 // END WORKAROUND |
|
955 |
|
956 // KErrEof is sometimes returned when play finishes at the end |
|
957 if ( KErrEof == aError ) |
|
958 { |
|
959 aError = KErrNone; |
|
960 } |
|
961 |
|
962 if ( iConsumeStarted ) |
|
963 { |
|
964 if ( KErrNone != aError ) |
|
965 { |
|
966 TRAP_IGNORE( ConsumeRightsL( ContentAccess::EPause ) ); |
|
967 } |
|
968 else |
|
969 { |
|
970 TRAP_IGNORE( ConsumeRightsL( ContentAccess::EStop ) ); |
|
971 } |
|
972 iConsumeStarted = EFalse; |
|
973 } |
|
974 |
|
975 // If killed by audio policy, mimic a paused state |
|
976 if ( KErrDied == aError ) |
|
977 { |
|
978 iObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPaused, |
|
979 0, |
|
980 aError ); |
|
981 } |
|
982 else |
|
983 { |
|
984 iObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPlayComplete, |
|
985 0, |
|
986 aError); |
|
987 } |
|
988 |
|
989 MPX_DEBUG1("CMPXProgressDownload::MapcPlayComplete() exiting"); |
|
990 } |
|
991 |
|
992 // ----------------------------------------------------------------------------- |
|
993 // CMPXProgressDownload::Paused |
|
994 // ----------------------------------------------------------------------------- |
|
995 // |
|
996 void CMPXProgressDownload::Paused() |
|
997 { |
|
998 MPX_DEBUG1("CMPXProgressDownload::Paused() entering"); |
|
999 |
|
1000 // This callback will only be called when the PD Utility runs out |
|
1001 // of data (i.e. all downloaded content has been played). |
|
1002 iObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPaused, |
|
1003 0, |
|
1004 KErrUnderflow); |
|
1005 MPX_DEBUG1("CMPXProgressDownload::Paused() exiting"); |
|
1006 } |
|
1007 |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // CMPXProgressDownload::Playing |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // |
|
1012 void CMPXProgressDownload::Playing() |
|
1013 { |
|
1014 MPX_DEBUG1("CMPXProgressDownload::Playing() entering"); |
|
1015 iObs->HandlePluginEvent(MMPXPlaybackPluginObserver::EPPlaying, |
|
1016 0, |
|
1017 KErrNone); |
|
1018 MPX_DEBUG1("CMPXProgressDownload::Playing() exiting"); |
|
1019 } |
|
1020 |
|
1021 // ----------------------------------------------------------------------------- |
|
1022 // CMPXProgressDownload::HandleDownloadEventL |
|
1023 // ----------------------------------------------------------------------------- |
|
1024 // |
|
1025 void CMPXProgressDownload::HandleDownloadEventL(TUint aTransactionID, |
|
1026 TBrCtlDownloadEvent aEvent, |
|
1027 TUint aValue) |
|
1028 { |
|
1029 MPX_DEBUG4("CMPXProgressDownload::HandleDownloadEventL(%d, %d, %d) entering", |
|
1030 aTransactionID, aEvent, aValue); |
|
1031 |
|
1032 // Notes. It is API in current music player which is called by MusicShop |
|
1033 // |
|
1034 if (iPdPlayer) |
|
1035 { |
|
1036 iPdPlayer->HandleDownloadEventL( aTransactionID, aEvent, aValue ); |
|
1037 |
|
1038 __ASSERT_DEBUG( |
|
1039 aTransactionID == iTransactionId, |
|
1040 User::Panic(_L("CMPlayerAudioUIController::HandleProgressiveDownloadEventL"), |
|
1041 KErrArgument)); |
|
1042 |
|
1043 switch (aEvent) |
|
1044 { |
|
1045 case EDownloadEventStarted: |
|
1046 { |
|
1047 iDownloadState = EPbDlStateBuffering; |
|
1048 iDownloadSize = static_cast<TInt>( aValue ); |
|
1049 |
|
1050 // send new state |
|
1051 iObs->HandlePluginEvent( |
|
1052 MMPXPlaybackPluginObserver::EPDownloadStateChanged, |
|
1053 iDownloadState, |
|
1054 KErrNone); |
|
1055 iObs->HandlePluginEvent( |
|
1056 MMPXPlaybackPluginObserver::EPDownloadStarted, |
|
1057 iDownloadSize, |
|
1058 KErrNone ); |
|
1059 break; |
|
1060 } |
|
1061 case EDownloadEventCompleted: |
|
1062 { |
|
1063 iDownloadState = EPbDlStateDownloadCompleted; |
|
1064 iDownloadSize = static_cast<TInt>( aValue ); |
|
1065 iDownloadBytes = iDownloadSize; |
|
1066 iObs->HandlePluginEvent( |
|
1067 MMPXPlaybackPluginObserver::EPDownloadStateChanged, |
|
1068 iDownloadState, |
|
1069 KErrNone); |
|
1070 break; |
|
1071 } |
|
1072 case EDownloadEventCanceled: |
|
1073 { |
|
1074 iDownloadState = EPbDlStateNotDownloading; |
|
1075 iObs->HandlePluginEvent( |
|
1076 MMPXPlaybackPluginObserver::EPDownloadStateChanged, |
|
1077 iDownloadState, |
|
1078 KErrNone); |
|
1079 break; |
|
1080 } |
|
1081 case EDownloadEventError: |
|
1082 { |
|
1083 iDownloadState = EPbDlStateDownloadError; |
|
1084 iObs->HandlePluginEvent( |
|
1085 MMPXPlaybackPluginObserver::EPDownloadStateChanged, |
|
1086 iDownloadState, |
|
1087 KErrNone); |
|
1088 break; |
|
1089 } |
|
1090 case EDownloadEventProgress: |
|
1091 { |
|
1092 if ( EPbDlStateDownloadPaused == iDownloadState ) |
|
1093 { |
|
1094 iDownloadState = EPbDlStateDownloading; |
|
1095 iObs->HandlePluginEvent( |
|
1096 MMPXPlaybackPluginObserver::EPDownloadStateChanged, |
|
1097 iDownloadState, |
|
1098 KErrNone); |
|
1099 } |
|
1100 iDownloadBytes = static_cast<TInt>( aValue ); |
|
1101 iObs->HandlePluginEvent( |
|
1102 MMPXPlaybackPluginObserver::EPDownloadPositionChanged, |
|
1103 iDownloadBytes, |
|
1104 KErrNone); |
|
1105 break; |
|
1106 } |
|
1107 case EDownloadEventPaused: |
|
1108 { |
|
1109 iDownloadState = EPbDlStateDownloadPaused; |
|
1110 iObs->HandlePluginEvent( |
|
1111 MMPXPlaybackPluginObserver::EPDownloadStateChanged, |
|
1112 iDownloadState, |
|
1113 KErrNone); |
|
1114 break; |
|
1115 } |
|
1116 case EDownloadEventPausable: |
|
1117 { |
|
1118 iFeatureFlag |= EPbFeaturePdPausable; |
|
1119 iObs->HandlePluginEvent( |
|
1120 MMPXPlaybackPluginObserver::EPSupportedFeaturesChanged, |
|
1121 iFeatureFlag, |
|
1122 KErrNone); |
|
1123 break; |
|
1124 } |
|
1125 default: |
|
1126 { |
|
1127 // pass |
|
1128 break; |
|
1129 } |
|
1130 } |
|
1131 } |
|
1132 MPX_DEBUG1("CMPXProgressDownload::HandleDownloadEventL() exiting"); |
|
1133 } |
|
1134 |
|
1135 // ---------------------------------------------------------------------------- |
|
1136 // Handle a change in a setting value. |
|
1137 // ---------------------------------------------------------------------------- |
|
1138 // |
|
1139 void CMPXProgressDownload::HandleSettingChange( |
|
1140 const TUid& aRepositoryUid, |
|
1141 TUint32 aSettingId ) |
|
1142 { |
|
1143 MPX_DEBUG1("CMPXProgressDownload::HandleSettingChange() entering"); |
|
1144 |
|
1145 if ( KCRUidMPXSettings == aRepositoryUid && |
|
1146 KMPXPlaybackVolume == aSettingId ) |
|
1147 { |
|
1148 MPX_DEBUG1("CMPXProgressDownload::HandleSettingChange() Volume setting changed"); |
|
1149 TInt currentVol( 0 ); |
|
1150 MPX_TRAPD( volError, currentVol = iVolumeWatcher->CurrentValueL() ); |
|
1151 if ( KErrNone == volError ) |
|
1152 { |
|
1153 SetVolume( currentVol ); |
|
1154 } |
|
1155 } |
|
1156 else if ( KCRUidMPXSettings == aRepositoryUid && |
|
1157 KMPXPlaybackMute == aSettingId ) |
|
1158 { |
|
1159 MPX_DEBUG1("CMPXProgressDownload::HandleSettingChange() Mute setting changed"); |
|
1160 TBool mute( EFalse ); |
|
1161 MPX_TRAPD( error, mute = static_cast<TBool>(iMuteWatcher->CurrentValueL()) ); |
|
1162 if ( error == KErrNone ) |
|
1163 { |
|
1164 TInt oldVolume( 0 ); |
|
1165 iPdPlayer->GetVolume( oldVolume ); |
|
1166 if ( (mute && oldVolume != 0) || (!mute && oldVolume == 0) ) |
|
1167 { |
|
1168 SetMute( mute ); |
|
1169 } |
|
1170 } |
|
1171 } |
|
1172 MPX_DEBUG1("CMPXProgressDownload::HandleSettingChange() exiting"); |
|
1173 } |
|
1174 |
|
1175 // ---------------------------------------------------------------------------- |
|
1176 // Sets the volume level in audio controller |
|
1177 // ---------------------------------------------------------------------------- |
|
1178 // |
|
1179 void CMPXProgressDownload::SetVolume( TInt aVolume ) |
|
1180 { |
|
1181 MPX_DEBUG2("CMPXProgressDownload::SetVolume(%d) entering", aVolume); |
|
1182 |
|
1183 // Ensure that level is within min and max values |
|
1184 if ( aVolume > KPbPlaybackVolumeLevelMax ) |
|
1185 { |
|
1186 aVolume = KPbPlaybackVolumeLevelMax; |
|
1187 } |
|
1188 if ( aVolume < KPbPlaybackVolumeLevelMin ) |
|
1189 { |
|
1190 aVolume = KPbPlaybackVolumeLevelMin; |
|
1191 } |
|
1192 |
|
1193 TBool changed( EFalse ); |
|
1194 // Change MMF Audio player's volume |
|
1195 if ( EStateInitialised == iState ) |
|
1196 { |
|
1197 TInt newVolume( aVolume * iPdPlayer->MaxVolume() / 100 ); |
|
1198 MPX_DEBUG2("CMPXProgressDownload::SetVolume(): Setting volume = %d", newVolume); |
|
1199 |
|
1200 // First check if MMF Audio player's volume is changed by new value |
|
1201 TInt oldVolume( 0 ); |
|
1202 iPdPlayer->GetVolume( oldVolume ); |
|
1203 if ( newVolume != oldVolume ) |
|
1204 { |
|
1205 iPdPlayer->SetVolume( newVolume ); |
|
1206 changed = ETrue; |
|
1207 } |
|
1208 } |
|
1209 |
|
1210 // Change setting in cenrep |
|
1211 TInt currentVol( 0 ); |
|
1212 MPX_TRAPD( volError, currentVol = iVolumeWatcher->CurrentValueL() ); |
|
1213 if ( volError == KErrNone && aVolume != currentVol ) |
|
1214 { |
|
1215 MPX_TRAP( volError, iVolumeWatcher->SetValueL( aVolume ) ); |
|
1216 } |
|
1217 |
|
1218 // Notify observer if value changed |
|
1219 if ( changed ) |
|
1220 { |
|
1221 iObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPVolumeChanged, |
|
1222 aVolume, |
|
1223 KErrNone); |
|
1224 } |
|
1225 |
|
1226 MPX_DEBUG1("CMPXProgressDownload::SetVolume() exiting"); |
|
1227 } |
|
1228 |
|
1229 // ---------------------------------------------------------------------------- |
|
1230 // Sets the volume level in audio controller |
|
1231 // ---------------------------------------------------------------------------- |
|
1232 // |
|
1233 void CMPXProgressDownload::SetMute( TBool aMute ) |
|
1234 { |
|
1235 MPX_DEBUG3("-->CMPXProgressDownload::SetMute 0x%08x vol (%d)", this, aMute); |
|
1236 |
|
1237 TBool changed( EFalse ); |
|
1238 // Change MMF Audio player's volume |
|
1239 TInt currentVolume(0); |
|
1240 iPdPlayer->GetVolume(currentVolume); |
|
1241 if ( aMute && currentVolume != 0 ) |
|
1242 { |
|
1243 iVolume = currentVolume; |
|
1244 iPdPlayer->SetVolume(0); |
|
1245 changed = ETrue; |
|
1246 } |
|
1247 else if ( !aMute && currentVolume == 0 ) // UnMute |
|
1248 { |
|
1249 iPdPlayer->SetVolume(iVolume); |
|
1250 changed = ETrue; |
|
1251 } |
|
1252 |
|
1253 // Change setting in cenrep |
|
1254 TBool currentMute( EFalse ); |
|
1255 MPX_TRAPD( muteError, currentMute = iMuteWatcher->CurrentValueL() ); |
|
1256 if ( muteError == KErrNone ) |
|
1257 { |
|
1258 if ( aMute && !currentMute ) |
|
1259 { |
|
1260 MPX_TRAP( muteError, iMuteWatcher->SetValueL( aMute ) ); |
|
1261 } |
|
1262 else if ( !aMute && currentMute ) |
|
1263 { |
|
1264 MPX_TRAP( muteError, iMuteWatcher->SetValueL( aMute ) ); |
|
1265 } |
|
1266 } |
|
1267 |
|
1268 // Notify observer if value changed |
|
1269 if ( changed ) |
|
1270 { |
|
1271 iObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPMuteChanged, |
|
1272 aMute, |
|
1273 KErrNone); |
|
1274 } |
|
1275 |
|
1276 MPX_DEBUG3("<--CMPXProgressDownload::SetMute 0x%08x vol (%d)", this, aMute); |
|
1277 } |
|
1278 |
|
1279 // ---------------------------------------------------------------------------- |
|
1280 // Consumes the rights for the current media |
|
1281 // ---------------------------------------------------------------------------- |
|
1282 // |
|
1283 void CMPXProgressDownload::ConsumeRightsL(ContentAccess::TIntent aIntent) |
|
1284 { |
|
1285 MPX_DEBUG2("-->CMPXProgressDownload::ConsumeRightsL(%d)", aIntent); |
|
1286 if ( iPdPlayer ) |
|
1287 { |
|
1288 MMMFDRMCustomCommand* drmCustom = iPdPlayer->GetDRMCustomCommand(); |
|
1289 if ( drmCustom ) |
|
1290 { |
|
1291 switch ( aIntent ) |
|
1292 { |
|
1293 case ContentAccess::EPlay: |
|
1294 case ContentAccess::EStop: |
|
1295 case ContentAccess::EPause: |
|
1296 case ContentAccess::EContinue: |
|
1297 { |
|
1298 break; |
|
1299 } |
|
1300 default: |
|
1301 { |
|
1302 aIntent = ContentAccess::EUnknown; |
|
1303 iConsumeStarted = EFalse; |
|
1304 break; |
|
1305 } |
|
1306 } |
|
1307 MPX_DEBUG2("-->CMPXProgressDownload::ConsumeRightsL(): Executing intent %d", aIntent); |
|
1308 TInt returnCode( drmCustom->ExecuteIntent(aIntent) ); |
|
1309 MPX_DEBUG2("CMPXProgressDownload::ConsumeRightsL() ExecuteIntent return (%d)", returnCode); |
|
1310 User::LeaveIfError(returnCode); |
|
1311 } |
|
1312 } |
|
1313 MPX_DEBUG2("<--CMPXProgressDownload::ConsumeRightsL(%d)", aIntent); |
|
1314 } |
|
1315 |
|
1316 // End of file |