|
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: Implementation of media key handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <bldvariant.hrh> |
|
21 #include <remconcoreapitarget.h> |
|
22 #include <remconcoreapitargetobserver.h> |
|
23 #include <remconinterfaceselector.h> |
|
24 #include <aknconsts.h> |
|
25 #include <AknUtils.h> |
|
26 #include <eikenv.h> |
|
27 #include <bautils.h> |
|
28 #include <StringLoader.h> |
|
29 #include <apgwgnam.h> |
|
30 |
|
31 #ifdef UPNP_INCLUDED |
|
32 #include <upnpcopycommand.h> |
|
33 #endif |
|
34 |
|
35 |
|
36 #include <aknnotewrappers.h> // AknErrorNote |
|
37 #include <AknVolumePopup.h> |
|
38 |
|
39 #include <mpxplaybackutility.h> |
|
40 #include <mpxplaybackmessage.h> |
|
41 #include <data_caging_path_literals.hrh> |
|
42 #include <mpxmediakeyhandler.rsg> |
|
43 #include <mpxmedia.h> |
|
44 #include <mpxmessagegeneraldefs.h> |
|
45 #include <mpxplaybackmessagedefs.h> |
|
46 #include <mpxmediageneraldefs.h> |
|
47 #include <mpxuser.h> |
|
48 #include <mpxmediakeyhandler.h> |
|
49 #include <mpxlog.h> |
|
50 #include <layoutmetadata.cdl.h> |
|
51 #include <mpxconstants.h> |
|
52 |
|
53 #include "mpxmetadatahandler.h" |
|
54 #include <mpxplaybackframeworkdefs.h> |
|
55 #include <sounddevice.h> |
|
56 #include "mpxmediakeyhandlerimp.h" |
|
57 #include "mpxremconkeyresponse.h" |
|
58 #include "mpxnotifierdialog.h" |
|
59 |
|
60 |
|
61 // CONSTANTS |
|
62 const TInt KFirstTimerExpiryInterval( 1 ); // Expire immediately |
|
63 const TInt KTimerExpiryInterval( KAknStandardKeyboardRepeatRate ); |
|
64 const TInt KMPXOneSecInMilliSecs( 1000 ); |
|
65 const TInt KMPXMinVolume(0); |
|
66 const TInt KMPXMaxVolume(100); // Max volume used in volume popup |
|
67 const TInt KMPXVolumeSteps(1); |
|
68 const TInt KTenStepsVolume = 10; |
|
69 const TInt KTwentyStepsVolume = 20; |
|
70 |
|
71 _LIT( KMPXMediaKeyHandlerRscPath, "mpxmediakeyhandler.rsc" ); |
|
72 |
|
73 |
|
74 // ======== MEMBER FUNCTIONS ======== |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // C++ default constructor can NOT contain any code, that |
|
78 // might leave. |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CMPXMediaKeyHandlerImp::CMPXMediaKeyHandlerImp( |
|
82 MMPXMediaKeyHandlerObserver* aObserver ) : |
|
83 iObserver( aObserver ), |
|
84 iEnable( ETrue ), |
|
85 iCurrentVol( KErrNotFound ), |
|
86 iVolumeSteps(KMPXMaxVolume) |
|
87 { |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // Symbian 2nd phase constructor can leave. |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CMPXMediaKeyHandlerImp::ConstructL( |
|
95 TMPXMediaKeyPopupFlags aFlags ) |
|
96 { |
|
97 ASSERT( iObserver ); |
|
98 CCoeEnv* coeEnv = CEikonEnv::Static(); |
|
99 TParse parse; |
|
100 parse.Set( KMPXMediaKeyHandlerRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
101 TFileName resourceFile( parse.FullName() ); |
|
102 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
103 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
104 iResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
105 |
|
106 // Register to remote control framework |
|
107 iInterfaceSelector = CRemConInterfaceSelector::NewL(); |
|
108 iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this ); |
|
109 // For handling AVRCP 1.3 metadata |
|
110 iMetaDataHandler = MMPXMetaDataHandler::NewL(*iInterfaceSelector); |
|
111 iInterfaceSelector->OpenTargetL(); |
|
112 iResponseHandler = CMPXRemConKeyResponse::NewL( *iCoreTarget ); |
|
113 |
|
114 // Timer for implementing repeat |
|
115 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
116 |
|
117 // Get the playback utility instance from engine. |
|
118 iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault ); |
|
119 iPlaybackUtility->AddObserverL( *this ); |
|
120 // get the current Volume and Max Volume |
|
121 iPlaybackUtility->PropertyL(*this, EPbPropertyVolume); |
|
122 iPlaybackUtility->PropertyL(*this, EPbPropertyMute); |
|
123 CMMFDevSound* devsound = CMMFDevSound::NewL(); |
|
124 MPX_DEBUG2( "CMPXMediaKeyHandlerImp::Constructdevsound->MaxVolume()%d",devsound->MaxVolume()); |
|
125 iVolumeSteps = KTenStepsVolume; //Default 10 steps |
|
126 if ( devsound && devsound->MaxVolume() >= KTwentyStepsVolume ) |
|
127 { |
|
128 // set 20-steps volume |
|
129 iVolumeSteps = KTwentyStepsVolume; |
|
130 } |
|
131 delete devsound; |
|
132 if ( aFlags & EDisplayVolumePopup ) |
|
133 { |
|
134 // Popup volume control |
|
135 iVolPopup = CAknVolumePopup::NewL(NULL, ETrue); |
|
136 iVolPopup->SetObserver(this); |
|
137 iVolPopup->SetRange(KMPXMinVolume, iVolumeSteps); |
|
138 iVolPopup->SetStepSize(KMPXVolumeSteps); |
|
139 |
|
140 HBufC* popupText = StringLoader::LoadLC( R_MPX_VOLUME_POPUP_TEXT ); |
|
141 iVolPopup->SetTitleTextL( *popupText ); |
|
142 CleanupStack::PopAndDestroy( popupText ); |
|
143 } |
|
144 |
|
145 if ( aFlags & EDisplayMediaPopup ) |
|
146 { |
|
147 // Playback popup |
|
148 iPlaybackPopup = CMPXNotifierDialog::NewL(); |
|
149 } |
|
150 |
|
151 MMPXSource* s = iPlaybackUtility->Source(); |
|
152 if ( s ) |
|
153 { |
|
154 RArray<TMPXAttribute> attrs; |
|
155 CleanupClosePushL(attrs); |
|
156 attrs.Append( KMPXMediaGeneralTitle ); |
|
157 s->MediaL( attrs.Array(), *this ); |
|
158 CleanupStack::PopAndDestroy( &attrs ); |
|
159 } |
|
160 else |
|
161 { |
|
162 // No current track. |
|
163 // This is constructed so that the first popup will display |
|
164 // it doesn't hold anything. |
|
165 iTrackTitle = HBufC::NewL( 1 ); |
|
166 } |
|
167 #ifdef UPNP_INCLUDED |
|
168 if (!iUpnpCopyCommand ) |
|
169 { |
|
170 MPX_TRAPD ( error, iUpnpCopyCommand = CUpnpCopyCommand::NewL() ); |
|
171 if ( error == KErrNone ) |
|
172 { |
|
173 iUpnpFrameworkSupport = ETrue; |
|
174 } |
|
175 else |
|
176 { |
|
177 iUpnpFrameworkSupport = EFalse; |
|
178 iUpnpCopyCommand = NULL; |
|
179 } |
|
180 } |
|
181 #endif |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // Two-phased constructor. |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 MMPXMediaKeyHandler* CMPXMediaKeyHandlerImp::NewL( |
|
189 TMPXMediaKeyPopupFlags aFlags, |
|
190 MMPXMediaKeyHandlerObserver* aObserver ) |
|
191 { |
|
192 CMPXMediaKeyHandlerImp* self = |
|
193 new(ELeave)CMPXMediaKeyHandlerImp( aObserver ); |
|
194 CleanupStack::PushL( self ); |
|
195 self->ConstructL( aFlags ); |
|
196 CleanupStack::Pop(); |
|
197 |
|
198 return self; |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // Destructor |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 CMPXMediaKeyHandlerImp::~CMPXMediaKeyHandlerImp() |
|
206 { |
|
207 if ( iPlaybackUtility ) |
|
208 { |
|
209 TRAP_IGNORE( iPlaybackUtility->RemoveObserverL( *this ) ); |
|
210 iPlaybackUtility->Close(); |
|
211 } |
|
212 |
|
213 delete iMetaDataHandler; |
|
214 |
|
215 delete iResponseHandler; |
|
216 delete iInterfaceSelector; |
|
217 |
|
218 if( iTimer ) |
|
219 { |
|
220 iTimer->Cancel(); |
|
221 delete iTimer; |
|
222 } |
|
223 |
|
224 if ( iResourceOffset ) |
|
225 { |
|
226 CEikonEnv::Static()->DeleteResourceFile( iResourceOffset ); |
|
227 } |
|
228 |
|
229 delete iTrackTitle; |
|
230 delete iVolPopup; |
|
231 delete iPlaybackPopup; |
|
232 #ifdef UPNP_INCLUDED |
|
233 if ( iUpnpCopyCommand) |
|
234 { |
|
235 delete iUpnpCopyCommand; |
|
236 } |
|
237 #endif |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // Filter and send command to playback utility. |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 void CMPXMediaKeyHandlerImp::FilterAndSendCommand( |
|
245 TMPXPlaybackCommand aCommandId ) |
|
246 { |
|
247 MPX_FUNC( "CMPXMediaKeyHandlerImp::FilterAndSendCommand" ); |
|
248 TRAP_IGNORE( DoFilterAndSendCommandL( aCommandId ) ); |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // Help filter and send command to playback utility. |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 void CMPXMediaKeyHandlerImp::DoFilterAndSendCommandL( |
|
256 TMPXPlaybackCommand aCommandId ) |
|
257 { |
|
258 MPX_FUNC( "CMPXMediaKeyHandlerImp::DoFilterAndSendCommandL" ); |
|
259 // Only send media key events if the media key component is enabled |
|
260 if( iEnable ) |
|
261 { |
|
262 TBool forwardCommand = ETrue; |
|
263 if ( iUpnpFrameworkSupport ) |
|
264 { |
|
265 switch ( aCommandId ) |
|
266 { |
|
267 case EPbCmdStartSeekForward: |
|
268 case EPbCmdStartSeekBackward: |
|
269 { |
|
270 if ( IsUpnpVisibleL() ) |
|
271 { |
|
272 TFileName subPlayerName; |
|
273 TMPXPlaybackPlayerType currentPlayerType = EPbLocal; |
|
274 GetSubPlayerInfoL(subPlayerName, currentPlayerType); |
|
275 |
|
276 if ( currentPlayerType != EPbLocal) |
|
277 { |
|
278 //show error note |
|
279 HBufC* dialogText = StringLoader::LoadLC(R_MPX_MEDIA_KEY_NOT_SUPPORTED); |
|
280 CAknErrorNote* errNote = new(ELeave) CAknErrorNote(ETrue); |
|
281 errNote->SetTimeout(CAknNoteDialog::ELongTimeout); |
|
282 errNote->ExecuteLD( *dialogText ); |
|
283 CleanupStack::PopAndDestroy( dialogText ); |
|
284 forwardCommand = EFalse; |
|
285 } |
|
286 } |
|
287 break; |
|
288 } |
|
289 default: |
|
290 { |
|
291 //do nothing |
|
292 break; |
|
293 } |
|
294 } |
|
295 } |
|
296 |
|
297 if ( forwardCommand ) |
|
298 { |
|
299 iVolumeEventCount++; |
|
300 |
|
301 TInt volume = iUpnpVolume % ( KPbPlaybackVolumeLevelMax / iVolumeSteps ) |
|
302 + iCurrentVol * KPbPlaybackVolumeLevelMax / iVolumeSteps; |
|
303 |
|
304 if ( volume < KMPXMinVolume ) |
|
305 { |
|
306 volume = KMPXMinVolume; |
|
307 } |
|
308 if ( volume > KMPXMaxVolume ) |
|
309 { |
|
310 volume = KMPXMaxVolume; |
|
311 } |
|
312 |
|
313 iObserver->HandleMediaKeyCommand( aCommandId, volume ); |
|
314 } |
|
315 } |
|
316 } |
|
317 |
|
318 // --------------------------------------------------------------------------- |
|
319 // Handle playback message. |
|
320 // --------------------------------------------------------------------------- |
|
321 // |
|
322 void CMPXMediaKeyHandlerImp::DoHandlePlaybackMessageL( |
|
323 const CMPXMessage& aMessage ) |
|
324 { |
|
325 MPX_FUNC( "CMPXMediaKeyHandlerImp::DoHandlePlaybackMessageL(CMPXMessage)"); |
|
326 |
|
327 TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
328 if ( KMPXMessagePbMediaChanged == id ) |
|
329 { |
|
330 if ( aMessage.IsSupported( KMPXMessagePbMedia ) ) |
|
331 { |
|
332 CMPXMedia* media( aMessage.Value<CMPXMedia>( KMPXMessagePbMedia ) ); |
|
333 User::LeaveIfNull( media ); |
|
334 iPlaybackPosition = 0; |
|
335 DoHandleMediaL( *media, KErrNone ); |
|
336 } |
|
337 } |
|
338 else if ( KMPXMessageGeneral == id ) |
|
339 { |
|
340 TInt type( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType )); |
|
341 TInt data( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData )); |
|
342 switch ( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) ) |
|
343 { |
|
344 case TMPXPlaybackMessage::EPropertyChanged: |
|
345 { |
|
346 TMPXPlaybackProperty property( |
|
347 static_cast<TMPXPlaybackProperty>( type ) ); |
|
348 TInt error( KErrNone ); |
|
349 |
|
350 DoHandlePropertyL( property, data, error ); |
|
351 break; |
|
352 } |
|
353 case TMPXPlaybackMessage::EStateChanged: |
|
354 { |
|
355 MPX_DEBUG2( "CMPXMediaKeyHandlerImp::HandlePlaybackMessageL - EStateChanged(%d)", type ); |
|
356 |
|
357 TMPXPlaybackState state = |
|
358 static_cast<TMPXPlaybackState>( type ); |
|
359 DoHandleStateChangedL( state ); |
|
360 break; |
|
361 } |
|
362 case TMPXPlaybackMessage::EMediaChanged: |
|
363 { |
|
364 MMPXSource* s = iPlaybackUtility->Source(); |
|
365 if ( s ) |
|
366 { |
|
367 RArray<TMPXAttribute> attrs; |
|
368 CleanupClosePushL(attrs); |
|
369 attrs.Append( KMPXMediaGeneralTitle ); |
|
370 MPX_DEBUG1( "CMPXMediaKeyHandlerImp::HandlePlaybackMessageL Media changed, calling MediaL to refresh" ); |
|
371 s->MediaL( attrs.Array(), *this ); |
|
372 CleanupStack::PopAndDestroy( &attrs ); |
|
373 } |
|
374 break; |
|
375 } |
|
376 case TMPXPlaybackMessage::ECommandReceived: |
|
377 { |
|
378 MPX_DEBUG2( "CMPXMediaKeyHandlerImp::HandlePlaybackMessageL - ECommandReceived(%d)", type ); |
|
379 break; |
|
380 } |
|
381 case TMPXPlaybackMessage::ESkipping: |
|
382 { |
|
383 iSkipping = ETrue; |
|
384 break; |
|
385 } |
|
386 case TMPXPlaybackMessage::ESkipEnd: |
|
387 { |
|
388 iSkipping = EFalse; |
|
389 break; |
|
390 } |
|
391 default: |
|
392 { |
|
393 break; |
|
394 } |
|
395 } |
|
396 } |
|
397 } |
|
398 |
|
399 // --------------------------------------------------------------------------- |
|
400 // Handle playback property. |
|
401 // --------------------------------------------------------------------------- |
|
402 // |
|
403 void CMPXMediaKeyHandlerImp::DoHandlePropertyL( |
|
404 TMPXPlaybackProperty aProperty, |
|
405 TInt aValue, |
|
406 TInt aError ) |
|
407 { |
|
408 MPX_FUNC( "CMPXMediaKeyHandlerImp::DoHandlePropertyL" ); |
|
409 MPX_DEBUG4( "CMPXMediaKeyHandlerImp::HandlePropertyL - Property(%d); Value(%d); Error(%d)", aProperty, aValue, aError ); |
|
410 |
|
411 iUpnpVolume = aValue; |
|
412 if ( KErrNone == aError ) |
|
413 { |
|
414 switch ( aProperty ) |
|
415 { |
|
416 case EPbPropertyPosition: |
|
417 { |
|
418 iPlaybackPosition = aValue / KMPXOneSecInMilliSecs; |
|
419 ShowPlaybackPopupL( EMPXPopupShowIfVisible ); |
|
420 break; |
|
421 } |
|
422 case EPbPropertyMute: |
|
423 { |
|
424 if ( iTouchVolEventCount > 0 ) |
|
425 { |
|
426 --iTouchVolEventCount; |
|
427 } |
|
428 if ( iVolumeEventCount > 0 ) |
|
429 { |
|
430 --iVolumeEventCount; |
|
431 } |
|
432 iMuted = aValue; |
|
433 if ( iMuted ) |
|
434 { |
|
435 iVolPopup->SetValue( 0 ); |
|
436 } |
|
437 else |
|
438 { |
|
439 iVolPopup->SetValue( iCurrentVol ); |
|
440 } |
|
441 break; |
|
442 } |
|
443 case EPbPropertyVolume: |
|
444 { |
|
445 if ( iVolPopup ) |
|
446 { |
|
447 if ( iTouchVolEventCount > 0 ) |
|
448 { |
|
449 --iTouchVolEventCount; |
|
450 } |
|
451 // Avkon Volume has 10 steps, but the rest of the framework |
|
452 // has 100 steps. Need to scale it to 10 steps. |
|
453 if ( aValue > 0 ) |
|
454 { |
|
455 aValue = aValue * iVolumeSteps; |
|
456 aValue = aValue / KPbPlaybackVolumeLevelMax; |
|
457 if ( aValue > iVolumeSteps ) |
|
458 { |
|
459 aValue = iVolumeSteps; |
|
460 } |
|
461 } |
|
462 |
|
463 if( iMuted && aValue > 0 ) // unmute |
|
464 { |
|
465 iMuted = EFalse; |
|
466 iCurrentVol = aValue; |
|
467 iVolPopup->SetValue( iCurrentVol ); |
|
468 } |
|
469 else if( aValue == 0 ) // mute |
|
470 { |
|
471 if( !iMuted ) |
|
472 { |
|
473 iMuted = ETrue; |
|
474 iVolPopup->SetValue( 0 ); |
|
475 } |
|
476 } |
|
477 else if ( aValue != iCurrentVol && !iTouchVolEventCount && !iVolumeEventCount ) |
|
478 { |
|
479 if ( aValue != 0 ) |
|
480 { |
|
481 iCurrentVol = aValue; |
|
482 } |
|
483 iVolPopup->SetValue( iCurrentVol ); |
|
484 } |
|
485 |
|
486 if ( iVolumeEventCount > 0 ) |
|
487 { |
|
488 --iVolumeEventCount; |
|
489 } |
|
490 |
|
491 // send a command to UI to display Volume bar on device when controlling volume via UPnP |
|
492 if ( IsUpnpVisibleL() && iPlayerState != EPbStateNotInitialised ) |
|
493 { |
|
494 TFileName subPlayerName; |
|
495 TMPXPlaybackPlayerType currentPlayerType = EPbLocal; |
|
496 GetSubPlayerInfoL( subPlayerName, currentPlayerType ); |
|
497 |
|
498 if ( currentPlayerType != EPbLocal ) |
|
499 { |
|
500 iObserver->HandleMediaKeyCommand( EPbCmdSetVolume, iUpnpVolume ); |
|
501 } |
|
502 } |
|
503 |
|
504 if ( iUpnpFrameworkSupport ) |
|
505 { |
|
506 SetVolumePopupTitleL(); |
|
507 } |
|
508 } |
|
509 break; |
|
510 } |
|
511 default: |
|
512 { |
|
513 break; |
|
514 } |
|
515 } |
|
516 } |
|
517 else |
|
518 { |
|
519 switch ( aProperty ) |
|
520 { |
|
521 case EPbPropertyVolume: |
|
522 case EPbPropertyMute: |
|
523 { |
|
524 if ( iVolPopup && iShowPopups & EDisplayVolumePopup ) |
|
525 { |
|
526 //show error note |
|
527 HBufC* dialogText = StringLoader::LoadLC(R_MPX_VOLUME_KEYS_NOT_SUPPORTED); |
|
528 CAknErrorNote* errNote = new(ELeave) CAknErrorNote(ETrue); |
|
529 errNote->SetTimeout(CAknNoteDialog::ELongTimeout); |
|
530 errNote->ExecuteLD( *dialogText ); |
|
531 CleanupStack::PopAndDestroy( dialogText ); |
|
532 } |
|
533 break; |
|
534 } |
|
535 default: |
|
536 { |
|
537 break; |
|
538 } |
|
539 } |
|
540 } |
|
541 } |
|
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // Handle media properties. |
|
545 // Notes: The client is responsible for delete the object of aProperties. |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 void CMPXMediaKeyHandlerImp::DoHandleMediaL( |
|
549 const CMPXMedia& aMedia, |
|
550 TInt aError ) |
|
551 { |
|
552 MPX_FUNC( "CMPXMediaKeyHandlerImp::DoHandleMediaL" ); |
|
553 |
|
554 // Delete old title no matter there's error or not |
|
555 if ( iTrackTitle ) |
|
556 { |
|
557 delete iTrackTitle; |
|
558 iTrackTitle = NULL; |
|
559 } |
|
560 |
|
561 if ( KErrNone == aError ) |
|
562 { |
|
563 // Keep track of the current track's title |
|
564 iTrackTitle = aMedia.ValueText( KMPXMediaGeneralTitle ).AllocL(); |
|
565 |
|
566 // Update popup if visible |
|
567 if ( iShowPopups & EDisplayMediaPopup ) |
|
568 { |
|
569 MPX_DEBUG1( "CMPXMediaKeyHandlerImp::DoHandleMediaL EMPXPopupTimeout" ); |
|
570 ShowPlaybackPopupL( EMPXPopupTimeout ); |
|
571 } |
|
572 else |
|
573 { |
|
574 ShowPlaybackPopupL( EMPXPopupShowIfVisible ); |
|
575 } |
|
576 } |
|
577 } |
|
578 |
|
579 // --------------------------------------------------------------------------- |
|
580 // Handle playback state changed. |
|
581 // --------------------------------------------------------------------------- |
|
582 // |
|
583 void CMPXMediaKeyHandlerImp::DoHandleStateChangedL( |
|
584 TMPXPlaybackState aState ) |
|
585 { |
|
586 MPX_FUNC( "CMPXMediaKeyHandlerImp::DoHandleStateChangedL" ); |
|
587 switch ( aState ) |
|
588 { |
|
589 case EPbStateStopped: |
|
590 { |
|
591 iPlayerState = aState; |
|
592 ShowPlaybackPopupL( EMPXPopupShowIfVisible ); |
|
593 break; |
|
594 } |
|
595 case EPbStatePlaying: |
|
596 case EPbStatePaused: |
|
597 { |
|
598 iPlayerState = aState; |
|
599 // Start the time if needed, otherwise, update content if visible |
|
600 if ( iShowPopups & EDisplayMediaPopup ) |
|
601 { |
|
602 MPX_DEBUG1( "CMPXMediaKeyHandlerImp::DoHandleStateChangedL EMPXPopupTimeout" ); |
|
603 ShowPlaybackPopupL( EMPXPopupTimeout ); |
|
604 } |
|
605 else |
|
606 { |
|
607 ShowPlaybackPopupL( EMPXPopupShowIfVisibleRestartTimer ); |
|
608 } |
|
609 break; |
|
610 } |
|
611 default: |
|
612 { |
|
613 // do nothing |
|
614 break; |
|
615 } |
|
616 } |
|
617 } |
|
618 |
|
619 // --------------------------------------------------------------------------- |
|
620 // Callback for timer |
|
621 // --------------------------------------------------------------------------- |
|
622 // |
|
623 TInt CMPXMediaKeyHandlerImp::TimerCallback( TAny* aPtr ) |
|
624 { |
|
625 static_cast<CMPXMediaKeyHandlerImp*>( aPtr )->HandleRepeatEvent(); |
|
626 return KErrNone; |
|
627 } |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // Handle repeat event |
|
631 // --------------------------------------------------------------------------- |
|
632 // |
|
633 void CMPXMediaKeyHandlerImp::HandleRepeatEvent() |
|
634 { |
|
635 UpdateVolume(); |
|
636 FilterAndSendCommand( iCommandId ); |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CMPXMediaKeyHandlerImp::GetSubPlayerInfoL |
|
641 // Retrieves the current player name and sets the volume popup title |
|
642 // ----------------------------------------------------------------------------- |
|
643 // |
|
644 void CMPXMediaKeyHandlerImp::GetSubPlayerInfoL( |
|
645 TDes& aSubPlayerName, |
|
646 TMPXPlaybackPlayerType& aCurrentPlayerType ) |
|
647 { |
|
648 aCurrentPlayerType = EPbLocal; |
|
649 aSubPlayerName = KNullDesC; |
|
650 |
|
651 //#ifdef __UPNP_FRAMEWORK_2_0_ |
|
652 if ( iUpnpFrameworkSupport ) |
|
653 { |
|
654 MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager(); |
|
655 TUid currentlyUsedPlayer; |
|
656 TInt currentlyUsedSubPlayer; |
|
657 HBufC* subPlayerName = NULL; |
|
658 TRAP_IGNORE( manager.GetSelectionL( aCurrentPlayerType, |
|
659 currentlyUsedPlayer, |
|
660 currentlyUsedSubPlayer, |
|
661 subPlayerName ) ); |
|
662 if ( subPlayerName ) |
|
663 { |
|
664 aSubPlayerName = (*subPlayerName); |
|
665 delete subPlayerName; |
|
666 } |
|
667 } |
|
668 //#endif |
|
669 } |
|
670 |
|
671 // ----------------------------------------------------------------------------- |
|
672 // CMPXMediaKeyHandlerImp::SetVolumePopupTitleL |
|
673 // Retrieves the current player name and sets the volume popup title |
|
674 // ----------------------------------------------------------------------------- |
|
675 // |
|
676 void CMPXMediaKeyHandlerImp::SetVolumePopupTitleL() |
|
677 { |
|
678 if ( iUpnpFrameworkSupport && IsUpnpVisibleL() ) |
|
679 { |
|
680 TFileName subPlayerName; |
|
681 TMPXPlaybackPlayerType currentPlayerType = EPbLocal; |
|
682 |
|
683 GetSubPlayerInfoL(subPlayerName, currentPlayerType); |
|
684 if ( currentPlayerType != EPbLocal) |
|
685 { |
|
686 iVolPopup->SetTitleTextL( subPlayerName ); |
|
687 } |
|
688 else // need to restore original title |
|
689 { |
|
690 HBufC* popupText = StringLoader::LoadLC( R_MPX_VOLUME_POPUP_TEXT ); |
|
691 iVolPopup->SetTitleTextL( *popupText ); |
|
692 CleanupStack::PopAndDestroy( popupText ); |
|
693 } |
|
694 } |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // CMPXMediaKeyHandlerImp::IsUpnpVisibleL |
|
699 // Taken from Gallery upnp support implementation |
|
700 // ----------------------------------------------------------------------------- |
|
701 // |
|
702 TBool CMPXMediaKeyHandlerImp::IsUpnpVisibleL() |
|
703 { |
|
704 MPX_FUNC( "CMPXMediaKeyHandlerImp::IsUpnpVisible" ); |
|
705 TBool returnValue = EFalse; |
|
706 #ifdef UPNP_INCLUDED |
|
707 if ( iUpnpCopyCommand && iUpnpFrameworkSupport ) |
|
708 { |
|
709 returnValue = iUpnpCopyCommand->IsAvailableL(); |
|
710 } |
|
711 #endif |
|
712 return returnValue; |
|
713 } |
|
714 |
|
715 // --------------------------------------------------------------------------- |
|
716 // Updates the volume and the volume command |
|
717 // --------------------------------------------------------------------------- |
|
718 // |
|
719 void CMPXMediaKeyHandlerImp::UpdateVolume() |
|
720 { |
|
721 // Current volume level is not yet initialised |
|
722 if( iCurrentVol < 0 ) |
|
723 { |
|
724 MPX_DEBUG1( "CMPXMediaKeyHandlerImp::UpdateVolume not initialised"); |
|
725 return; |
|
726 } |
|
727 |
|
728 if ( iIncreaseVol ) |
|
729 { |
|
730 if ( iMuted ) |
|
731 { |
|
732 iMuted = EFalse; |
|
733 iCommandId = EPbCmdUnMuteVolume; |
|
734 iVolPopup->SetValue( iCurrentVol ); |
|
735 } |
|
736 else |
|
737 { |
|
738 iCommandId = EPbCmdSetVolume; |
|
739 iCurrentVol = iCurrentVol < iVolumeSteps ? (iCurrentVol + 1) : iCurrentVol; // +KMPXVolumeSteps; ? |
|
740 iVolPopup->SetValue( iCurrentVol ); |
|
741 } |
|
742 } |
|
743 else |
|
744 { |
|
745 if ( iCurrentVol == 1 ) |
|
746 { |
|
747 iMuted = ETrue; |
|
748 iCommandId = EPbCmdMuteVolume; |
|
749 iVolPopup->SetValue( 0 ); |
|
750 } |
|
751 else if ( iMuted ) // Muted && volume > 1 |
|
752 { |
|
753 iMuted = EFalse; |
|
754 iCommandId = EPbCmdUnMuteVolume; |
|
755 iVolPopup->SetValue( iCurrentVol ); |
|
756 } |
|
757 else |
|
758 { |
|
759 iCommandId = EPbCmdSetVolume; |
|
760 iCurrentVol = iCurrentVol - 1; // KMPXVolumeSteps ? |
|
761 iVolPopup->SetValue( iCurrentVol ); |
|
762 } |
|
763 } |
|
764 } |
|
765 |
|
766 // --------------------------------------------------------------------------- |
|
767 // From MMPXMediaKeyHandler |
|
768 // Show playback popup. |
|
769 // --------------------------------------------------------------------------- |
|
770 // |
|
771 void CMPXMediaKeyHandlerImp::ShowPlaybackPopupL( |
|
772 TMPXPlaybackPopupModes aMode ) |
|
773 { |
|
774 MPX_FUNC( "CMPXMediaKeyHandlerImp::ShowPlaybackPopupL" ); |
|
775 |
|
776 // Check to see is it ok to display popup |
|
777 if ( !iPlaybackPopup || !iTrackTitle ) |
|
778 { |
|
779 return; |
|
780 } |
|
781 |
|
782 switch ( aMode ) |
|
783 { |
|
784 case EMPXPopupShowIfVisibleRestartTimer: |
|
785 case EMPXPopupTimeout: |
|
786 { |
|
787 iShowPopups &= ~EDisplayMediaPopup; |
|
788 break; |
|
789 } |
|
790 case EMPXPopupNoTimeout: |
|
791 { |
|
792 iShowPopups |= EDisplayMediaPopup; |
|
793 break; |
|
794 } |
|
795 case EMPXPopupShowIfVisible: |
|
796 { |
|
797 if ( iShowPopups & EDisplayMediaPopup ) |
|
798 { |
|
799 aMode = EMPXPopupNoTimeout; |
|
800 } |
|
801 break; |
|
802 } |
|
803 default: |
|
804 { |
|
805 break; |
|
806 } |
|
807 } |
|
808 |
|
809 CMPXNotifierDialog::TMPXPlaybackPopupIcons icon( |
|
810 CMPXNotifierDialog::EMPXPopupNoneIcon ); |
|
811 TMPXPlaybackState playerState( EPbStateNotInitialised ); |
|
812 |
|
813 // Get current playback state from playback utility |
|
814 playerState = iPlaybackUtility->StateL(); |
|
815 switch ( playerState ) |
|
816 { |
|
817 case EPbStatePlaying: |
|
818 { |
|
819 icon = CMPXNotifierDialog::EMPXPopupPlayIcon; |
|
820 break; |
|
821 } |
|
822 case EPbStatePaused: |
|
823 { |
|
824 icon = CMPXNotifierDialog::EMPXPopupPauseIcon; |
|
825 break; |
|
826 } |
|
827 case EPbStateSeekingForward: |
|
828 icon = CMPXNotifierDialog::EMPXPopupFFIcon; |
|
829 break; |
|
830 case EPbStateSeekingBackward: |
|
831 { |
|
832 icon = CMPXNotifierDialog::EMPXPopupFRIcon; |
|
833 break; |
|
834 } |
|
835 case EPbStateStopped: |
|
836 { |
|
837 // no icon if in stopped state |
|
838 break; |
|
839 } |
|
840 default: |
|
841 { |
|
842 // not to display popup in other states |
|
843 return; |
|
844 } |
|
845 } |
|
846 |
|
847 if ( iTrackTitle->Length() ) |
|
848 { |
|
849 MPX_DEBUG2( "CMPXMediaKeyHandlerImp::ShowPlaybackPopupL aMode = %d", aMode ); |
|
850 iPlaybackPopup->ShowInfoPopupL( |
|
851 icon, *iTrackTitle, iSkipping ? KErrNotFound : iPlaybackPosition, aMode ); |
|
852 } |
|
853 } |
|
854 |
|
855 // --------------------------------------------------------------------------- |
|
856 // From MMPXMediaKeyHandler |
|
857 // Show Volume popup |
|
858 // --------------------------------------------------------------------------- |
|
859 // |
|
860 void CMPXMediaKeyHandlerImp::ShowVolumePopupL() |
|
861 { |
|
862 MPX_FUNC( "CMPXMediaKeyHandlerImp::ShowVolumePopupL" ); |
|
863 if ( iVolPopup ) |
|
864 { |
|
865 iShowPopups |= EDisplayVolumePopup; |
|
866 iVolPopup->ShowVolumePopupL(); |
|
867 } |
|
868 } |
|
869 |
|
870 // --------------------------------------------------------------------------- |
|
871 // From MMPXMediaKeyHandler |
|
872 // Dismiss notifier popup. |
|
873 // --------------------------------------------------------------------------- |
|
874 // |
|
875 void CMPXMediaKeyHandlerImp::DismissNotifier( |
|
876 TMPXMediaKeyPopupFlags aFlags ) |
|
877 { |
|
878 MPX_FUNC( "CMPXMediaKeyHandlerImp::DismissNotifier" ); |
|
879 if ( aFlags & EDisplayMediaPopup && iPlaybackPopup ) |
|
880 { |
|
881 iPlaybackPopup->CancelInfoPopup(); |
|
882 iShowPopups &= ~EDisplayMediaPopup; |
|
883 } |
|
884 |
|
885 if ( aFlags & EDisplayVolumePopup && iVolPopup ) |
|
886 { |
|
887 iVolPopup->CloseVolumePopup(); |
|
888 iShowPopups &= ~EDisplayVolumePopup; |
|
889 } |
|
890 } |
|
891 |
|
892 // --------------------------------------------------------------------------- |
|
893 // From MMPXMediaKeyHandler |
|
894 // Enable or disable media keys |
|
895 // --------------------------------------------------------------------------- |
|
896 // |
|
897 void CMPXMediaKeyHandlerImp::SetEnableMediaKeys( TBool aEnable ) |
|
898 { |
|
899 iEnable = aEnable; |
|
900 } |
|
901 |
|
902 // --------------------------------------------------------------------------- |
|
903 // From MMPXMediaKeyHandler |
|
904 // Gets called when orientation change begins |
|
905 // --------------------------------------------------------------------------- |
|
906 // |
|
907 void CMPXMediaKeyHandlerImp::NotifyOrientationChangeBegin() |
|
908 { |
|
909 iPlaybackPopup->NotifyOrientationChangeBegin(); |
|
910 } |
|
911 |
|
912 // From MMPXPlaybackObserver |
|
913 // Handle playback message. |
|
914 // --------------------------------------------------------------------------- |
|
915 // |
|
916 void CMPXMediaKeyHandlerImp::HandlePlaybackMessage( |
|
917 CMPXMessage* aMessage, TInt aError ) |
|
918 { |
|
919 if ( aError == KErrNone && aMessage ) |
|
920 { |
|
921 TRAP_IGNORE( DoHandlePlaybackMessageL( *aMessage ) ); |
|
922 } |
|
923 } |
|
924 |
|
925 // --------------------------------------------------------------------------- |
|
926 // From MMPXPlaybackCallback |
|
927 // Handle playback property. |
|
928 // --------------------------------------------------------------------------- |
|
929 // |
|
930 void CMPXMediaKeyHandlerImp::HandlePropertyL( |
|
931 TMPXPlaybackProperty aProperty, |
|
932 TInt aValue, |
|
933 TInt aError ) |
|
934 { |
|
935 TRAP_IGNORE( DoHandlePropertyL( aProperty, aValue, aError ) ); |
|
936 } |
|
937 |
|
938 // --------------------------------------------------------------------------- |
|
939 // From MMPXPlaybackCallback |
|
940 // Method is called continously until aComplete=ETrue, signifying that |
|
941 // it is done and there will be no more callbacks |
|
942 // Only new items are passed each time |
|
943 // --------------------------------------------------------------------------- |
|
944 // |
|
945 void CMPXMediaKeyHandlerImp::HandleSubPlayerNamesL( |
|
946 TUid /* aPlayer */, |
|
947 const MDesCArray* /* aSubPlayers */, |
|
948 TBool /* aComplete */, |
|
949 TInt /* aError */ ) |
|
950 { |
|
951 MPX_FUNC( "CMPXMediaKeyHandlerImp::HandleSubPlayerNamesL" ); |
|
952 } |
|
953 |
|
954 // --------------------------------------------------------------------------- |
|
955 // From MMPXPlaybackCallback |
|
956 // Handle media properties. |
|
957 // Notes: The client is responsible for delete the object of aMedia. |
|
958 // --------------------------------------------------------------------------- |
|
959 // |
|
960 void CMPXMediaKeyHandlerImp::HandleMediaL( |
|
961 const CMPXMedia& aMedia, |
|
962 TInt aError ) |
|
963 { |
|
964 MPX_FUNC( "CMPXMediaKeyHandlerImp::HandleMediaL" ); |
|
965 TRAP_IGNORE( DoHandleMediaL( aMedia, aError ) ); |
|
966 } |
|
967 |
|
968 // --------------------------------------------------------------------------- |
|
969 // A 'play' command has been received. |
|
970 // --------------------------------------------------------------------------- |
|
971 // |
|
972 void CMPXMediaKeyHandlerImp::MrccatoPlay( |
|
973 TRemConCoreApiPlaybackSpeed /* aSpeed */, |
|
974 TRemConCoreApiButtonAction aButtonAct ) |
|
975 { |
|
976 MPX_DEBUG2( "-->CMPXMediaKeyHandlerImp::MrccatoPlay(aButtonAct=%d)", aButtonAct ); |
|
977 |
|
978 if ( ( aButtonAct == ERemConCoreApiButtonClick ) || |
|
979 ( aButtonAct == ERemConCoreApiButtonPress ) ) |
|
980 { |
|
981 FilterAndSendCommand( EPbCmdPlay ); |
|
982 } |
|
983 iResponseHandler->CompleteAnyKey( ERemConCoreApiPlay ); |
|
984 MPX_DEBUG1( "<--CMPXMediaKeyHandlerImp::MrccatoPlay"); |
|
985 } |
|
986 |
|
987 // --------------------------------------------------------------------------- |
|
988 // A command has been received. |
|
989 // --------------------------------------------------------------------------- |
|
990 // |
|
991 void CMPXMediaKeyHandlerImp::MrccatoCommand( |
|
992 TRemConCoreApiOperationId aOperationId, |
|
993 TRemConCoreApiButtonAction aButtonAct ) |
|
994 { |
|
995 MPX_DEBUG3( "CMPXMediaKeyHandlerImp::MrccatoCommand(aOperationId=%d, aButtonAct=%d)", aOperationId, aButtonAct ); |
|
996 |
|
997 switch (aOperationId) |
|
998 { |
|
999 case ERemConCoreApiPausePlayFunction: |
|
1000 { |
|
1001 if ( aButtonAct == ERemConCoreApiButtonClick ) |
|
1002 { |
|
1003 FilterAndSendCommand( EPbCmdPlayPause ); |
|
1004 } |
|
1005 break; |
|
1006 } |
|
1007 case ERemConCoreApiPlay: |
|
1008 { |
|
1009 if ( ( aButtonAct == ERemConCoreApiButtonClick ) || |
|
1010 ( aButtonAct == ERemConCoreApiButtonPress ) ) |
|
1011 { |
|
1012 FilterAndSendCommand( EPbCmdPlay ); |
|
1013 } |
|
1014 break; |
|
1015 } |
|
1016 case ERemConCoreApiStop: |
|
1017 { |
|
1018 if ( ( aButtonAct == ERemConCoreApiButtonClick ) || |
|
1019 ( aButtonAct == ERemConCoreApiButtonPress ) ) |
|
1020 { |
|
1021 FilterAndSendCommand( EPbCmdStop ); |
|
1022 } |
|
1023 break; |
|
1024 } |
|
1025 case ERemConCoreApiPause: |
|
1026 { |
|
1027 if ( ( aButtonAct == ERemConCoreApiButtonClick ) || |
|
1028 ( aButtonAct == ERemConCoreApiButtonPress ) ) |
|
1029 { |
|
1030 FilterAndSendCommand( EPbCmdPause ); |
|
1031 } |
|
1032 break; |
|
1033 } |
|
1034 case ERemConCoreApiRewind: |
|
1035 { |
|
1036 switch ( aButtonAct ) |
|
1037 { |
|
1038 case ERemConCoreApiButtonPress: |
|
1039 { |
|
1040 FilterAndSendCommand( EPbCmdStartSeekBackward ); |
|
1041 break; |
|
1042 } |
|
1043 case ERemConCoreApiButtonRelease: |
|
1044 { |
|
1045 FilterAndSendCommand( EPbCmdStopSeeking ); |
|
1046 break; |
|
1047 } |
|
1048 default: |
|
1049 { |
|
1050 break; |
|
1051 } |
|
1052 } |
|
1053 break; |
|
1054 } |
|
1055 case ERemConCoreApiFastForward: |
|
1056 { |
|
1057 switch ( aButtonAct ) |
|
1058 { |
|
1059 case ERemConCoreApiButtonPress: |
|
1060 { |
|
1061 FilterAndSendCommand( EPbCmdStartSeekForward ); |
|
1062 break; |
|
1063 } |
|
1064 case ERemConCoreApiButtonRelease: |
|
1065 { |
|
1066 FilterAndSendCommand( EPbCmdStopSeeking ); |
|
1067 break; |
|
1068 } |
|
1069 default: |
|
1070 { |
|
1071 break; |
|
1072 } |
|
1073 } |
|
1074 break; |
|
1075 } |
|
1076 case ERemConCoreApiBackward: |
|
1077 { |
|
1078 if ( aButtonAct == ERemConCoreApiButtonClick ) |
|
1079 { |
|
1080 FilterAndSendCommand( EPbCmdPrevious ); |
|
1081 } |
|
1082 break; |
|
1083 } |
|
1084 case ERemConCoreApiForward: |
|
1085 { |
|
1086 if ( aButtonAct == ERemConCoreApiButtonClick ) |
|
1087 { |
|
1088 FilterAndSendCommand( EPbCmdNext ); |
|
1089 } |
|
1090 break; |
|
1091 } |
|
1092 case ERemConCoreApiVolumeUp: |
|
1093 case ERemConCoreApiVolumeDown: |
|
1094 { |
|
1095 iTimer->Cancel(); |
|
1096 |
|
1097 MMPXPlaybackUtility* pbUtil = MMPXPlaybackUtility::UtilityL( KPbModeActivePlayer ); |
|
1098 CleanupClosePushL(*pbUtil); |
|
1099 |
|
1100 TMPXPlaybackState playerState( EPbStateNotInitialised ); |
|
1101 playerState = pbUtil->StateL(); |
|
1102 |
|
1103 CleanupStack::PopAndDestroy(pbUtil); |
|
1104 |
|
1105 if( playerState == EPbStatePlaying || IsAppForeground() ) |
|
1106 { |
|
1107 iIncreaseVol = (aOperationId == ERemConCoreApiVolumeUp ? ETrue: EFalse); |
|
1108 switch (aButtonAct) |
|
1109 { |
|
1110 case ERemConCoreApiButtonPress: |
|
1111 { |
|
1112 //Start Timer |
|
1113 iTimer->Start( |
|
1114 KFirstTimerExpiryInterval, |
|
1115 KTimerExpiryInterval, |
|
1116 TCallBack( TimerCallback, this ) ); |
|
1117 break; |
|
1118 } |
|
1119 case ERemConCoreApiButtonClick: |
|
1120 { |
|
1121 UpdateVolume(); |
|
1122 FilterAndSendCommand( iCommandId ); |
|
1123 break; |
|
1124 } |
|
1125 case ERemConCoreApiButtonRelease: |
|
1126 default: |
|
1127 { |
|
1128 break; |
|
1129 } |
|
1130 } |
|
1131 } |
|
1132 break; |
|
1133 } |
|
1134 default: |
|
1135 { |
|
1136 break; |
|
1137 } |
|
1138 } |
|
1139 iResponseHandler->CompleteAnyKey( aOperationId ); |
|
1140 MPX_DEBUG1( "<--CMPXMediaKeyHandlerImp::MrccatoCommand"); |
|
1141 } |
|
1142 |
|
1143 // --------------------------------------------------------------------------- |
|
1144 // A 'tune function' command has been received. |
|
1145 // --------------------------------------------------------------------------- |
|
1146 // |
|
1147 void CMPXMediaKeyHandlerImp::MrccatoTuneFunction( |
|
1148 TBool /* aTwoPart */, |
|
1149 TUint /* aMajorChannel */, |
|
1150 TUint /* aMinorChannel */, |
|
1151 TRemConCoreApiButtonAction /* aButtonAct */ ) |
|
1152 { |
|
1153 iResponseHandler->CompleteAnyKey( |
|
1154 ERemConCoreApiTuneFunction ); |
|
1155 } |
|
1156 |
|
1157 // --------------------------------------------------------------------------- |
|
1158 // A 'select disk function' has been received. |
|
1159 // --------------------------------------------------------------------------- |
|
1160 // |
|
1161 void CMPXMediaKeyHandlerImp::MrccatoSelectDiskFunction( |
|
1162 TUint /* aDisk */, |
|
1163 TRemConCoreApiButtonAction /* aButtonAct */ ) |
|
1164 { |
|
1165 iResponseHandler->CompleteAnyKey( |
|
1166 ERemConCoreApiSelectDiskFunction ); |
|
1167 } |
|
1168 |
|
1169 // --------------------------------------------------------------------------- |
|
1170 // A 'select AV input function' has been received. |
|
1171 // --------------------------------------------------------------------------- |
|
1172 // |
|
1173 void CMPXMediaKeyHandlerImp::MrccatoSelectAvInputFunction( |
|
1174 TUint8 /* aAvInputSignalNumber */, |
|
1175 TRemConCoreApiButtonAction /* aButtonAct */ ) |
|
1176 { |
|
1177 iResponseHandler->CompleteAnyKey( |
|
1178 ERemConCoreApiSelectAvInputFunction ); |
|
1179 } |
|
1180 |
|
1181 // --------------------------------------------------------------------------- |
|
1182 // A 'select audio input function' has been received. |
|
1183 // --------------------------------------------------------------------------- |
|
1184 // |
|
1185 void CMPXMediaKeyHandlerImp::MrccatoSelectAudioInputFunction( |
|
1186 TUint8 /* aAudioInputSignalNumber */, |
|
1187 TRemConCoreApiButtonAction /* aButtonAct */ ) |
|
1188 { |
|
1189 iResponseHandler->CompleteAnyKey( |
|
1190 ERemConCoreApiSelectAudioInputFunction ); |
|
1191 } |
|
1192 |
|
1193 // ---------------------------------------------------------------------------- |
|
1194 // void CMPlayerBaseView::HandleControlEventL |
|
1195 // ---------------------------------------------------------------------------- |
|
1196 // |
|
1197 void CMPXMediaKeyHandlerImp::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ) |
|
1198 { |
|
1199 if ( !AknLayoutUtils::PenEnabled() ) |
|
1200 { |
|
1201 return; |
|
1202 } |
|
1203 |
|
1204 if( (aEventType == EEventStateChanged) && (aControl == iVolPopup) ) |
|
1205 { |
|
1206 TInt vol = iVolPopup->Value(); |
|
1207 if ( vol == iCurrentVol ) |
|
1208 { |
|
1209 if ( iMuted ) |
|
1210 { |
|
1211 iMuted = EFalse; |
|
1212 FilterAndSendCommand( EPbCmdUnMuteVolume ); |
|
1213 iTouchVolEventCount++; |
|
1214 } |
|
1215 else |
|
1216 { |
|
1217 return; |
|
1218 } |
|
1219 } |
|
1220 |
|
1221 if ( vol == 0 ) |
|
1222 { |
|
1223 if ( iMuted ) |
|
1224 { |
|
1225 return; |
|
1226 } |
|
1227 else |
|
1228 { |
|
1229 iMuted = ETrue; |
|
1230 FilterAndSendCommand( EPbCmdMuteVolume ); |
|
1231 iTouchVolEventCount++; |
|
1232 } |
|
1233 } |
|
1234 else |
|
1235 { |
|
1236 if ( iMuted ) |
|
1237 { |
|
1238 iMuted = EFalse; |
|
1239 iVolPopup->SetValue( iCurrentVol ); |
|
1240 FilterAndSendCommand( EPbCmdUnMuteVolume ); |
|
1241 iTouchVolEventCount++; |
|
1242 } |
|
1243 else |
|
1244 { |
|
1245 iCurrentVol = vol; |
|
1246 FilterAndSendCommand( EPbCmdSetVolume ); |
|
1247 iTouchVolEventCount++; |
|
1248 } |
|
1249 } |
|
1250 } |
|
1251 } |
|
1252 |
|
1253 // --------------------------------------------------------------------------- |
|
1254 // Check the mpx app is foreground. |
|
1255 // --------------------------------------------------------------------------- |
|
1256 // |
|
1257 TBool CMPXMediaKeyHandlerImp::IsAppForeground() |
|
1258 { |
|
1259 TBool isForeground( EFalse ); |
|
1260 // Gets the window group id of the app in foreground |
|
1261 RWsSession& wsSession = CCoeEnv::Static()->WsSession(); |
|
1262 TInt windowGroupId = wsSession.GetFocusWindowGroup(); |
|
1263 if ( windowGroupId >= 0 ) |
|
1264 { |
|
1265 TRAP_IGNORE( |
|
1266 { |
|
1267 CApaWindowGroupName* wgName = CApaWindowGroupName::NewL( |
|
1268 wsSession, windowGroupId ); |
|
1269 |
|
1270 isForeground = ( wgName->AppUid() == KAppUidMusicPlayerX ); |
|
1271 delete wgName; |
|
1272 } ); |
|
1273 } |
|
1274 |
|
1275 return isForeground; |
|
1276 } |
|
1277 // End of File |