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