|
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: Music Player upnp playback dialog implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <aknViewAppUi.h> |
|
22 #include <StringLoader.h> |
|
23 #include <akntitle.h> |
|
24 #include <aknnotewrappers.h> |
|
25 #include <aknnavide.h> |
|
26 #include <aknnavilabel.h> |
|
27 #include <coeutils.h> |
|
28 #include <hlplch.h> |
|
29 #include <bautils.h> |
|
30 #include <centralrepository.h> |
|
31 #include <bldvariant.hrh> |
|
32 #include <caf/caferr.h> |
|
33 #include <aknsoundsystem.h> |
|
34 #include <apgcli.h> // RApaLsSession |
|
35 #include <ctsydomainpskeys.h> |
|
36 |
|
37 #include <featmgr.h> |
|
38 #include <hwrmfmtx.h> // TFmTxState, for FF_FMTX |
|
39 |
|
40 #ifdef __SERIES60_31__ |
|
41 #include <upnpnetworkaccess.h> // KCRUidUPnPApplication, KUPnPAppAccessPoint |
|
42 #else |
|
43 #include <upnpsettings.h> |
|
44 #endif |
|
45 |
|
46 #include <mpxcollectionmessage.h> |
|
47 #include <mpxcollectionutility.h> |
|
48 #include <mpxmediakeyhandler.h> |
|
49 |
|
50 #include <data_caging_path_literals.hrh> |
|
51 #include <layoutmetadata.cdl.h> |
|
52 #include <mpxcommonplaybackview.rsg> |
|
53 #include <mpxplaybackutility.h> |
|
54 #include <mpxplaybackmessage.h> |
|
55 #include <mpxmessagegeneraldefs.h> // KMPXMessageGeneralId |
|
56 #include <mpxplaybackmessagedefs.h> // KMPXMessagePbMediaChanged, KMPXMessagePbMedia |
|
57 #include <mpxcollectionplaylist.h> |
|
58 #include <mpxcollectionpath.h> |
|
59 #include <mpxviewutility.h> |
|
60 #include <mpxmusicplayerviewplugin.hrh> |
|
61 #include <mpxmedia.h> |
|
62 #include <mpxmediaarray.h> |
|
63 #include <mpxmediageneraldefs.h> |
|
64 #include <mpxmediamusicdefs.h> |
|
65 #include <mpxmediadrmdefs.h> |
|
66 #include <mpxmediacontainerdefs.h> |
|
67 #include <mpxcollectionutility.h> |
|
68 #include <mpxcollectionhelperfactory.h> |
|
69 #include <mpxcommandgeneraldefs.h> |
|
70 |
|
71 |
|
72 #include <mpxconstants.h> |
|
73 #include <mpxappui.hrh> |
|
74 #include "mpxcommonplaybackview.hrh" |
|
75 #include "mpxalbumartutil.h" |
|
76 #include "mpxcommonuihelper.h" |
|
77 #include <mpxinternalcrkeys.h> |
|
78 #include <mpxtlshelper.h> |
|
79 #include <mpxlog.h> |
|
80 #include <mpxuser.h> |
|
81 #include <akntoolbar.h> |
|
82 #include <aknbutton.h> |
|
83 |
|
84 #include "mpxupnpplaybackdialog.hrh" |
|
85 #include "mpxupnpplaybackdialogcustomcontrol.h" |
|
86 #include <mpxupnpplaybackview.rsg> |
|
87 #include "mpxupnpplaybackdialogcustomcontrolcontainer.h" |
|
88 #include "mpxupnpplaybackdialog.h" |
|
89 #include "mpxupnpplaybackdialoglayout.h" |
|
90 #include <mpxupnpplaybackdialog.rsg> |
|
91 |
|
92 // CONSTANTS |
|
93 const TInt KMPXOneSecInMilliSecs( 1000 ); |
|
94 |
|
95 _LIT( KMPXUPnPPlaybackDialogRscPath, "mpxUpnpPlaybackdialog.rsc" ); |
|
96 _LIT( KMPXCommonPlaybackRscPath, "mpxcommonplaybackview.rsc" ); |
|
97 _LIT( KMPXUpnpPlaybackRscPath, "mpxupnpplaybackview.rsc" ); |
|
98 |
|
99 _LIT( KMPXFMTXRscPath, "mpxfmtx.rsc" ); // For FF_FMTX |
|
100 |
|
101 #ifdef RD_RA_SUPPORT_FOR_MUSIC_PLAYER |
|
102 _LIT(KMPXPnRealAudioMimeType, "audio/x-pn-realaudio"); |
|
103 _LIT(KMPXRealAudioMimeType, "audio/x-realaudio"); |
|
104 _LIT(KMPXRnRealAudioMimeType, "audio/vnd.rn-realaudio"); |
|
105 #endif |
|
106 |
|
107 // ============================ MEMBER FUNCTIONS =============================== |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CMPXUPnPPlaybackDialog::NewL |
|
111 // Two-phased constructor. |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 EXPORT_C CMPXUPnPPlaybackDialog* CMPXUPnPPlaybackDialog::NewL() |
|
115 { |
|
116 MPX_FUNC( "CMPXUPnPPlaybackDialog::NewL" ); |
|
117 CMPXUPnPPlaybackDialog* self = |
|
118 new ( ELeave ) CMPXUPnPPlaybackDialog(); |
|
119 CleanupStack::PushL( self ); |
|
120 self->ConstructL( R_MPX_CUI_UPNP_PLAYBACK_DIALOG_MENUBAR ); |
|
121 CleanupStack::Pop( self ); // this, it will be PushL-d by executeLD... |
|
122 return self; |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CMPXUPnPPlaybackDialog::CMPXUPnPPlaybackDialog |
|
127 // C++ default constructor can NOT contain any code, that |
|
128 // might leave. |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 CMPXUPnPPlaybackDialog::CMPXUPnPPlaybackDialog() |
|
132 { |
|
133 } |
|
134 |
|
135 // ---------------------------------------------------------------------------- |
|
136 // CMPXUPnPPlaybackDialog::SetParamL |
|
137 // parameter passed in from viewframework |
|
138 // ---------------------------------------------------------------------------- |
|
139 // |
|
140 EXPORT_C void CMPXUPnPPlaybackDialog::SetParamL( const TDesC* /*aParam*/ ) |
|
141 { |
|
142 MPX_FUNC( "CMPXUPnPPlaybackDialog::SetParamL" ); |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CMPXUPnPPlaybackDialog::ConstructL |
|
147 // (other items were commented in a header). |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CMPXUPnPPlaybackDialog::ConstructL( TInt aResource ) |
|
151 { |
|
152 MPX_FUNC( "CMPXUPnPPlaybackDialog::ConstructL" ); |
|
153 CCoeEnv* coeEnv = iEikonEnv; |
|
154 TParse parse; |
|
155 parse.Set( KMPXUPnPPlaybackDialogRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
156 TFileName resourceFile( parse.FullName() ); |
|
157 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
158 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
159 iResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
160 |
|
161 parse.Set( KMPXCommonPlaybackRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
162 TFileName playbackResourceFile( parse.FullName() ); |
|
163 User::LeaveIfError( MPXUser::CompleteWithDllPath( playbackResourceFile ) ); |
|
164 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), playbackResourceFile ); |
|
165 iCommonPlaybackResourceOffset = coeEnv->AddResourceFileL( playbackResourceFile ); |
|
166 |
|
167 parse.Set( KMPXUpnpPlaybackRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
168 TFileName upnpResourceFile = parse.FullName(); |
|
169 User::LeaveIfError( MPXUser::CompleteWithDllPath( upnpResourceFile ) ); |
|
170 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), upnpResourceFile ); |
|
171 iUpnpResourceOffset = coeEnv->AddResourceFileL( upnpResourceFile ); |
|
172 |
|
173 // CommonPlaybackViewLayout uses this rsc file so it needs to be loaded |
|
174 if ( FeatureManager::FeatureSupported( KFeatureIdFmtx ) ) |
|
175 { |
|
176 parse.Set( KMPXFMTXRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
177 TFileName fmtxResourceFile( parse.FullName() ); |
|
178 User::LeaveIfError( MPXUser::CompleteWithDllPath( fmtxResourceFile ) ); |
|
179 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), fmtxResourceFile ); |
|
180 iFMTXResourceOffset = coeEnv->AddResourceFileL( fmtxResourceFile ); |
|
181 } |
|
182 |
|
183 // Get the playback utility instance from engine. |
|
184 iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault ); |
|
185 iPlaybackUtility->AddObserverL( *this ); |
|
186 |
|
187 iMPXUtility = CMPXAlbumArtUtil::NewL(); |
|
188 iCommonUiHelper = CMPXCommonUiHelper::NewL(); |
|
189 |
|
190 iEmbedded = iEikonEnv->StartedAsServerApp(); |
|
191 |
|
192 // Get an instance of view utility |
|
193 iViewUtility = MMPXViewUtility::UtilityL(); |
|
194 |
|
195 TInt flags( 0 ); |
|
196 CRepository* repository( CRepository::NewL( KCRUidMPXMPFeatures )); |
|
197 User::LeaveIfError( repository->Get( KMPXMPLocalVariation, flags )); |
|
198 delete repository; |
|
199 repository = NULL; |
|
200 |
|
201 iChangeRTForAllProfiles = |
|
202 static_cast<TBool>( flags & KMPXChangeRTForAll ); |
|
203 |
|
204 iCollectionUtility = MMPXCollectionUtility::NewL(); |
|
205 |
|
206 iStartPlaybackIndex = KErrNotFound; |
|
207 iLastSkipDirection = 1; |
|
208 |
|
209 if ( !iMediaKeyHandler ) |
|
210 { |
|
211 // Handle media key in appui |
|
212 iMediaKeyHandler = MMPXMediaKeyHandler::NewL( |
|
213 EDisplayVolumePopup | EDisplayMediaPopup, |
|
214 this ); |
|
215 } |
|
216 |
|
217 CAknDialog::ConstructL( aResource ); |
|
218 if ( AknLayoutUtils::PenEnabled()) |
|
219 { |
|
220 CAknAppUi* appUi = static_cast<CAknAppUi*>( CCoeEnv::Static()->AppUi()); |
|
221 iToolbar = appUi->CurrentFixedToolbar(); |
|
222 if ( iToolbar ) |
|
223 { |
|
224 iBtnPreviousItem = |
|
225 CAknButton::NewL( R_MPX_PBV_TOUCH_TOOLBAR_PREVIOUS_ITEM_BTN ); |
|
226 iBtnNextItem = |
|
227 CAknButton::NewL( R_MPX_PBV_TOUCH_TOOLBAR_NEXT_ITEM_BTN ); |
|
228 iBtnPlayPause = |
|
229 CAknButton::NewL( R_MPX_PBV_TOUCH_TOOLBAR_PLAYPAUSE_BTN ); |
|
230 |
|
231 iToolbar->AddItemL( iBtnPreviousItem, EAknCtButton, |
|
232 EMPXPbvCmdPreviousListItem, KAknButtonReportOnLongPress ); |
|
233 iToolbar->AddItemL( iBtnPlayPause, EAknCtButton, |
|
234 EMPXPbvCmdPlayPause, 0 ); |
|
235 iToolbar->AddItemL( iBtnNextItem, EAknCtButton, |
|
236 EMPXPbvCmdNextListItem, KAknButtonReportOnLongPress ); |
|
237 |
|
238 iToolbar->SetToolbarVisibility( ETrue ); |
|
239 iToolbar->SetToolbarObserver( this ); |
|
240 } |
|
241 } |
|
242 } |
|
243 // --------------------------------------------------------------------------- |
|
244 // Destructor |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 EXPORT_C CMPXUPnPPlaybackDialog::~CMPXUPnPPlaybackDialog() |
|
248 { |
|
249 MPX_FUNC( "CMPXUPnPPlaybackDialog::~CMPXUPnPPlaybackDialog" ); |
|
250 |
|
251 delete iMPXUtility; |
|
252 delete iMedia; |
|
253 delete iCommonUiHelper; |
|
254 |
|
255 if ( iPlaybackUtility ) |
|
256 { |
|
257 TRAP_IGNORE( iPlaybackUtility->RemoveObserverL( *this ) ); |
|
258 iPlaybackUtility->Close(); |
|
259 } |
|
260 |
|
261 if ( iViewUtility ) |
|
262 { |
|
263 iViewUtility->Close(); |
|
264 } |
|
265 |
|
266 if ( iResourceOffset ) |
|
267 { |
|
268 iEikonEnv->DeleteResourceFile( iResourceOffset ); |
|
269 } |
|
270 |
|
271 if ( iCommonPlaybackResourceOffset ) |
|
272 { |
|
273 iEikonEnv->DeleteResourceFile( iCommonPlaybackResourceOffset ); |
|
274 } |
|
275 |
|
276 iPlayersList.Close(); |
|
277 delete iSubPlayerName; |
|
278 |
|
279 if ( iUpnpResourceOffset ) |
|
280 { |
|
281 iEikonEnv->DeleteResourceFile( iUpnpResourceOffset ); |
|
282 } |
|
283 |
|
284 if ( iFMTXResourceOffset ) |
|
285 { |
|
286 iEikonEnv->DeleteResourceFile( iFMTXResourceOffset ); |
|
287 } |
|
288 |
|
289 if ( iCollectionUtility ) |
|
290 { |
|
291 iCollectionUtility->Close(); |
|
292 } |
|
293 |
|
294 if ( iKeySoundDisabled ) |
|
295 { |
|
296 iAvkonAppUi->KeySounds()->PopContext(); |
|
297 } |
|
298 delete iOrigTitle; |
|
299 delete iPlaybackDialogLayout; |
|
300 |
|
301 delete iMediaKeyHandler; |
|
302 |
|
303 if ( iDelayedEventExit ) |
|
304 { |
|
305 iDelayedEventExit->Cancel(); |
|
306 } |
|
307 delete iDelayedEventExit; |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // Updates playback view. |
|
312 // --------------------------------------------------------------------------- |
|
313 // |
|
314 void CMPXUPnPPlaybackDialog::UpdateViewL() |
|
315 { |
|
316 MPX_FUNC( "CMPXUPnPPlaybackDialog::UpdateViewL" ); |
|
317 |
|
318 if ( GetUPnPPlaybackDialogCustomControl() && !iSwitchingView ) |
|
319 { |
|
320 UpdatePlaybackState( iPlaybackState ); |
|
321 UpdateTrackInfoL( iMedia ); |
|
322 UpdateTrackPlaybackPositionL( iPosition, iDuration ); |
|
323 UpdateTrackPosInPlaylistL(); |
|
324 UpdateAlbumArtL( iMedia ); |
|
325 UpdateDownloadStateLabelL(); |
|
326 |
|
327 // Retrieve current repeat & random modes |
|
328 iPlaybackUtility->PropertyL( *this, EPbPropertyRandomMode ); |
|
329 iPlaybackUtility->PropertyL( *this, EPbPropertyRepeatMode ); |
|
330 iPlaybackUtility->PropertyL( *this, EPbPropertyVolume); |
|
331 } |
|
332 } |
|
333 |
|
334 // --------------------------------------------------------------------------- |
|
335 // Updates track info field. |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 void CMPXUPnPPlaybackDialog::UpdateTrackInfoL( |
|
339 const CMPXMedia* aMedia ) |
|
340 { |
|
341 MPX_FUNC( "CMPXUPnPPlaybackDialog::UpdateTrackInfo" ); |
|
342 |
|
343 if ( GetUPnPPlaybackDialogCustomControl() && !iSwitchingView ) |
|
344 { |
|
345 if ( aMedia ) |
|
346 { |
|
347 if ( aMedia->IsSupported( KMPXMediaGeneralTitle ) ) |
|
348 { |
|
349 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
350 ETextTrack, |
|
351 aMedia->ValueText( KMPXMediaGeneralTitle ) ); |
|
352 } |
|
353 else if ( aMedia->IsSupported( KMPXMediaGeneralUri ) ) |
|
354 { |
|
355 TParsePtrC filePath( |
|
356 aMedia->ValueText( KMPXMediaGeneralUri ) ); |
|
357 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
358 ETextTrack, filePath.Name() ); |
|
359 } |
|
360 else |
|
361 { |
|
362 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
363 ETextTrack, KNullDesC ); |
|
364 } |
|
365 |
|
366 if ( aMedia->IsSupported( KMPXMediaMusicArtist ) ) |
|
367 { |
|
368 const TDesC& artist = |
|
369 aMedia->ValueText( KMPXMediaMusicArtist ); |
|
370 if ( artist != KNullDesC ) |
|
371 { |
|
372 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
373 ETextArtist, |
|
374 artist ); |
|
375 } |
|
376 else |
|
377 { |
|
378 if ( !iSkipping ) |
|
379 { |
|
380 // Display unknown artist as artist |
|
381 HBufC* unknownArtistText = |
|
382 StringLoader::LoadLC( R_MPX_PBV_UNKNOWN_ARTIST_LABEL ); |
|
383 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
384 ETextArtist, *unknownArtistText ); |
|
385 CleanupStack::PopAndDestroy( unknownArtistText ); |
|
386 } |
|
387 else |
|
388 { |
|
389 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
390 ETextArtist, KNullDesC ); |
|
391 } |
|
392 } |
|
393 } |
|
394 else |
|
395 { |
|
396 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
397 ETextArtist, KNullDesC ); |
|
398 } |
|
399 |
|
400 #ifdef RD_RA_SUPPORT_FOR_MUSIC_PLAYER |
|
401 if ( aMedia->IsSupported( KMPXMediaGeneralMimeType ) ) |
|
402 { |
|
403 // Get mime type |
|
404 const TDesC& mimeType = aMedia->ValueText( |
|
405 KMPXMediaGeneralMimeType ); |
|
406 |
|
407 const TBool realAudioMode = |
|
408 ( mimeType.Compare( KMPXPnRealAudioMimeType ) == 0 ) || |
|
409 ( mimeType.Compare( KMPXRealAudioMimeType ) == 0) || |
|
410 ( mimeType.Compare( KMPXRnRealAudioMimeType ) == 0 ); |
|
411 |
|
412 MPX_DEBUG2("CMPXUPnPPlaybackDialog::UpdateTrackInfoL() mimeType: %S", &mimeType); |
|
413 // Set the real audio mode |
|
414 GetUPnPPlaybackDialogCustomControl()->SetRealAudioMode( realAudioMode ); |
|
415 } |
|
416 else |
|
417 { |
|
418 GetUPnPPlaybackDialogCustomControl()->SetRealAudioMode( EFalse ); |
|
419 } |
|
420 #endif |
|
421 } |
|
422 else |
|
423 { |
|
424 // Display nothing if properties is NULL |
|
425 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
426 ETextTrack, KNullDesC ); |
|
427 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
428 ETextArtist, KNullDesC ); |
|
429 } |
|
430 } |
|
431 } |
|
432 |
|
433 // --------------------------------------------------------------------------- |
|
434 // Update current playback state. |
|
435 // --------------------------------------------------------------------------- |
|
436 // |
|
437 void CMPXUPnPPlaybackDialog::UpdatePlaybackState( |
|
438 TMPXPlaybackState aPlaybackState ) |
|
439 { |
|
440 MPX_FUNC( "CMPXUPnPPlaybackDialog::UpdatePlaybackState()" ); |
|
441 MPX_DEBUG2("CMPXUPnPPlaybackDialog::UpdatePlaybackState(%d): Entering", aPlaybackState); |
|
442 |
|
443 if ( GetUPnPPlaybackDialogCustomControl() && !iSwitchingView ) |
|
444 { |
|
445 TMPXPbvPlaybackMode mode( EInvalidMode ); |
|
446 |
|
447 switch ( aPlaybackState ) |
|
448 { |
|
449 case EPbStateNotInitialised: |
|
450 { |
|
451 mode = ENoTracksMode; |
|
452 break; |
|
453 } |
|
454 case EPbStateInitialising: |
|
455 case EPbStateDownloading: |
|
456 { |
|
457 mode = EInitialising; |
|
458 break; |
|
459 } |
|
460 case EPbStatePlaying: |
|
461 { |
|
462 mode = EPlayMode; |
|
463 break; |
|
464 } |
|
465 case EPbStatePaused: |
|
466 { |
|
467 mode = EPauseMode; |
|
468 break; |
|
469 } |
|
470 case EPbStateStopped: |
|
471 { |
|
472 mode = EStopMode; |
|
473 break; |
|
474 } |
|
475 default: |
|
476 { |
|
477 // Pass |
|
478 break; |
|
479 } |
|
480 } |
|
481 |
|
482 if ( EInvalidMode != mode ) |
|
483 { |
|
484 iPlaybackState = aPlaybackState; |
|
485 GetUPnPPlaybackDialogCustomControl()->SetMode( mode ); |
|
486 } |
|
487 |
|
488 GetUPnPPlaybackDialogCustomControl()->UpdateButtons( aPlaybackState ); |
|
489 UpdateToolbar(); |
|
490 } |
|
491 else |
|
492 { |
|
493 // If no container, just need to update state |
|
494 switch ( aPlaybackState ) |
|
495 { |
|
496 case EPbStateNotInitialised: |
|
497 case EPbStateInitialising: |
|
498 case EPbStateDownloading: |
|
499 case EPbStatePlaying: |
|
500 case EPbStatePaused: |
|
501 case EPbStateStopped: |
|
502 { |
|
503 iPlaybackState = aPlaybackState; |
|
504 break; |
|
505 } |
|
506 default: |
|
507 { |
|
508 // Pass |
|
509 // Ignore other state changes such as skipping, etc. |
|
510 break; |
|
511 } |
|
512 } |
|
513 } |
|
514 } |
|
515 |
|
516 // --------------------------------------------------------------------------- |
|
517 // Updates track's playback position. |
|
518 // --------------------------------------------------------------------------- |
|
519 // |
|
520 void CMPXUPnPPlaybackDialog::UpdateTrackPlaybackPositionL( |
|
521 TInt aPos, |
|
522 TInt aDuration ) |
|
523 { |
|
524 MPX_FUNC( "CMPXUPnPPlaybackDialog::UpdateTrackPlaybackPosition" ); |
|
525 |
|
526 if ( GetUPnPPlaybackDialogCustomControl() && !iSwitchingView ) |
|
527 { |
|
528 if ( aPos > aDuration ) |
|
529 { |
|
530 aPos = aDuration; |
|
531 } |
|
532 switch ( iPlaybackState ) |
|
533 { |
|
534 case EPbStatePaused: |
|
535 case EPbStatePlaying: |
|
536 { |
|
537 GetUPnPPlaybackDialogCustomControl()->UpdateTimeIndicatorsL( aPos, aDuration ); |
|
538 break; |
|
539 } |
|
540 case EPbStateStopped: |
|
541 { |
|
542 GetUPnPPlaybackDialogCustomControl()->UpdateTimeIndicatorsL( aPos, aDuration ); |
|
543 } // falls through |
|
544 case EPbStateNotInitialised: |
|
545 { |
|
546 GetUPnPPlaybackDialogCustomControl()->UpdateDurationLabelL( aDuration ); |
|
547 break; |
|
548 } |
|
549 default: |
|
550 { |
|
551 // Do nothing |
|
552 break; |
|
553 } |
|
554 } |
|
555 } |
|
556 } |
|
557 |
|
558 // --------------------------------------------------------------------------- |
|
559 // Updates track's album art. |
|
560 // --------------------------------------------------------------------------- |
|
561 // |
|
562 void CMPXUPnPPlaybackDialog::UpdateAlbumArtL( |
|
563 const CMPXMedia* aMedia ) |
|
564 { |
|
565 MPX_FUNC( "CMPXUPnPPlaybackDialog::UpdateAlbumArt" ); |
|
566 |
|
567 if ( GetUPnPPlaybackDialogCustomControl() && !iSwitchingView ) |
|
568 { |
|
569 TInt err( KErrNone ); |
|
570 if ( aMedia ) |
|
571 { |
|
572 TRect albumArtRect( |
|
573 iPlaybackDialogLayout->IndicatorLayout( |
|
574 iModRect, EAlbumArtArea ) ); |
|
575 |
|
576 MPX_TRAP( err, |
|
577 iMPXUtility->ExtractAlbumArtL( |
|
578 *aMedia, |
|
579 *GetUPnPPlaybackDialogCustomControl(), |
|
580 albumArtRect.Size() ); ); |
|
581 } |
|
582 |
|
583 if ( !aMedia || KErrNone != err ) |
|
584 { |
|
585 // If error, show default album art |
|
586 MPX_DEBUG2("CMPXUPnPPlaybackDialog::UpdateAlbumArt(): err = %d", err); |
|
587 GetUPnPPlaybackDialogCustomControl()->ExtractAlbumArtCompleted( NULL, KErrNone ); |
|
588 } |
|
589 } |
|
590 } |
|
591 |
|
592 // --------------------------------------------------------------------------- |
|
593 // Updates track position in playlist field. |
|
594 // --------------------------------------------------------------------------- |
|
595 // |
|
596 void CMPXUPnPPlaybackDialog::UpdateTrackPosInPlaylistL() |
|
597 { |
|
598 MPX_FUNC( "CMPXUPnPPlaybackDialog::UpdateTrackPosInPlaylist" ); |
|
599 |
|
600 if ( GetUPnPPlaybackDialogCustomControl() && !iSwitchingView ) |
|
601 { |
|
602 TBool emptyCount( EFalse ); |
|
603 TInt count( 0 ); |
|
604 TInt index( 0 ); |
|
605 |
|
606 MMPXSource* s = iPlaybackUtility->Source(); |
|
607 if ( s ) |
|
608 { |
|
609 CMPXCollectionPlaylist* playlist = s->PlaylistL(); |
|
610 if ( playlist ) |
|
611 { |
|
612 count = playlist->Count(); |
|
613 index = playlist->Index(); |
|
614 delete playlist; |
|
615 playlist = NULL; |
|
616 } |
|
617 } |
|
618 MPX_DEBUG3("CMPXUPnPPlaybackDialog::UpdateTrackPosInPlaylistL: index = %d, count = %d", index, count ); |
|
619 |
|
620 // not display for progressive mode & embedded track mode |
|
621 TMPXLaunchMode mode = MPXTlsHelper::LaunchMode(); |
|
622 |
|
623 if ( count ) |
|
624 { |
|
625 if ( EMPXLaunchModeTrack != mode ) |
|
626 { |
|
627 // Current index (1-based) if playlist is non-empty |
|
628 // Magic: array granularity |
|
629 CArrayFixFlat<TInt>* params = |
|
630 new ( ELeave ) CArrayFixFlat<TInt>( 2 ); |
|
631 CleanupStack::PushL( params ); |
|
632 params->AppendL( index + 1 ); |
|
633 params->AppendL( count ); |
|
634 HBufC* plcounter = StringLoader::LoadLC( |
|
635 R_MPX_PBV_PLAYLIST_ITEM_COUNTER_LABEL, *params ); |
|
636 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
637 ETextPlaylistCount, |
|
638 *plcounter ); |
|
639 CleanupStack::PopAndDestroy( plcounter ); |
|
640 CleanupStack::PopAndDestroy( params ); |
|
641 } |
|
642 else |
|
643 { |
|
644 emptyCount = ETrue; |
|
645 } |
|
646 } |
|
647 else |
|
648 { |
|
649 emptyCount = ETrue; |
|
650 |
|
651 // Display empty state text |
|
652 HBufC* noTracksText = |
|
653 StringLoader::LoadLC( R_MPX_PBV_NO_TRACKS_LABEL ); |
|
654 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
655 ETextEmpty, *noTracksText ); |
|
656 CleanupStack::PopAndDestroy( noTracksText ); |
|
657 } |
|
658 |
|
659 if ( emptyCount ) |
|
660 { |
|
661 // Empty string if playlist is empty |
|
662 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
663 ETextPlaylistCount, |
|
664 KNullDesC ); |
|
665 } |
|
666 } |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // Updates download state label. |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 void CMPXUPnPPlaybackDialog::UpdateDownloadStateLabelL() |
|
674 { |
|
675 MPX_FUNC( "CMPXCommonPlaybackViewImp::UpdateDownloadStateLabelL" ); |
|
676 |
|
677 if ( GetUPnPPlaybackDialogCustomControl() && !iSwitchingView ) |
|
678 { |
|
679 switch ( iPlaybackState ) |
|
680 { |
|
681 case EPbStateInitialising: |
|
682 case EPbStateDownloading: |
|
683 { |
|
684 HBufC* labelText( |
|
685 StringLoader::LoadLC( R_MPX_PBV_SONG_OPENING_LABEL )); |
|
686 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
687 ETextDownloadState, *labelText ); |
|
688 CleanupStack::PopAndDestroy( labelText ); |
|
689 break; |
|
690 } |
|
691 default: |
|
692 { |
|
693 GetUPnPPlaybackDialogCustomControl()->UpdateLabelL( |
|
694 ETextDownloadState, KNullDesC ); |
|
695 break; |
|
696 } |
|
697 } |
|
698 } |
|
699 } |
|
700 |
|
701 // --------------------------------------------------------------------------- |
|
702 // Updates Title Pane. |
|
703 // --------------------------------------------------------------------------- |
|
704 // |
|
705 void CMPXUPnPPlaybackDialog::UpdateTitlePaneL() |
|
706 { |
|
707 MPX_FUNC( "CMPXUPnPPlaybackDialog::UpdateTitlePaneL" ); |
|
708 |
|
709 CAknTitlePane* title( NULL ); |
|
710 |
|
711 TRAP_IGNORE( |
|
712 { |
|
713 title = static_cast<CAknTitlePane*> |
|
714 ( iAvkonAppUi->StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
715 } ); |
|
716 |
|
717 MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager(); |
|
718 TUid currentlyUsedPlayer; |
|
719 TInt currentlyUsedSubPlayer; |
|
720 delete iSubPlayerName; |
|
721 iSubPlayerName = NULL; |
|
722 iCurrentPlayerType = EPbLocal; |
|
723 TRAP_IGNORE( manager.GetSelectionL( iCurrentPlayerType, |
|
724 currentlyUsedPlayer, |
|
725 currentlyUsedSubPlayer, |
|
726 iSubPlayerName ) ); |
|
727 |
|
728 if ( title ) |
|
729 { |
|
730 if ( iCurrentPlayerType != EPbLocal) |
|
731 { |
|
732 if ( iSubPlayerName ) |
|
733 { |
|
734 title->SetTextL( *iSubPlayerName ); |
|
735 } |
|
736 } |
|
737 else |
|
738 { |
|
739 if ( FeatureManager::FeatureSupported( KFeatureIdFmtx ) ) |
|
740 { |
|
741 // We need to switch off FMtx so playback can be local |
|
742 CHWRMFmTx* fmtx = CHWRMFmTx::NewLC(); |
|
743 TRAP_IGNORE( fmtx->DisableL()); |
|
744 CleanupStack::PopAndDestroy( fmtx ); |
|
745 } |
|
746 |
|
747 RApaLsSession lsSession; |
|
748 TInt ret = lsSession.Connect(); |
|
749 if ( ret == KErrNone ) |
|
750 { |
|
751 CleanupClosePushL( lsSession ); |
|
752 TApaAppInfo appInfo; |
|
753 RProcess registeredProcess; |
|
754 CleanupClosePushL( registeredProcess ); |
|
755 |
|
756 ret = lsSession.GetAppInfo( appInfo, registeredProcess.Identity() ); |
|
757 MPX_DEBUG2("ProcessUID=0x%x", registeredProcess.Identity().iUid); |
|
758 |
|
759 CleanupStack::PopAndDestroy( ®isteredProcess ); |
|
760 |
|
761 if ( ret == KErrNone ) |
|
762 { |
|
763 MPX_DEBUG2("calling app name = %S", &appInfo.iCaption); |
|
764 title->SetTextL(appInfo.iCaption); |
|
765 } |
|
766 CleanupStack::PopAndDestroy( &lsSession ); // close lsSession |
|
767 } |
|
768 } |
|
769 } |
|
770 } |
|
771 |
|
772 // --------------------------------------------------------------------------- |
|
773 // Handle playback message. |
|
774 // --------------------------------------------------------------------------- |
|
775 // |
|
776 void CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL( |
|
777 const CMPXMessage& aMessage ) |
|
778 { |
|
779 MPX_FUNC( "CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL" ); |
|
780 |
|
781 TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId )); |
|
782 if ( KMPXMessagePbMediaChanged == id ) |
|
783 { |
|
784 if ( aMessage.IsSupported( KMPXMessagePbMedia )) |
|
785 { |
|
786 CMPXMedia* media( aMessage.Value<CMPXMedia>( KMPXMessagePbMedia )); |
|
787 User::LeaveIfNull( media ); |
|
788 DoHandleMediaL( *media, KErrNone ); |
|
789 } |
|
790 } |
|
791 else if ( KMPXMessageGeneral == id ) |
|
792 { |
|
793 TInt type( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ) ); |
|
794 TInt data( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ) ); |
|
795 switch ( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) ) |
|
796 { |
|
797 case TMPXPlaybackMessage::EPropertyChanged: |
|
798 { |
|
799 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL - EPropertyChanged(%d)", type ); |
|
800 TMPXPlaybackProperty property( |
|
801 static_cast<TMPXPlaybackProperty>( type ) ); |
|
802 TInt error( KErrNone ); |
|
803 |
|
804 DoHandlePropertyL( property, data, error ); |
|
805 break; |
|
806 } |
|
807 case TMPXPlaybackMessage::EStateChanged: |
|
808 { |
|
809 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL - EStateChanged(%d)", type ); |
|
810 |
|
811 TMPXPlaybackState state = |
|
812 static_cast<TMPXPlaybackState>( type ); |
|
813 if ( ( data == KErrNotSupported ) && |
|
814 ( state == EPbStatePaused ) ) |
|
815 { |
|
816 CommandNotSupportedL(); |
|
817 } |
|
818 else if ( ( data == KErrAccessDenied ) && |
|
819 ( state == EPbStatePaused )) |
|
820 { |
|
821 if ( MPXUser::IsCallOngoing( EPSCTsyCallTypeH324Multimedia )) |
|
822 { |
|
823 iCommonUiHelper->HandleErrorL( KMPXErrorVideoCall ); |
|
824 } |
|
825 } |
|
826 else |
|
827 { |
|
828 DoHandleStateChangedL( state, data ); |
|
829 } |
|
830 break; |
|
831 } |
|
832 case TMPXPlaybackMessage::EDownloadStarted: |
|
833 { |
|
834 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL - EDownloadStarted(%d)", type ); |
|
835 TMPXPlaybackState state = EPbStateDownloading; |
|
836 DoHandleStateChangedL( state, data ); |
|
837 break; |
|
838 } |
|
839 case TMPXPlaybackMessage::ECommandReceived: |
|
840 { |
|
841 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL - ECommandReceived(%d)", type ); |
|
842 break; |
|
843 } |
|
844 case TMPXPlaybackMessage::ESkipping: |
|
845 { |
|
846 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL - ESkipping(%d)", data ); |
|
847 iMPXUtility->CancelRequest(); |
|
848 if ( GetUPnPPlaybackDialogCustomControl() ) |
|
849 { |
|
850 GetUPnPPlaybackDialogCustomControl()->SetMode( EMediaKeySkipping ); |
|
851 } |
|
852 TInt offset( data ); |
|
853 if ( offset < 0 ) |
|
854 { |
|
855 iLastSkipDirection = -1; |
|
856 } |
|
857 else |
|
858 { |
|
859 iLastSkipDirection = 1; |
|
860 } |
|
861 iSkipping = ETrue; |
|
862 break; |
|
863 } |
|
864 case TMPXPlaybackMessage::ESkipEnd: |
|
865 { |
|
866 MPX_DEBUG1( "CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL - ESkipEnd()"); |
|
867 iSkipping = EFalse; |
|
868 break; |
|
869 } |
|
870 case TMPXPlaybackMessage::EPlaylistUpdated: |
|
871 { |
|
872 MPX_DEBUG1( "CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL - EPlaylistUpdated()"); |
|
873 // Do not retrive media again if in the middle of handling an error |
|
874 if ( KErrNone == iDelayedError ) |
|
875 { |
|
876 TBool noTracks( ETrue ); |
|
877 MMPXSource* source = iPlaybackUtility->Source(); |
|
878 if ( source ) |
|
879 { |
|
880 CMPXCollectionPlaylist* pl( source->PlaylistL() ); |
|
881 if ( pl ) |
|
882 { |
|
883 CleanupStack::PushL( pl ); |
|
884 if ( pl->Count() > 0 ) |
|
885 { |
|
886 // Only update media if in foreground |
|
887 if ( !GetUPnPPlaybackDialogCustomControl() ) |
|
888 { |
|
889 // If in background, wait for view to be activated |
|
890 // before requesting media again |
|
891 delete iMedia; |
|
892 iMedia = NULL; |
|
893 } |
|
894 noTracks = EFalse; |
|
895 } |
|
896 CleanupStack::PopAndDestroy( pl ); |
|
897 } |
|
898 } |
|
899 if ( noTracks ) |
|
900 { |
|
901 delete iMedia; |
|
902 iMedia = NULL; |
|
903 iPlaybackState = EPbStateNotInitialised; |
|
904 UpdateViewL(); |
|
905 } |
|
906 } |
|
907 break; |
|
908 } |
|
909 case TMPXPlaybackMessage::EInitializeComplete: |
|
910 { |
|
911 if (iCommonUiHelper) |
|
912 { |
|
913 iCommonUiHelper->DismissWaitNoteL(); |
|
914 } |
|
915 break; |
|
916 } |
|
917 case TMPXPlaybackMessage::EPlayerUnavailable: |
|
918 { |
|
919 TUid activeView = iViewUtility->ActiveViewType(); |
|
920 if ( activeView == TUid::Uid( KMPXPluginTypePlaybackUid ) ) |
|
921 { |
|
922 iPlaybackUtility->CommandL(EPbCmdClose); |
|
923 if ( data == KErrNotFound ) |
|
924 { |
|
925 if ( iSubPlayerName ) |
|
926 { |
|
927 HBufC* dialogText = StringLoader::LoadLC( R_MPX_NOTE_REMOTE_CONNECTION_FAILED, |
|
928 *iSubPlayerName ); |
|
929 CAknErrorNote* errNote = new(ELeave) CAknErrorNote(ETrue); |
|
930 errNote->SetTimeout(CAknNoteDialog::ELongTimeout); |
|
931 errNote->ExecuteLD( *dialogText ); |
|
932 CleanupStack::PopAndDestroy( dialogText ); |
|
933 } |
|
934 } |
|
935 |
|
936 if ( !iDelayedEventExit ) |
|
937 { |
|
938 iDelayedEventExit = CIdle::NewL(CActive::EPriorityStandard); |
|
939 } |
|
940 |
|
941 if ( !iDelayedEventExit->IsActive()) |
|
942 { |
|
943 TCallBack callBack( CMPXUPnPPlaybackDialog::DelayedExit, |
|
944 this ); |
|
945 iDelayedEventExit->Start(callBack); |
|
946 } |
|
947 } |
|
948 break; |
|
949 } |
|
950 default: |
|
951 { |
|
952 break; |
|
953 } |
|
954 } |
|
955 } |
|
956 } |
|
957 |
|
958 // --------------------------------------------------------------------------- |
|
959 // Handle playback property. |
|
960 // --------------------------------------------------------------------------- |
|
961 // |
|
962 void CMPXUPnPPlaybackDialog::DoHandlePropertyL( |
|
963 TMPXPlaybackProperty aProperty, |
|
964 TInt aValue, |
|
965 TInt aError, |
|
966 TBool aInit) |
|
967 { |
|
968 MPX_FUNC( "CMPXUPnPPlaybackDialog::DoHandlePropertyL" ); |
|
969 MPX_DEBUG4( "HandlePropertyL - Property(%d); Value(%d); Error(%d)", aProperty, aValue, aError ); |
|
970 |
|
971 if ( KErrNone == aError ) |
|
972 { |
|
973 switch ( aProperty ) |
|
974 { |
|
975 case EPbPropertyPosition: |
|
976 { |
|
977 iPosition = aValue / KMPXOneSecInMilliSecs; |
|
978 UpdateTrackPlaybackPositionL( |
|
979 iPosition, iDuration ); |
|
980 break; |
|
981 } |
|
982 case EPbPropertyDuration: |
|
983 { |
|
984 iDuration = aValue / KMPXOneSecInMilliSecs; |
|
985 if ( ( ( iPlaybackState == EPbStateStopped ) || |
|
986 ( iPlaybackState == EPbStateInitialising ) ) && |
|
987 iDuration > 0 ) |
|
988 { |
|
989 UpdateTrackPlaybackPositionL( iPosition, iDuration ); |
|
990 } |
|
991 break; |
|
992 } |
|
993 case EPbPropertyRandomMode: |
|
994 { |
|
995 iRandomMode = aValue; |
|
996 if ( GetUPnPPlaybackDialogCustomControl() ) |
|
997 { |
|
998 GetUPnPPlaybackDialogCustomControl()->SetRandomMode( aValue ); |
|
999 } |
|
1000 break; |
|
1001 } |
|
1002 case EPbPropertyRepeatMode: |
|
1003 { |
|
1004 iRepeatMode = aValue; |
|
1005 if ( GetUPnPPlaybackDialogCustomControl() ) |
|
1006 { |
|
1007 GetUPnPPlaybackDialogCustomControl()->SetRepeatMode( |
|
1008 EPbRepeatAll == aValue, EPbRepeatOne == aValue ); |
|
1009 } |
|
1010 break; |
|
1011 } |
|
1012 case EPbPropertyVolume: |
|
1013 { |
|
1014 iCurrentVolume = aValue; |
|
1015 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::DoHandlePlaybackMessageL iCurrentVolume = %d", iCurrentVolume ); |
|
1016 break; |
|
1017 } |
|
1018 default: |
|
1019 { |
|
1020 break; |
|
1021 } |
|
1022 } |
|
1023 } |
|
1024 else |
|
1025 { |
|
1026 HandleErrorL( aError ); |
|
1027 } |
|
1028 } |
|
1029 |
|
1030 // --------------------------------------------------------------------------- |
|
1031 // Handle media properties. |
|
1032 // Notes: The client is responsible for delete the object of aProperties. |
|
1033 // --------------------------------------------------------------------------- |
|
1034 // |
|
1035 void CMPXUPnPPlaybackDialog::DoHandleMediaL( |
|
1036 const CMPXMedia& aMedia, |
|
1037 TInt aError ) |
|
1038 { |
|
1039 MPX_FUNC( "CMPXUPnPPlaybackDialog::DoHandleMediaL" ); |
|
1040 MPX_DEBUG2("CMPXUPnPPlaybackDialog::DoHandleMediaL(): aError = %d", aError); |
|
1041 |
|
1042 delete iMedia; |
|
1043 iMedia = NULL; |
|
1044 if ( KErrNone == aError ) |
|
1045 { |
|
1046 iMedia = CMPXMedia::NewL( aMedia ); |
|
1047 |
|
1048 UpdateTrackPosInPlaylistL(); |
|
1049 UpdateTrackInfoL( iMedia ); |
|
1050 // If media key skipping, do not update album art |
|
1051 if ( !iSkipping ) |
|
1052 { |
|
1053 UpdateAlbumArtL( iMedia ); |
|
1054 } |
|
1055 |
|
1056 // Update duration if previously not available |
|
1057 if ( iMedia->IsSupported( KMPXMediaGeneralDuration ) ) |
|
1058 { |
|
1059 iDuration = iMedia->ValueTObjectL<TInt>( KMPXMediaGeneralDuration ) / |
|
1060 KMPXOneSecInMilliSecs; |
|
1061 UpdateTrackPlaybackPositionL( iPosition, iDuration ); |
|
1062 } |
|
1063 |
|
1064 // If there's a delayed error, handle it now |
|
1065 // that the media object has arrived |
|
1066 if ( iDelayedError != KErrNone ) |
|
1067 { |
|
1068 // Copy error code and reset iDelayedError, this is becuase |
|
1069 // a media event may be called while handling this error |
|
1070 TInt err( iDelayedError ); |
|
1071 iDelayedError = KErrNone; |
|
1072 HandleErrorL( err ); |
|
1073 } |
|
1074 } |
|
1075 else |
|
1076 { |
|
1077 HandleErrorL( aError ); |
|
1078 if ( aError == iDelayedError ) |
|
1079 { |
|
1080 iDelayedError = KErrNone; |
|
1081 } |
|
1082 } |
|
1083 } |
|
1084 |
|
1085 // --------------------------------------------------------------------------- |
|
1086 // Handle playback state changed. |
|
1087 // --------------------------------------------------------------------------- |
|
1088 // |
|
1089 void CMPXUPnPPlaybackDialog::DoHandleStateChangedL( |
|
1090 TMPXPlaybackState aState, |
|
1091 TInt aData ) |
|
1092 { |
|
1093 MPX_FUNC( "CMPXUPnPPlaybackDialog::DoHandleStateChangedL" ); |
|
1094 |
|
1095 // If KErrDisconnected, it's a fatal error and we close the dialog |
|
1096 if ( ( aState == EPbStatePaused ) && |
|
1097 ( aData == KErrDisconnected ) ) |
|
1098 { |
|
1099 TUid activeView = iViewUtility->ActiveViewType(); |
|
1100 if ( activeView == TUid::Uid( KMPXPluginTypePlaybackUid ) ) |
|
1101 { |
|
1102 iPlaybackUtility->CommandL(EPbCmdStop); |
|
1103 |
|
1104 if ( !iDelayedEventExit ) |
|
1105 { |
|
1106 iDelayedEventExit = CIdle::NewL(CActive::EPriorityStandard); |
|
1107 } |
|
1108 |
|
1109 if ( !iDelayedEventExit->IsActive()) |
|
1110 { |
|
1111 TCallBack callBack( CMPXUPnPPlaybackDialog::DelayedExit, |
|
1112 this ); |
|
1113 iDelayedEventExit->Start(callBack); |
|
1114 } |
|
1115 } |
|
1116 } |
|
1117 else |
|
1118 { |
|
1119 UpdatePlaybackState( aState ); |
|
1120 |
|
1121 switch ( aState ) |
|
1122 { |
|
1123 case EPbStateStopped: |
|
1124 { |
|
1125 iStartPlaybackIndex = KErrNotFound; |
|
1126 } |
|
1127 case EPbStateNotInitialised: |
|
1128 { |
|
1129 UpdateTrackPlaybackPositionL( 0, iDuration ); |
|
1130 break; |
|
1131 } |
|
1132 case EPbStateInitialising: |
|
1133 { |
|
1134 // Save the start playback index |
|
1135 if ( KErrNotFound == iStartPlaybackIndex && |
|
1136 KErrNotFound != aData ) |
|
1137 { |
|
1138 iStartPlaybackIndex = aData; |
|
1139 } |
|
1140 |
|
1141 // Fall through on purpose |
|
1142 } |
|
1143 case EPbStateDownloading: |
|
1144 { |
|
1145 UpdateDownloadStateLabelL(); |
|
1146 break; |
|
1147 } |
|
1148 case EPbStatePlaying: |
|
1149 case EPbStatePaused: |
|
1150 default: |
|
1151 { |
|
1152 MPX_PERF_CHECKPT("Playback state changes to Play/Pause"); |
|
1153 iStartPlaybackIndex = KErrNotFound; |
|
1154 iLastSkipDirection = 1; |
|
1155 break; |
|
1156 } |
|
1157 } |
|
1158 } |
|
1159 } |
|
1160 |
|
1161 // --------------------------------------------------------------------------- |
|
1162 // Displays error notes. |
|
1163 // --------------------------------------------------------------------------- |
|
1164 // |
|
1165 void CMPXUPnPPlaybackDialog::HandleErrorL( TInt aError ) |
|
1166 { |
|
1167 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandleErrorL()" ); |
|
1168 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::HandleErrorL(%d)", aError ); |
|
1169 if ( aError ) |
|
1170 { |
|
1171 TInt currentIndex( KErrNotFound ); |
|
1172 TInt nextIndex( KErrNotFound ); |
|
1173 TInt plCount( KErrNotFound ); |
|
1174 MMPXSource* source( iPlaybackUtility->Source() ); |
|
1175 if ( source ) |
|
1176 { |
|
1177 CMPXCollectionPlaylist* pl( source->PlaylistL() ); |
|
1178 if ( pl ) |
|
1179 { |
|
1180 CleanupStack::PushL( pl ); |
|
1181 currentIndex = pl->Index(); |
|
1182 if ( iLastSkipDirection < 0 ) |
|
1183 { |
|
1184 pl->Previous( ETrue ); |
|
1185 } |
|
1186 else |
|
1187 { |
|
1188 pl->Next( ETrue ); |
|
1189 } |
|
1190 nextIndex = pl->Index(); |
|
1191 plCount = pl->Count(); |
|
1192 CleanupStack::PopAndDestroy( pl ); |
|
1193 } |
|
1194 } |
|
1195 |
|
1196 // MMF framework will return KErrArgument/KErrCompletion if it reaches |
|
1197 // the end of a partially downloaded file. The downloaded portion of |
|
1198 // the file should still be playable in this case. |
|
1199 if ( KErrNotFound != nextIndex && |
|
1200 ( ( KErrArgument != aError && KErrCompletion != aError ) || |
|
1201 iPlaybackState != EPbStatePlaying )) |
|
1202 { |
|
1203 // Check if all tracks are invalid, or if there's only |
|
1204 // 1 track in the playlist |
|
1205 if ( nextIndex == iStartPlaybackIndex || |
|
1206 plCount == 1 ) |
|
1207 { |
|
1208 aError = KMPXAllTracksInvalid; |
|
1209 } |
|
1210 } |
|
1211 |
|
1212 switch ( aError ) |
|
1213 { |
|
1214 case KMPXRightsAboutToExpire: |
|
1215 case KErrCANotSupported: |
|
1216 case KErrCANoPermission: |
|
1217 case KErrCANoRights: |
|
1218 case KErrCANoAgent: |
|
1219 case KErrCAOutOfRange: |
|
1220 case KErrCAPendingRights: |
|
1221 case KErrCASizeNotDetermined: |
|
1222 case KErrCANewFileHandleRequired: |
|
1223 case KErrPermissionDenied: |
|
1224 { |
|
1225 if ( iMedia ) |
|
1226 { |
|
1227 if ( iMedia->IsSupported( KMPXMediaDrmType ) ) |
|
1228 { |
|
1229 TMPXMediaDrmType type( |
|
1230 iMedia->ValueTObjectL<TMPXMediaDrmType>( |
|
1231 KMPXMediaDrmType ) ); |
|
1232 // Only display DRM error message for WMDRM |
|
1233 // if it's the first song selected |
|
1234 if ( EMPXDrmTypeWMA == type && |
|
1235 currentIndex == iStartPlaybackIndex ) |
|
1236 { |
|
1237 iCommonUiHelper->HandleErrorL( aError, iMedia ); |
|
1238 } |
|
1239 } |
|
1240 } |
|
1241 SkipOnErrorL( currentIndex, plCount ); |
|
1242 break; |
|
1243 } |
|
1244 case KErrAccessDenied: |
|
1245 { |
|
1246 // Only display error message if first one selected to play |
|
1247 if ( currentIndex == iStartPlaybackIndex ) |
|
1248 { |
|
1249 iCommonUiHelper->HandleErrorL( aError, iMedia ); |
|
1250 } |
|
1251 SkipOnErrorL( currentIndex, plCount ); |
|
1252 break; |
|
1253 } |
|
1254 case KErrNotSupported: |
|
1255 case KErrCorrupt: |
|
1256 case KErrNotFound: |
|
1257 case KErrPathNotFound: |
|
1258 { |
|
1259 SkipOnErrorL( currentIndex, plCount ); |
|
1260 break; |
|
1261 } |
|
1262 case KMPXAllTracksInvalid: |
|
1263 { |
|
1264 HandleAllTracksInvalidL(); |
|
1265 break; |
|
1266 } |
|
1267 case KErrArgument: |
|
1268 case KErrCompletion: |
|
1269 { |
|
1270 TBool skip( ETrue ); |
|
1271 |
|
1272 // UI specs say theres two cases where it stops and |
|
1273 // does not skip to the next song. |
|
1274 // First case is if not repeat all and playback has |
|
1275 // reached the end of the list and gone to the first song. |
|
1276 // Second case is if not repeat all and the user is skipping |
|
1277 // backwards and reached the first song |
|
1278 if ( EPbRepeatAll != iRepeatMode && |
|
1279 0 == currentIndex && |
|
1280 -1 == iLastSkipDirection) |
|
1281 { |
|
1282 skip = EFalse; |
|
1283 } |
|
1284 |
|
1285 // Skip to next/previous track |
|
1286 if ( skip ) |
|
1287 { |
|
1288 if ( iLastSkipDirection < 0 ) |
|
1289 { |
|
1290 iPlaybackUtility->CommandL( EPbCmdPrevious ); |
|
1291 } |
|
1292 else |
|
1293 { |
|
1294 iPlaybackUtility->CommandL( EPbCmdNext ); |
|
1295 } |
|
1296 } |
|
1297 break; |
|
1298 } |
|
1299 // Cannot be recovered, exit the dialog. |
|
1300 case KErrDisconnected: |
|
1301 { |
|
1302 TUid activeView = iViewUtility->ActiveViewType(); |
|
1303 if ( activeView == TUid::Uid( KMPXPluginTypePlaybackUid ) ) |
|
1304 { |
|
1305 iPlaybackUtility->CommandL(EPbCmdStop); |
|
1306 |
|
1307 if ( !iDelayedEventExit ) |
|
1308 { |
|
1309 iDelayedEventExit = CIdle::NewL(CActive::EPriorityStandard); |
|
1310 } |
|
1311 |
|
1312 if ( !iDelayedEventExit->IsActive()) |
|
1313 { |
|
1314 TCallBack callBack( CMPXUPnPPlaybackDialog::DelayedExit, |
|
1315 this ); |
|
1316 iDelayedEventExit->Start(callBack); |
|
1317 } |
|
1318 } |
|
1319 break; |
|
1320 } |
|
1321 default: |
|
1322 { |
|
1323 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
1324 iCommonUiHelper->HandleErrorL( aError, iMedia ); |
|
1325 break; |
|
1326 } |
|
1327 } |
|
1328 } |
|
1329 } |
|
1330 |
|
1331 // --------------------------------------------------------------------------- |
|
1332 // Displays error note for when all tracks are invalid, |
|
1333 // and goes back to collection list view |
|
1334 // --------------------------------------------------------------------------- |
|
1335 // |
|
1336 void CMPXUPnPPlaybackDialog::HandleAllTracksInvalidL() |
|
1337 { |
|
1338 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandleAllTracksInvalidL()" ); |
|
1339 |
|
1340 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
1341 UpdatePlaybackState( EPbStateStopped ); |
|
1342 |
|
1343 // Do not display error if view is not active |
|
1344 if ( GetUPnPPlaybackDialogCustomControl() ) |
|
1345 { |
|
1346 iCommonUiHelper->HandleErrorL( KMPXAllTracksInvalid, iMedia ); |
|
1347 HandleCommandL( EAknSoftkeyBack ); |
|
1348 } |
|
1349 iStartPlaybackIndex = KErrNotFound; |
|
1350 iLastSkipDirection = 1; |
|
1351 |
|
1352 // Reset the playlist to point to the first item |
|
1353 // in list, but do not initialize the song for |
|
1354 // playback |
|
1355 MMPXSource* source( iPlaybackUtility->Source() ); |
|
1356 if ( source ) |
|
1357 { |
|
1358 CMPXCollectionPlaylist* pl( source->PlaylistL() ); |
|
1359 if ( pl ) |
|
1360 { |
|
1361 CleanupStack::PushL( pl ); |
|
1362 pl->SetToFirst(); |
|
1363 iPlaybackUtility->InitL( *pl, EFalse ); |
|
1364 CleanupStack::PopAndDestroy( pl ); |
|
1365 } |
|
1366 } |
|
1367 } |
|
1368 |
|
1369 // --------------------------------------------------------------------------- |
|
1370 // Checks whether or not to skip to next track on an error |
|
1371 // --------------------------------------------------------------------------- |
|
1372 // |
|
1373 void CMPXUPnPPlaybackDialog::SkipOnErrorL( |
|
1374 TInt aCurrentIndex, |
|
1375 TInt aCount ) |
|
1376 { |
|
1377 MPX_FUNC( "CMPXUPnPPlaybackDialog::SkipOnErrorL()" ); |
|
1378 MPX_DEBUG2("CMPXUPnPPlaybackDialog::SkipOnErrorL(%d)", aCurrentIndex); |
|
1379 |
|
1380 TBool skip( ETrue ); |
|
1381 TBool displayError( EFalse ); |
|
1382 |
|
1383 // UI specs say theres two cases where it stops and |
|
1384 // does not skip to the next song. |
|
1385 // First case is if not repeat all and playback has |
|
1386 // reached the end of the list and gone to the first song. |
|
1387 // Second case is if not repeat all and the user is skipping |
|
1388 // backwards and reached the first song |
|
1389 if ( EPbRepeatAll != iRepeatMode ) |
|
1390 { |
|
1391 if ( 0 == aCurrentIndex && |
|
1392 -1 == iLastSkipDirection ) |
|
1393 { |
|
1394 skip = EFalse; |
|
1395 displayError = ETrue; |
|
1396 } |
|
1397 else if ( aCurrentIndex == aCount-1 && |
|
1398 1 == iLastSkipDirection ) |
|
1399 { |
|
1400 skip = EFalse; |
|
1401 displayError = ETrue; |
|
1402 } |
|
1403 } |
|
1404 |
|
1405 // Skip to next/previous track |
|
1406 if ( skip ) |
|
1407 { |
|
1408 if ( iLastSkipDirection < 0 ) |
|
1409 { |
|
1410 iPlaybackUtility->CommandL( EPbCmdPrevious ); |
|
1411 } |
|
1412 else |
|
1413 { |
|
1414 iPlaybackUtility->CommandL( EPbCmdNext ); |
|
1415 } |
|
1416 } |
|
1417 |
|
1418 // Display error message |
|
1419 if ( displayError ) |
|
1420 { |
|
1421 HandleAllTracksInvalidL(); |
|
1422 } |
|
1423 |
|
1424 MPX_DEBUG1("CMPXUPnPPlaybackDialog::SkipOnErrorL: Exiting"); |
|
1425 } |
|
1426 |
|
1427 // --------------------------------------------------------------------------- |
|
1428 // Request for the media object |
|
1429 // --------------------------------------------------------------------------- |
|
1430 // |
|
1431 void CMPXUPnPPlaybackDialog::RequestMediaL( TBool aDrm /*=EFalse*/ ) |
|
1432 { |
|
1433 MPX_FUNC( "CMPXUPnPPlaybackDialog::RequestMediaL()" ); |
|
1434 |
|
1435 MMPXSource* s = iPlaybackUtility->Source(); |
|
1436 if ( s ) |
|
1437 { |
|
1438 RArray<TMPXAttribute> attrs; |
|
1439 CleanupClosePushL(attrs); |
|
1440 attrs.Append( KMPXMediaGeneralBasic | |
|
1441 KMPXMediaGeneralUri | |
|
1442 KMPXMediaGeneralMimeType | |
|
1443 KMPXMediaGeneralDuration ); |
|
1444 attrs.Append( KMPXMediaMusicAlbumArtFileName | |
|
1445 KMPXMediaMusicArtist | |
|
1446 KMPXMediaMusicAlbum ); |
|
1447 if ( aDrm ) |
|
1448 { |
|
1449 attrs.Append( KMPXMediaDrmAll ); |
|
1450 } |
|
1451 else |
|
1452 { |
|
1453 // If not retrieving all drm attributes, then |
|
1454 // minimal is retrieve the protected flag and |
|
1455 // automated flag |
|
1456 attrs.Append( KMPXMediaDrmProtected | |
|
1457 KMPXMediaDrmCanSetAutomated ); |
|
1458 } |
|
1459 s->MediaL( attrs.Array(), *this ); |
|
1460 CleanupStack::PopAndDestroy( &attrs ); |
|
1461 } |
|
1462 } |
|
1463 |
|
1464 // ----------------------------------------------------------------------------- |
|
1465 // CMPXUPnPPlaybackDialog::PrepareStatusPaneForPlaybackViewL |
|
1466 // ----------------------------------------------------------------------------- |
|
1467 // |
|
1468 void CMPXUPnPPlaybackDialog::PrepareStatusPaneForPlaybackViewL() |
|
1469 { |
|
1470 iPreviousLayoutId = iAvkonAppUi->StatusPane()->CurrentLayoutResId(); |
|
1471 |
|
1472 if ( !Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1473 { |
|
1474 if ( iPreviousLayoutId != |
|
1475 R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT ) |
|
1476 { |
|
1477 TRAP_IGNORE( |
|
1478 iAvkonAppUi->StatusPane()->SwitchLayoutL( |
|
1479 R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT )); |
|
1480 } |
|
1481 } |
|
1482 else |
|
1483 { |
|
1484 if ( iPreviousLayoutId != |
|
1485 R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
|
1486 { |
|
1487 TRAP_IGNORE( |
|
1488 iAvkonAppUi->StatusPane()->SwitchLayoutL( |
|
1489 R_AVKON_STATUS_PANE_LAYOUT_USUAL )); |
|
1490 } |
|
1491 } |
|
1492 } |
|
1493 |
|
1494 // ----------------------------------------------------------------------------- |
|
1495 // CMPXUPnPPlaybackDialog::PrepareStatusPaneForExitingViewL |
|
1496 // ----------------------------------------------------------------------------- |
|
1497 // |
|
1498 void CMPXUPnPPlaybackDialog::PrepareStatusPaneForExitingViewL() |
|
1499 { |
|
1500 if ( iAvkonAppUi->StatusPane()->CurrentLayoutResId() != |
|
1501 R_AVKON_STATUS_PANE_LAYOUT_USUAL) |
|
1502 { |
|
1503 iAvkonAppUi->StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL); |
|
1504 } |
|
1505 } |
|
1506 |
|
1507 // --------------------------------------------------------------------------- |
|
1508 // From MMPXPlaybackObserver |
|
1509 // Handle playback message. |
|
1510 // --------------------------------------------------------------------------- |
|
1511 // |
|
1512 void CMPXUPnPPlaybackDialog::HandlePlaybackMessage( |
|
1513 CMPXMessage* aMessage, TInt aError ) |
|
1514 { |
|
1515 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandlePlaybackMessage" ); |
|
1516 MPX_DEBUG2("CMPXUPnPPlaybackDialog::HandlePlaybackMessage(%d)", aError); |
|
1517 if ( aError == KErrNone && aMessage ) |
|
1518 { |
|
1519 TRAP_IGNORE( DoHandlePlaybackMessageL( *aMessage ) ); |
|
1520 } |
|
1521 else if ( aError != KErrNone ) |
|
1522 { |
|
1523 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::HandlePlaybackMessage - EError(%d)", aError ); |
|
1524 // Check if it's a DRM song first, only get media for DRM songs |
|
1525 TBool drmSong( EFalse ); |
|
1526 if ( iMedia ) |
|
1527 { |
|
1528 if ( iMedia->IsSupported( KMPXMediaDrmProtected )) |
|
1529 { |
|
1530 drmSong = iMedia->ValueTObjectL<TBool>( KMPXMediaDrmProtected ); |
|
1531 } |
|
1532 } |
|
1533 if ( drmSong ) |
|
1534 { |
|
1535 iDelayedError = aError; |
|
1536 TRAP_IGNORE( RequestMediaL( ETrue )); |
|
1537 } |
|
1538 else |
|
1539 { |
|
1540 iDelayedError = KErrNone; |
|
1541 TRAP_IGNORE( HandleErrorL( aError )); |
|
1542 } |
|
1543 } |
|
1544 } |
|
1545 |
|
1546 // --------------------------------------------------------------------------- |
|
1547 // From MMPXPlaybackCallback |
|
1548 // Handle playback property. |
|
1549 // --------------------------------------------------------------------------- |
|
1550 // |
|
1551 void CMPXUPnPPlaybackDialog::HandlePropertyL( |
|
1552 TMPXPlaybackProperty aProperty, |
|
1553 TInt aValue, |
|
1554 TInt aError ) |
|
1555 { |
|
1556 DoHandlePropertyL( aProperty, aValue, aError, ETrue ); |
|
1557 } |
|
1558 |
|
1559 // --------------------------------------------------------------------------- |
|
1560 // From MMPXPlaybackCallback |
|
1561 // Method is called continously until aComplete=ETrue, signifying that |
|
1562 // it is done and there will be no more callbacks |
|
1563 // Only new items are passed each time |
|
1564 // --------------------------------------------------------------------------- |
|
1565 // |
|
1566 void CMPXUPnPPlaybackDialog::HandleSubPlayerNamesL( |
|
1567 TUid /* aPlayer */, |
|
1568 const MDesCArray* /* aSubPlayers */, |
|
1569 TBool /* aComplete */, |
|
1570 TInt /* aError */ ) |
|
1571 { |
|
1572 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandleSubPlayerNamesL" ); |
|
1573 } |
|
1574 |
|
1575 // --------------------------------------------------------------------------- |
|
1576 // From MMPXPlaybackCallback |
|
1577 // Handle media event. |
|
1578 // Notes: The client is responsible for delete the object of aProperties. |
|
1579 // --------------------------------------------------------------------------- |
|
1580 // |
|
1581 void CMPXUPnPPlaybackDialog::HandleMediaL( |
|
1582 const CMPXMedia& aMedia, |
|
1583 TInt aError ) |
|
1584 { |
|
1585 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandleMediaL" ); |
|
1586 DoHandleMediaL( aMedia, aError ); |
|
1587 } |
|
1588 |
|
1589 // --------------------------------------------------------------------------- |
|
1590 // From MMPXCollectionMediaObserver |
|
1591 // Handle extended media properties |
|
1592 // --------------------------------------------------------------------------- |
|
1593 // |
|
1594 void CMPXUPnPPlaybackDialog::HandleCollectionMediaL( |
|
1595 const CMPXMedia& aMedia, |
|
1596 TInt aError ) |
|
1597 { |
|
1598 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandleCollectionMediaL" ); |
|
1599 DoHandleMediaL( aMedia, aError ); |
|
1600 } |
|
1601 |
|
1602 // --------------------------------------------------------------------------- |
|
1603 // From CAknView |
|
1604 // Command handling function. |
|
1605 // --------------------------------------------------------------------------- |
|
1606 // |
|
1607 void CMPXUPnPPlaybackDialog::HandleCommandL( TInt aCommand ) |
|
1608 { |
|
1609 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandleCommandL()" ); |
|
1610 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::HandleCommandL(%d) entering", aCommand ); |
|
1611 |
|
1612 switch (aCommand) |
|
1613 { |
|
1614 case EMPXPbvCmdPlay: |
|
1615 { |
|
1616 iPlaybackUtility->CommandL( EPbCmdPlay ); |
|
1617 break; |
|
1618 } |
|
1619 case EMPXPbvCmdStop: |
|
1620 { |
|
1621 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
1622 break; |
|
1623 } |
|
1624 case EMPXPbvCmdPause: |
|
1625 { |
|
1626 MPX_PERF_CHECKPT("Pause command issued"); |
|
1627 iPlaybackUtility->CommandL( EPbCmdPause ); |
|
1628 break; |
|
1629 } |
|
1630 case EMPXPbvCmdPlayPause: |
|
1631 { |
|
1632 iPlaybackUtility->CommandL( EPbCmdPlayPause ); |
|
1633 break; |
|
1634 } |
|
1635 case EMPXPbvCmdSeekForward: |
|
1636 case EMPXPbvCmdSeekBackward: |
|
1637 { |
|
1638 if ( iCurrentPlayerType == EPbLocal) |
|
1639 { |
|
1640 if ( aCommand == EMPXPbvCmdSeekForward ) |
|
1641 { |
|
1642 iPlaybackUtility->CommandL( EPbCmdStartSeekForward ); |
|
1643 } |
|
1644 else |
|
1645 { |
|
1646 iPlaybackUtility->CommandL( EPbCmdStartSeekBackward ); |
|
1647 } |
|
1648 |
|
1649 if ( !iKeySoundDisabled ) |
|
1650 { |
|
1651 iAvkonAppUi->KeySounds()->PushContextL( |
|
1652 R_MPX_PBV_LEFT_RIGHT_KEYS_SILENT ); |
|
1653 iKeySoundDisabled = ETrue; |
|
1654 } |
|
1655 } |
|
1656 else |
|
1657 { |
|
1658 // Not Supported in UPnP |
|
1659 if ( iSeekForward ) |
|
1660 { |
|
1661 break; |
|
1662 } |
|
1663 iSeekForward = ETrue; |
|
1664 CommandNotSupportedL(); |
|
1665 |
|
1666 if ( iLastKeyType != EEventKeyUp ) |
|
1667 { |
|
1668 iLastKeyType = EEventKeyUp; |
|
1669 if ( GetUPnPPlaybackDialogCustomControl() ) |
|
1670 { |
|
1671 GetUPnPPlaybackDialogCustomControl()->OfferKeyEventL( |
|
1672 iLastKeyEvent, |
|
1673 EEventKeyUp ); |
|
1674 } |
|
1675 } |
|
1676 iSeekForward = EFalse; |
|
1677 } |
|
1678 break; |
|
1679 } |
|
1680 case EMPXPbvCmdEndSeek: |
|
1681 { |
|
1682 if ( iCurrentPlayerType == EPbLocal) |
|
1683 { |
|
1684 iPlaybackUtility->CommandL( EPbCmdStopSeeking ); |
|
1685 if ( iKeySoundDisabled ) |
|
1686 { |
|
1687 iAvkonAppUi->KeySounds()->PopContext(); |
|
1688 iKeySoundDisabled = EFalse; |
|
1689 } |
|
1690 } |
|
1691 // else Not supported |
|
1692 break; |
|
1693 } |
|
1694 case EMPXPbvCmdNextListItem: |
|
1695 { |
|
1696 // When user skips a track, reset the start playback index |
|
1697 iStartPlaybackIndex = KErrNotFound; |
|
1698 |
|
1699 iPlaybackUtility->CommandL( EPbCmdNext ); |
|
1700 break; |
|
1701 } |
|
1702 case EMPXPbvCmdPreviousListItem: |
|
1703 { |
|
1704 // When user skips a track, reset the start playback index |
|
1705 iStartPlaybackIndex = KErrNotFound; |
|
1706 |
|
1707 iPlaybackUtility->CommandL( EPbCmdPrevious ); |
|
1708 break; |
|
1709 } |
|
1710 case EMPXPbvCmdDecreaseVolume: |
|
1711 { |
|
1712 iPlaybackUtility->CommandL( EPbCmdDecreaseVolume ); |
|
1713 break; |
|
1714 } |
|
1715 case EMPXPbvCmdIncreaseVolume: |
|
1716 { |
|
1717 iPlaybackUtility->CommandL( EPbCmdIncreaseVolume ); |
|
1718 break; |
|
1719 } |
|
1720 case EMPXCmdSeekForward: |
|
1721 case EMPXCmdSeekBackward: |
|
1722 { |
|
1723 if ( iCurrentPlayerType == EPbLocal) |
|
1724 { |
|
1725 iAvkonAppUi->HandleCommandL( aCommand ); |
|
1726 } |
|
1727 else |
|
1728 { |
|
1729 CommandNotSupportedL(); |
|
1730 } |
|
1731 break; |
|
1732 } |
|
1733 case EMPXCmdNext: |
|
1734 case EMPXCmdPrevious: |
|
1735 // When user skips a track, reset the start playback index |
|
1736 iStartPlaybackIndex = KErrNotFound; |
|
1737 case EMPXCmdPlay: |
|
1738 case EMPXCmdPause: |
|
1739 case EMPXCmdPlayPause: |
|
1740 case EMPXCmdStop: |
|
1741 case EMPXCmdStopSeeking: |
|
1742 case EMPXCmdVolumeUp: |
|
1743 case EMPXCmdVolumeDown: |
|
1744 { |
|
1745 iAvkonAppUi->HandleCommandL( aCommand ); |
|
1746 break; |
|
1747 } |
|
1748 default: |
|
1749 { |
|
1750 iAvkonAppUi->HandleCommandL( aCommand ); |
|
1751 break; |
|
1752 } |
|
1753 } |
|
1754 } |
|
1755 |
|
1756 // --------------------------------------------------------------------------- |
|
1757 // From CAknView |
|
1758 // Processes user commands. |
|
1759 // --------------------------------------------------------------------------- |
|
1760 // |
|
1761 void CMPXUPnPPlaybackDialog::ProcessCommandL( TInt aCommandId ) |
|
1762 { |
|
1763 MPX_FUNC( "CMPXUPnPPlaybackDialog::ProcessCommandL" ); |
|
1764 CAknDialog::ProcessCommandL( aCommandId ); |
|
1765 HandleCommandL( aCommandId ); |
|
1766 } |
|
1767 |
|
1768 // --------------------------------------------------------------------------- |
|
1769 // From CAknView |
|
1770 // Event handler for status pane size changes. |
|
1771 // --------------------------------------------------------------------------- |
|
1772 // |
|
1773 void CMPXUPnPPlaybackDialog::HandleStatusPaneSizeChange() |
|
1774 { |
|
1775 CMPXUPnPPlaybackDialogCustomControlContainer *control = |
|
1776 ( CMPXUPnPPlaybackDialogCustomControlContainer* ) |
|
1777 ControlOrNull ( EMPXUPnPPlaybackDlgCtrlId ); |
|
1778 if ( control ) |
|
1779 { |
|
1780 AknLayoutUtils::LayoutMetricsRect( |
|
1781 AknLayoutUtils::EMainPane, iModRect ); |
|
1782 |
|
1783 if ( iToolbar && iToolbar->IsVisible() |
|
1784 && !Layout_Meta_Data::IsLandscapeOrientation()) |
|
1785 { |
|
1786 iModRect.iBr.iY -= iToolbar->Rect().Height(); |
|
1787 } |
|
1788 control->SetRect( iModRect ); |
|
1789 control->iDialogCustomControl->SetRect( iModRect ); |
|
1790 control->iDialogCustomControl->DrawDeferred(); |
|
1791 } |
|
1792 } |
|
1793 |
|
1794 // ----------------------------------------------------------------------------- |
|
1795 // CMPXUPnPPlaybackDialog::GetUPnPPlaybackDialogCustomControl |
|
1796 // Returns the Custom Control Container. |
|
1797 // ----------------------------------------------------------------------------- |
|
1798 // |
|
1799 CMPXUPnPPlaybackDialogCustomControl *CMPXUPnPPlaybackDialog:: |
|
1800 GetUPnPPlaybackDialogCustomControl() const |
|
1801 { |
|
1802 MPX_FUNC( "CMPXUPnPPlaybackDialog::GetUPnPPlaybackDialogCustomControl" ); |
|
1803 CMPXUPnPPlaybackDialogCustomControlContainer *control = |
|
1804 ( CMPXUPnPPlaybackDialogCustomControlContainer* ) |
|
1805 ControlOrNull ( EMPXUPnPPlaybackDlgCtrlId ); |
|
1806 if ( control ) |
|
1807 { |
|
1808 return control->iDialogCustomControl; |
|
1809 } |
|
1810 return NULL; |
|
1811 } |
|
1812 |
|
1813 |
|
1814 // ----------------------------------------------------------------------------- |
|
1815 // CMPXUPnPPlaybackDialog::CreateCustomControlL |
|
1816 // Creates a Custom Control for the dialog. |
|
1817 // ----------------------------------------------------------------------------- |
|
1818 // |
|
1819 SEikControlInfo CMPXUPnPPlaybackDialog::CreateCustomControlL( |
|
1820 TInt aControlType ) |
|
1821 { |
|
1822 MPX_FUNC( "CMPXUPnPPlaybackDialog::CreateCustomControlL" ); |
|
1823 SEikControlInfo controlInfo; |
|
1824 controlInfo.iControl = NULL; |
|
1825 controlInfo.iTrailerTextId = 0; |
|
1826 controlInfo.iFlags = 0; |
|
1827 |
|
1828 switch (aControlType) |
|
1829 { |
|
1830 case EMPXUPnPPlaybackDlg: |
|
1831 { |
|
1832 controlInfo.iControl = new ( ELeave ) |
|
1833 CMPXUPnPPlaybackDialogCustomControlContainer; |
|
1834 break; |
|
1835 } |
|
1836 default: |
|
1837 { |
|
1838 break; |
|
1839 } |
|
1840 } |
|
1841 return controlInfo; |
|
1842 } |
|
1843 |
|
1844 // ----------------------------------------------------------------------------- |
|
1845 // CMPXUPnPPlaybackDialog::PreLayoutDynInitL |
|
1846 // Initialises the dialog's controls before the dialog is sized and layed out. |
|
1847 // ----------------------------------------------------------------------------- |
|
1848 // |
|
1849 void CMPXUPnPPlaybackDialog::PreLayoutDynInitL() |
|
1850 { |
|
1851 MPX_FUNC( "CMPXUPnPPlaybackDialog::PreLayoutDynInitL" ); |
|
1852 |
|
1853 iSwitchingView = EFalse; |
|
1854 |
|
1855 PrepareStatusPaneForPlaybackViewL(); |
|
1856 |
|
1857 iRandomMode = KErrNotFound; |
|
1858 iRepeatMode = KErrNotFound; |
|
1859 |
|
1860 BackupPreviousStatusPaneL(); |
|
1861 |
|
1862 // Set title |
|
1863 // Ignore errors from updating title pane since if that is not |
|
1864 // updated, still want to activate view |
|
1865 TRAP_IGNORE( |
|
1866 { |
|
1867 UpdateTitlePaneL(); |
|
1868 CAknNavigationControlContainer* naviPane( |
|
1869 static_cast<CAknNavigationControlContainer*> |
|
1870 ( iAvkonAppUi->StatusPane()->ControlL( |
|
1871 TUid::Uid( EEikStatusPaneUidNavi ) ) )); |
|
1872 if ( naviPane ) |
|
1873 { |
|
1874 naviPane->PushDefaultL(); |
|
1875 } |
|
1876 } ); |
|
1877 |
|
1878 if ( ButtonGroupContainer().ButtonGroup() ) |
|
1879 { |
|
1880 CCoeControl* control = ButtonGroupContainer().ButtonGroup()->AsControl(); |
|
1881 static_cast<CEikCba*>( control )-> |
|
1882 SetSkinBackgroundId( KAknsIIDQsnBgAreaControlMp ); |
|
1883 } |
|
1884 |
|
1885 AknLayoutUtils::LayoutMetricsRect( |
|
1886 AknLayoutUtils::EMainPane, iModRect ); |
|
1887 |
|
1888 if ( iToolbar && iToolbar->IsVisible() |
|
1889 && !Layout_Meta_Data::IsLandscapeOrientation()) |
|
1890 { |
|
1891 iModRect.iBr.iY -= iToolbar->Rect().Height(); |
|
1892 } |
|
1893 CMPXUPnPPlaybackDialogCustomControlContainer *control1 = |
|
1894 ( CMPXUPnPPlaybackDialogCustomControlContainer* ) ControlOrNull ( |
|
1895 EMPXUPnPPlaybackDlgCtrlId ); |
|
1896 CMPXUPnPPlaybackDialogCustomControl *control = NULL; |
|
1897 |
|
1898 if ( control1 ) |
|
1899 { |
|
1900 if ( !iPlaybackDialogLayout ) |
|
1901 { |
|
1902 iPlaybackDialogLayout = CMPXUPnPPlaybackDialogLayout::NewL(); |
|
1903 } |
|
1904 |
|
1905 control = CMPXUPnPPlaybackDialogCustomControl::NewL( |
|
1906 *control1, iModRect, this, this, iPlaybackDialogLayout, iCurrentPlayerType ); |
|
1907 control1->iDialogCustomControl = control; |
|
1908 GetUPnPPlaybackDialogCustomControl()->MakeVisible( ETrue ); |
|
1909 MakeVisible(EFalse); |
|
1910 } |
|
1911 |
|
1912 // Update view |
|
1913 // Ignore errors from updating labels in view since if labels |
|
1914 // are empty, still want to activate view |
|
1915 iPlaybackState = iPlaybackUtility->StateL(); |
|
1916 TRAP_IGNORE( UpdateViewL() ); |
|
1917 |
|
1918 if ( ( iPlaybackState == EPbStateInitialising ) || |
|
1919 ( iPlaybackState == EPbStateDownloading ) ) |
|
1920 { |
|
1921 delete iMedia; |
|
1922 iMedia = NULL; |
|
1923 UpdatePlaybackState( iPlaybackState ); |
|
1924 UpdateTrackInfoL( iMedia ); |
|
1925 } |
|
1926 else if ( iMedia == NULL ) |
|
1927 { |
|
1928 MMPXSource* s = iPlaybackUtility->Source(); |
|
1929 if ( s ) |
|
1930 { |
|
1931 CMPXCollectionPlaylist* playlist( s->PlaylistL() ); |
|
1932 if ( playlist ) |
|
1933 { |
|
1934 CleanupStack::PushL( playlist ); |
|
1935 if ( playlist->Count() > 0 ) |
|
1936 { |
|
1937 RequestMediaL(); |
|
1938 UpdatePlaybackState( iPlaybackState ); |
|
1939 } |
|
1940 else |
|
1941 { |
|
1942 // playlist count is 0, no tracks |
|
1943 iPlaybackState = EPbStateNotInitialised; |
|
1944 } |
|
1945 CleanupStack::PopAndDestroy( playlist ); |
|
1946 } |
|
1947 else |
|
1948 { |
|
1949 // If empty playlist, then no tracks |
|
1950 iPlaybackState = EPbStateNotInitialised; |
|
1951 } |
|
1952 } |
|
1953 } |
|
1954 |
|
1955 CAknDialog::PreLayoutDynInitL(); |
|
1956 } |
|
1957 |
|
1958 // ----------------------------------------------------------------------------- |
|
1959 // CMPXUPnPPlaybackDialog::OkToExitL |
|
1960 // This function returns whether it's ok to exit or not |
|
1961 // ----------------------------------------------------------------------------- |
|
1962 // |
|
1963 TBool CMPXUPnPPlaybackDialog::OkToExitL( TInt aButtonId ) |
|
1964 { |
|
1965 MPX_FUNC( "CMPXUPnPPlaybackDialog::OkToExitL" ); |
|
1966 TBool retVal = EFalse; |
|
1967 switch (aButtonId) |
|
1968 { |
|
1969 case EAknSoftkeyClose: |
|
1970 { |
|
1971 if ( iToolbar ) |
|
1972 { |
|
1973 iToolbar->SetToolbarVisibility( EFalse ); |
|
1974 iToolbar->SetToolbarObserver( NULL ); |
|
1975 iToolbar->RemoveItem( EMPXPbvCmdPreviousListItem ); |
|
1976 iToolbar->RemoveItem( EMPXPbvCmdPlayPause ); |
|
1977 iToolbar->RemoveItem( EMPXPbvCmdNextListItem ); |
|
1978 iToolbar = NULL; |
|
1979 } |
|
1980 if ( !Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1981 { |
|
1982 PrepareStatusPaneForExitingViewL(); |
|
1983 } |
|
1984 |
|
1985 RestorePreviousStatusPaneL(); |
|
1986 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
1987 iPlaybackUtility->CommandL( EPbCmdClose ); |
|
1988 retVal = ETrue; |
|
1989 break; |
|
1990 } |
|
1991 default: |
|
1992 { |
|
1993 retVal = CAknDialog::OkToExitL( aButtonId ); |
|
1994 break; |
|
1995 } |
|
1996 } |
|
1997 if ( retVal ) |
|
1998 { |
|
1999 iMPXUtility->CancelRequest(); |
|
2000 |
|
2001 // We need to unload the current plugin to release WLAN connection |
|
2002 iPlaybackUtility->PlayerManager().ClearSelectPlayersL(); |
|
2003 } |
|
2004 return retVal; |
|
2005 } |
|
2006 |
|
2007 // ----------------------------------------------------------------------------- |
|
2008 // CMPXUPnPPlaybackDialog::BackupPreviousStatusPaneL |
|
2009 // Backs up Status Pane information. |
|
2010 // ----------------------------------------------------------------------------- |
|
2011 // |
|
2012 void CMPXUPnPPlaybackDialog::BackupPreviousStatusPaneL() |
|
2013 { |
|
2014 MPX_FUNC( "CMPXUPnPPlaybackDialog::BackupPreviousStatusPaneL" ); |
|
2015 CEikStatusPane* sp = iAvkonAppUi->StatusPane(); |
|
2016 // Backup navi pane |
|
2017 iNaviPane = static_cast< CAknNavigationControlContainer* > |
|
2018 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
2019 |
|
2020 // Backup title pane |
|
2021 iTitlePane = static_cast< CAknTitlePane* > |
|
2022 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
2023 iOrigTitle = iTitlePane->Text()->AllocL(); |
|
2024 } |
|
2025 |
|
2026 // ----------------------------------------------------------------------------- |
|
2027 // CMPXUPnPPlaybackDialog::RestorePreviousStatusPaneL() |
|
2028 // Restores previous status pane. |
|
2029 // ----------------------------------------------------------------------------- |
|
2030 // |
|
2031 void CMPXUPnPPlaybackDialog::RestorePreviousStatusPaneL() |
|
2032 { |
|
2033 MPX_FUNC( "CMPXUPnPPlaybackDialog::RestorePreviousStatusPaneL" ); |
|
2034 if ( iOrigTitle && iTitlePane ) |
|
2035 { |
|
2036 // Set original title pane |
|
2037 iTitlePane->SetTextL( *iOrigTitle ); |
|
2038 } |
|
2039 // Set original navi pane |
|
2040 if ( iNaviPane ) |
|
2041 { |
|
2042 iNaviPane->Pop(); |
|
2043 } |
|
2044 } |
|
2045 |
|
2046 // --------------------------------------------------------------------------- |
|
2047 // From MEikMenuObserver |
|
2048 // Dynamically initialises a menu pane. |
|
2049 // --------------------------------------------------------------------------- |
|
2050 // |
|
2051 void CMPXUPnPPlaybackDialog::DynInitMenuPaneL( |
|
2052 TInt aResourceId, |
|
2053 CEikMenuPane* aMenuPane ) |
|
2054 { |
|
2055 MPX_FUNC( "CMPXUPnPPlaybackDialog::DynInitMenuPaneL" ); |
|
2056 CAknDialog::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
2057 } |
|
2058 |
|
2059 // ----------------------------------------------------------------------------- |
|
2060 // CMPXUPnPPlaybackDialog::CountComponentControls |
|
2061 // Counts the number of components. |
|
2062 // ----------------------------------------------------------------------------- |
|
2063 // |
|
2064 TInt CMPXUPnPPlaybackDialog::CountComponentControls() const |
|
2065 { |
|
2066 MPX_FUNC( "CMPXUPnPPlaybackDialog::CountComponentControls" ); |
|
2067 TInt newitems = 0; |
|
2068 if ( GetUPnPPlaybackDialogCustomControl() ) newitems++; |
|
2069 return CAknDialog::CountComponentControls() + newitems; |
|
2070 } |
|
2071 |
|
2072 // ----------------------------------------------------------------------------- |
|
2073 // CMPXUPnPPlaybackDialog::ComponentControl |
|
2074 // Returns component control. |
|
2075 // ----------------------------------------------------------------------------- |
|
2076 // |
|
2077 CCoeControl* CMPXUPnPPlaybackDialog::ComponentControl( TInt aIndex ) const |
|
2078 { |
|
2079 MPX_FUNC( "CMPXUPnPPlaybackDialog::ComponentControl" ); |
|
2080 if (aIndex == CAknDialog::CountComponentControls() ) |
|
2081 { |
|
2082 return GetUPnPPlaybackDialogCustomControl(); |
|
2083 } |
|
2084 return CAknDialog::ComponentControl( aIndex ); |
|
2085 } |
|
2086 |
|
2087 // --------------------------------------------------------------------------- |
|
2088 // From CCoeControl |
|
2089 // Handles key events. |
|
2090 // --------------------------------------------------------------------------- |
|
2091 // |
|
2092 TKeyResponse CMPXUPnPPlaybackDialog::OfferKeyEventL( |
|
2093 const TKeyEvent& aKeyEvent, |
|
2094 TEventCode aType ) |
|
2095 { |
|
2096 MPX_FUNC( "CMPXUPnPPlaybackDialog::OfferKeyEventL()" ); |
|
2097 MPX_DEBUG4( "CMPXUPnPPlaybackDialog::OfferKeyEventL(iCode=%d, iScanCode=%d, aType=%d)", |
|
2098 aKeyEvent.iCode, aKeyEvent.iScanCode, aType ); |
|
2099 |
|
2100 TKeyResponse keyResponse( EKeyWasNotConsumed ); |
|
2101 |
|
2102 if ( ( iLastKeyEvent.iScanCode == aKeyEvent.iScanCode ) && |
|
2103 ( iLastKeyType == aType ) && |
|
2104 ( iLastKeyType == EEventKeyUp ) ) |
|
2105 { |
|
2106 keyResponse = EKeyWasConsumed; |
|
2107 } |
|
2108 else |
|
2109 { |
|
2110 iLastKeyEvent = aKeyEvent; |
|
2111 iLastKeyType = aType; |
|
2112 |
|
2113 // End key was pressed and dialog needs to close |
|
2114 if ( aKeyEvent.iCode == EKeyEscape ) |
|
2115 { |
|
2116 TryExitL(EAknSoftkeyClose); |
|
2117 keyResponse = EKeyWasConsumed; |
|
2118 } |
|
2119 else |
|
2120 { |
|
2121 if ( GetUPnPPlaybackDialogCustomControl() ) |
|
2122 { |
|
2123 keyResponse = GetUPnPPlaybackDialogCustomControl()->OfferKeyEventL( |
|
2124 aKeyEvent, |
|
2125 aType ); |
|
2126 } |
|
2127 } |
|
2128 } |
|
2129 return keyResponse; |
|
2130 } |
|
2131 |
|
2132 // --------------------------------------------------------------------------- |
|
2133 // From MMPXCustomCommandObserver. |
|
2134 // Handle custom commands. |
|
2135 // --------------------------------------------------------------------------- |
|
2136 // |
|
2137 void CMPXUPnPPlaybackDialog::HandleMediaKeyCommand( |
|
2138 const TMPXPlaybackCommand aCommand, |
|
2139 const TInt aData ) |
|
2140 { |
|
2141 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandleMediaKeyCommand()" ); |
|
2142 |
|
2143 switch ( aCommand ) |
|
2144 { |
|
2145 case EPbCmdSetVolume: |
|
2146 { |
|
2147 TMPXPlaybackState playerState( iPlaybackUtility->StateL() ); |
|
2148 if ( iAvkonAppUi->IsForeground() || playerState == EPbStatePlaying ) |
|
2149 { |
|
2150 if ( aData != iCurrentVolume ) |
|
2151 { |
|
2152 SetVolume( aData ); |
|
2153 } |
|
2154 // popup volume control even if volume didn't change |
|
2155 HandlePopupL( EPbCmdSetVolume ); |
|
2156 } |
|
2157 break; |
|
2158 } |
|
2159 case EPbCmdMuteVolume: |
|
2160 { |
|
2161 TMPXPlaybackState playerState( iPlaybackUtility->StateL() ); |
|
2162 if ( iAvkonAppUi->IsForeground() || playerState == EPbStatePlaying ) |
|
2163 { |
|
2164 MuteVolume(); |
|
2165 HandlePopupL( EPbCmdMuteVolume ); |
|
2166 } |
|
2167 break; |
|
2168 } |
|
2169 case EPbCmdUnMuteVolume: |
|
2170 { |
|
2171 TMPXPlaybackState playerState( iPlaybackUtility->StateL() ); |
|
2172 if ( iAvkonAppUi->IsForeground() || playerState == EPbStatePlaying ) |
|
2173 { |
|
2174 UnMuteVolume(); |
|
2175 HandlePopupL( EPbCmdUnMuteVolume ); |
|
2176 } |
|
2177 break; |
|
2178 } |
|
2179 default: |
|
2180 { |
|
2181 if ( iAvkonAppUi->IsForeground() ) |
|
2182 { |
|
2183 // Forward the command to handle when |
|
2184 // music is foreground app and not displaying |
|
2185 // dialogs |
|
2186 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::HandleCustomCommand sending command %d to view", aCommand ); |
|
2187 TRAP_IGNORE( DoHandleMediaKeyCommandL( aCommand ) ); |
|
2188 } |
|
2189 else |
|
2190 { |
|
2191 TMPXPlaybackState playerState( EPbStateNotInitialised ); |
|
2192 TRAP_IGNORE( playerState = iPlaybackUtility->StateL() ); |
|
2193 // displaying not foreground, pass to view to handle only play command |
|
2194 if ( playerState == EPbStatePlaying || |
|
2195 playerState == EPbStatePaused || |
|
2196 playerState == EPbStateSeekingForward || |
|
2197 playerState == EPbStateSeekingBackward ) |
|
2198 { |
|
2199 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::HandleCustomCommand not foreground, sending command %d to HandleMediaKeyCommandL", aCommand ); |
|
2200 TRAP_IGNORE( DoHandleMediaKeyCommandL( aCommand ) ); |
|
2201 } |
|
2202 else if ( aCommand == EPbCmdPlay || aCommand == EPbCmdPlayPause ) |
|
2203 { |
|
2204 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::HandleCustomCommand not foreground, active idle foreground, sending command %d to HandleMediaKeyCommandL", aCommand ); |
|
2205 // not foreground, play without loading playback view |
|
2206 TRAP_IGNORE( DoHandleMediaKeyCommandL( aCommand ) ); |
|
2207 } |
|
2208 else |
|
2209 { |
|
2210 MPX_DEBUG2( "CMPXUPnPPlaybackDialog::HandleCustomCommand not foreground, inactive state, command %d ignored", aCommand ); |
|
2211 } |
|
2212 } |
|
2213 } |
|
2214 } |
|
2215 } |
|
2216 |
|
2217 // --------------------------------------------------------------------------- |
|
2218 // Additional handling of media key commands. |
|
2219 // Determine if the command will be passed to the playback engine. |
|
2220 // --------------------------------------------------------------------------- |
|
2221 // |
|
2222 void CMPXUPnPPlaybackDialog::DoHandleMediaKeyCommandL( |
|
2223 TMPXPlaybackCommand aCommand ) |
|
2224 { |
|
2225 MPX_FUNC( "CMPXUPnPPlaybackDialog::DoHandleMediaKeyCommandL()" ); |
|
2226 |
|
2227 TBool handleCommand(EFalse); |
|
2228 TMPXPlaybackState playerState( iPlaybackUtility->StateL() ); |
|
2229 |
|
2230 switch ( aCommand ) |
|
2231 { |
|
2232 case EPbCmdPlay: |
|
2233 case EPbCmdPause: |
|
2234 case EPbCmdPlayPause: |
|
2235 case EPbCmdStop: |
|
2236 case EPbCmdNext: |
|
2237 case EPbCmdPrevious: |
|
2238 handleCommand = ETrue; |
|
2239 break; |
|
2240 case EPbCmdStartSeekForward: |
|
2241 { |
|
2242 if ( iCurrentPlayerType == EPbLocal && |
|
2243 ( EPbStatePlaying == playerState || |
|
2244 EPbStatePaused == playerState || |
|
2245 EPbStateSeekingBackward == playerState ) ) |
|
2246 { |
|
2247 handleCommand = ETrue; |
|
2248 } |
|
2249 break; |
|
2250 } |
|
2251 case EPbCmdStartSeekBackward: |
|
2252 { |
|
2253 if ( iCurrentPlayerType == EPbLocal && |
|
2254 ( EPbStatePlaying == playerState || |
|
2255 EPbStatePaused == playerState || |
|
2256 EPbStateSeekingForward == playerState ) ) |
|
2257 { |
|
2258 handleCommand = ETrue; |
|
2259 } |
|
2260 break; |
|
2261 } |
|
2262 case EPbCmdStopSeeking: |
|
2263 { |
|
2264 if ( iCurrentPlayerType == EPbLocal && |
|
2265 ( EPbStateSeekingForward == playerState || |
|
2266 EPbStateSeekingBackward == playerState ) ) |
|
2267 { |
|
2268 handleCommand = ETrue; |
|
2269 } |
|
2270 // Do nothing, not supported by UPnP |
|
2271 break; |
|
2272 } |
|
2273 default: |
|
2274 { |
|
2275 // Do nothing |
|
2276 break; |
|
2277 } |
|
2278 } |
|
2279 |
|
2280 if ( handleCommand ) |
|
2281 { |
|
2282 iPlaybackUtility->CommandL( aCommand ); |
|
2283 |
|
2284 // Control popup behaviour |
|
2285 HandlePopupL( aCommand ); |
|
2286 } |
|
2287 } |
|
2288 |
|
2289 // ----------------------------------------------------------------------------- |
|
2290 // Control popup behaviour. |
|
2291 // ----------------------------------------------------------------------------- |
|
2292 // |
|
2293 void CMPXUPnPPlaybackDialog::HandlePopupL( |
|
2294 TMPXPlaybackCommand aCommand ) |
|
2295 { |
|
2296 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandlePopupL" ); |
|
2297 |
|
2298 switch ( aCommand ) |
|
2299 { |
|
2300 case EPbCmdStop: |
|
2301 { |
|
2302 iMediaKeyHandler->DismissNotifier( EDisplayMediaPopup ); |
|
2303 break; |
|
2304 } |
|
2305 case EPbCmdSetVolume: |
|
2306 case EPbCmdMuteVolume: |
|
2307 case EPbCmdUnMuteVolume: |
|
2308 { |
|
2309 if ( iAvkonAppUi->IsForeground() ) |
|
2310 { |
|
2311 // display pop up volume control |
|
2312 iMediaKeyHandler->ShowVolumePopupL(); |
|
2313 } |
|
2314 break; |
|
2315 } |
|
2316 default: |
|
2317 { |
|
2318 // Do nothing |
|
2319 break; |
|
2320 } |
|
2321 } |
|
2322 } |
|
2323 |
|
2324 // --------------------------------------------------------------------------- |
|
2325 // From CCoeControl |
|
2326 // Handles a change to the control's resources. |
|
2327 // --------------------------------------------------------------------------- |
|
2328 // |
|
2329 void CMPXUPnPPlaybackDialog::HandleResourceChange( TInt aType ) |
|
2330 { |
|
2331 if ( GetUPnPPlaybackDialogCustomControl() ) |
|
2332 { |
|
2333 GetUPnPPlaybackDialogCustomControl()->HandleResourceChange( aType ); |
|
2334 } |
|
2335 } |
|
2336 |
|
2337 // --------------------------------------------------------------------------- |
|
2338 // From MMPXLayoutSwitchObserver |
|
2339 // Callback function when layout is changed. |
|
2340 // --------------------------------------------------------------------------- |
|
2341 // |
|
2342 void CMPXUPnPPlaybackDialog::HandleLayoutChange() |
|
2343 { |
|
2344 MPX_FUNC( "CMPXUPnPPlaybackDialog::HandleLayoutChange()" ); |
|
2345 |
|
2346 if (GetUPnPPlaybackDialogCustomControl() && !iSwitchingView) |
|
2347 { |
|
2348 if ( !Layout_Meta_Data::IsLandscapeOrientation() ) |
|
2349 { |
|
2350 if ( iAvkonAppUi->StatusPane()->CurrentLayoutResId() != |
|
2351 R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT ) |
|
2352 { |
|
2353 TRAP_IGNORE( |
|
2354 iAvkonAppUi->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT )); |
|
2355 } |
|
2356 } |
|
2357 else |
|
2358 { |
|
2359 if ( iAvkonAppUi->StatusPane()->CurrentLayoutResId() != |
|
2360 R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
|
2361 { |
|
2362 TRAP_IGNORE( |
|
2363 iAvkonAppUi->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL )); |
|
2364 } |
|
2365 } |
|
2366 |
|
2367 AknLayoutUtils::LayoutMetricsRect( |
|
2368 AknLayoutUtils::EMainPane, iModRect ); |
|
2369 |
|
2370 if ( iToolbar && iToolbar->IsVisible() |
|
2371 && !Layout_Meta_Data::IsLandscapeOrientation()) |
|
2372 { |
|
2373 iModRect.iBr.iY -= iToolbar->Rect().Height(); |
|
2374 } |
|
2375 GetUPnPPlaybackDialogCustomControl()->SetRect( iModRect ); |
|
2376 |
|
2377 // Update album art |
|
2378 TRAP_IGNORE( UpdateAlbumArtL( iMedia )); |
|
2379 |
|
2380 GetUPnPPlaybackDialogCustomControl()->DrawDeferred(); |
|
2381 } |
|
2382 } |
|
2383 |
|
2384 // ----------------------------------------------------------------------------- |
|
2385 // CMPXUPnPPlaybackDialog::CommandNotSupportedL |
|
2386 // Shows a Not supported error note |
|
2387 // ----------------------------------------------------------------------------- |
|
2388 // |
|
2389 void CMPXUPnPPlaybackDialog::CommandNotSupportedL() |
|
2390 { |
|
2391 HBufC* dialogText = StringLoader::LoadLC(R_MPX_MEDIA_KEYS_NOT_SUPPORTED); |
|
2392 CAknErrorNote* errNote = new(ELeave) CAknErrorNote(ETrue); |
|
2393 errNote->ExecuteLD( *dialogText ); |
|
2394 CleanupStack::PopAndDestroy( dialogText ); |
|
2395 } |
|
2396 |
|
2397 // ----------------------------------------------------------------------------- |
|
2398 // Exits the dialog when callback from CIdle |
|
2399 // ----------------------------------------------------------------------------- |
|
2400 // |
|
2401 TInt CMPXUPnPPlaybackDialog::DelayedExit( TAny* aPtr ) |
|
2402 { |
|
2403 CMPXUPnPPlaybackDialog* upnpPlaybackDialog = |
|
2404 static_cast<CMPXUPnPPlaybackDialog*>(aPtr); |
|
2405 |
|
2406 TRAP_IGNORE(upnpPlaybackDialog->TryExitL(EAknSoftkeyClose)); |
|
2407 return EFalse; |
|
2408 } |
|
2409 |
|
2410 // ----------------------------------------------------------------------------- |
|
2411 // CMPXUPnPPlaybackDialog::SetVolume |
|
2412 // ----------------------------------------------------------------------------- |
|
2413 // |
|
2414 void CMPXUPnPPlaybackDialog::SetVolume( const TInt aVolume ) |
|
2415 { |
|
2416 CMPXCommand* cmd( CMPXCommand::NewL() ); |
|
2417 CleanupStack::PushL( cmd ); |
|
2418 cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral ); |
|
2419 cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue ); |
|
2420 cmd->SetTObjectValueL<TBool>( KMPXCommandPlaybackGeneralNoBuffer, ETrue ); |
|
2421 cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralType, EPbCmdSetVolume ); |
|
2422 cmd->SetTObjectValueL<TUint>( KMPXCommandPlaybackGeneralData, aVolume ); |
|
2423 iPlaybackUtility->CommandL( *cmd ); |
|
2424 CleanupStack::PopAndDestroy( cmd ); |
|
2425 } |
|
2426 |
|
2427 // ----------------------------------------------------------------------------- |
|
2428 // CMPXUPnPPlaybackDialog::MuteVolume |
|
2429 // ----------------------------------------------------------------------------- |
|
2430 // |
|
2431 void CMPXUPnPPlaybackDialog::MuteVolume() |
|
2432 { |
|
2433 CMPXCommand* cmd( CMPXCommand::NewL() ); |
|
2434 CleanupStack::PushL( cmd ); |
|
2435 cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral ); |
|
2436 cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue ); |
|
2437 cmd->SetTObjectValueL<TBool>( KMPXCommandPlaybackGeneralNoBuffer, ETrue ); |
|
2438 cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralType, EPbCmdMuteVolume ); |
|
2439 iPlaybackUtility->CommandL( *cmd ); |
|
2440 CleanupStack::PopAndDestroy( cmd ); |
|
2441 } |
|
2442 |
|
2443 // ----------------------------------------------------------------------------- |
|
2444 // CMPXUPnPPlaybackDialog::UnMuteVolume |
|
2445 // ----------------------------------------------------------------------------- |
|
2446 // |
|
2447 void CMPXUPnPPlaybackDialog::UnMuteVolume() |
|
2448 { |
|
2449 CMPXCommand* cmd( CMPXCommand::NewL() ); |
|
2450 CleanupStack::PushL( cmd ); |
|
2451 cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral ); |
|
2452 cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue ); |
|
2453 cmd->SetTObjectValueL<TBool>( KMPXCommandPlaybackGeneralNoBuffer, ETrue ); |
|
2454 cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralType, EPbCmdUnMuteVolume ); |
|
2455 iPlaybackUtility->CommandL( *cmd ); |
|
2456 CleanupStack::PopAndDestroy( cmd ); |
|
2457 } |
|
2458 |
|
2459 // --------------------------------------------------------------------------- |
|
2460 // Updates the middle toolbar button |
|
2461 // --------------------------------------------------------------------------- |
|
2462 // |
|
2463 void CMPXUPnPPlaybackDialog::UpdateToolbar() |
|
2464 { |
|
2465 if ( AknLayoutUtils::PenEnabled() ) |
|
2466 { |
|
2467 MPX_DEBUG1("AknLayoutUtils::PenEnabled() : true"); |
|
2468 if ( iToolbar && iToolbar->IsVisible()) |
|
2469 { |
|
2470 MPX_DEBUG1("Toolbar() : true"); |
|
2471 iToolbar->SetDimmed( EFalse ); |
|
2472 CAknButton* pausePlayControl; |
|
2473 CAknButton* skipControl; |
|
2474 pausePlayControl = (CAknButton*)(iToolbar->ComponentControl( 1 )); |
|
2475 MMPXSource* s = iPlaybackUtility->Source(); |
|
2476 if ( s ) |
|
2477 { |
|
2478 CMPXCollectionPlaylist* playlist = s->PlaylistL(); |
|
2479 if ( playlist ) |
|
2480 { |
|
2481 if ( playlist->Count() > 0 ) |
|
2482 { |
|
2483 if( pausePlayControl ) |
|
2484 { |
|
2485 TMPXPlaybackState state = iPlaybackUtility->StateL(); |
|
2486 if ((state == EPbStateInitialising) || (state == EPbStatePlaying)) |
|
2487 { |
|
2488 pausePlayControl->SetCurrentState(0, ETrue); |
|
2489 } |
|
2490 else |
|
2491 { |
|
2492 pausePlayControl->SetCurrentState(1, ETrue); |
|
2493 } |
|
2494 } |
|
2495 } |
|
2496 |
|
2497 delete playlist; |
|
2498 } |
|
2499 else |
|
2500 { |
|
2501 if( pausePlayControl ) |
|
2502 { |
|
2503 TMPXPlaybackState state = iPlaybackUtility->StateL(); |
|
2504 if ( ( state == EPbStateInitialising ) || |
|
2505 ( state == EPbStatePlaying ) ) |
|
2506 { |
|
2507 pausePlayControl->SetCurrentState( 0, ETrue ); |
|
2508 } |
|
2509 else |
|
2510 { |
|
2511 pausePlayControl->SetCurrentState( 1, ETrue ); |
|
2512 } |
|
2513 } |
|
2514 } |
|
2515 skipControl = (CAknButton*)(iToolbar->ComponentControl( 0 )); |
|
2516 if( skipControl ) |
|
2517 { |
|
2518 skipControl->SetCurrentState(1,ETrue); |
|
2519 } |
|
2520 |
|
2521 skipControl = (CAknButton*)(iToolbar->ComponentControl( 2 )); |
|
2522 if( skipControl ) |
|
2523 { |
|
2524 skipControl->SetCurrentState(1,ETrue); |
|
2525 } |
|
2526 } |
|
2527 else |
|
2528 { |
|
2529 iToolbar->SetDimmed( ETrue ); |
|
2530 } |
|
2531 } |
|
2532 else |
|
2533 { |
|
2534 MPX_DEBUG1("Toolbar() : false"); |
|
2535 } |
|
2536 } |
|
2537 } |
|
2538 // ----------------------------------------------------------------------------- |
|
2539 // From MAknToolbarObserver |
|
2540 // Used to change toolbar settings before toolbar becomes visible |
|
2541 // ----------------------------------------------------------------------------- |
|
2542 // |
|
2543 void CMPXUPnPPlaybackDialog::DynInitToolbarL(TInt aResourceId, CAknToolbar* aToolbar) |
|
2544 { |
|
2545 CAknAppUi* appUi = static_cast<CAknAppUi*>( CCoeEnv::Static()->AppUi()); |
|
2546 CAknToolbar* toolbar = appUi->CurrentFixedToolbar(); |
|
2547 if ( toolbar == aToolbar ) |
|
2548 { |
|
2549 // Put initializations here to take effect before toolbar is shown |
|
2550 UpdateToolbar(); |
|
2551 aToolbar->UpdateBackground(); |
|
2552 } |
|
2553 } |
|
2554 |
|
2555 // ----------------------------------------------------------------------------- |
|
2556 // From MAknToolbarObserver |
|
2557 // Handles toolbar events |
|
2558 // ----------------------------------------------------------------------------- |
|
2559 // |
|
2560 void CMPXUPnPPlaybackDialog::OfferToolbarEventL( TInt aCommandId ) |
|
2561 { |
|
2562 TInt commandId = aCommandId; |
|
2563 TInt eventModifiers = iToolbar->EventModifiers(); |
|
2564 if ( eventModifiers == CAknToolbar::ELongPress ) |
|
2565 { |
|
2566 if ( aCommandId == EMPXPbvCmdNextListItem ) |
|
2567 { |
|
2568 commandId = EMPXPbvCmdSeekForward; |
|
2569 } |
|
2570 else if ( aCommandId == EMPXPbvCmdPreviousListItem ) |
|
2571 { |
|
2572 commandId = EMPXPbvCmdSeekBackward; |
|
2573 } |
|
2574 } |
|
2575 else if ( eventModifiers == CAknToolbar::ELongPressEnded ) |
|
2576 { |
|
2577 if ( aCommandId == EMPXPbvCmdNextListItem || aCommandId == EMPXPbvCmdPreviousListItem ) |
|
2578 { |
|
2579 commandId = EMPXPbvCmdEndSeek; |
|
2580 } |
|
2581 } |
|
2582 |
|
2583 HandleCommandL( commandId ); |
|
2584 } |
|
2585 // End of File |