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