107 iAccessPoint(0), |
107 iAccessPoint(0), |
108 iAccessPointSet(EFalse), |
108 iAccessPointSet(EFalse), |
109 iState(EPbStateNotInitialised), |
109 iState(EPbStateNotInitialised), |
110 iNextState(EPbStateNotInitialised), |
110 iNextState(EPbStateNotInitialised), |
111 iPluginState(EPbStateNotInitialised), |
111 iPluginState(EPbStateNotInitialised), |
|
112 iCategory(EMPXCategoryUndefined), |
112 iModeId(aModeId), |
113 iModeId(aModeId), |
113 iObserver(aObserver), |
114 iObserver(aObserver), |
114 iPreservedState( EPbStateNotInitialised ), |
115 iPreservedState( EPbStateNotInitialised ), |
115 iPreservedPosition( KErrNotFound ), |
116 iPreservedPosition( KErrNotFound ), |
116 iSkipping(EFalse), |
117 iSkipping(EFalse), |
117 iPluginUid(KNullUid), |
118 iPluginUid(KNullUid), |
118 iLastActiveProcess(KNullProcessId), |
119 iLastActiveProcess(KNullProcessId), |
119 iLastInactiveProcess(KNullProcessId) |
120 iLastInactiveProcess(KNullProcessId), |
|
121 iPositionFromMedia( KErrNotFound ) |
120 { |
122 { |
121 iProperties[EPbPropertyVolumeRamp]=KPbFadeInDurationMicroSeconds; |
123 iProperties[EPbPropertyVolumeRamp]=KPbFadeInDurationMicroSeconds; |
122 } |
124 } |
123 |
125 |
124 // ---------------------------------------------------------------------------- |
126 // ---------------------------------------------------------------------------- |
138 iAccessPointSet(EFalse), |
140 iAccessPointSet(EFalse), |
139 iState(EPbStateNotInitialised), |
141 iState(EPbStateNotInitialised), |
140 iNextState(EPbStateNotInitialised), |
142 iNextState(EPbStateNotInitialised), |
141 iPluginState(EPbStateNotInitialised), |
143 iPluginState(EPbStateNotInitialised), |
142 iModeId(aModeId), |
144 iModeId(aModeId), |
|
145 iCategory(aCategory), |
143 iObserver(aObserver), |
146 iObserver(aObserver), |
144 iPreservedState( EPbStateNotInitialised ), |
147 iPreservedState( EPbStateNotInitialised ), |
145 iPreservedPosition( KErrNotFound ), |
148 iPreservedPosition( KErrNotFound ), |
146 iSkipping(EFalse), |
149 iSkipping(EFalse), |
147 iPluginUid(KNullUid), |
150 iPluginUid(KNullUid), |
148 iLastActiveProcess(KNullProcessId), |
151 iLastActiveProcess(KNullProcessId), |
149 iLastInactiveProcess(KNullProcessId), |
152 iLastInactiveProcess(KNullProcessId), |
150 iCategory(aCategory) |
153 iPositionFromMedia( KErrNotFound ) |
151 { |
154 { |
152 iProperties[EPbPropertyVolumeRamp]=KPbFadeInDurationMicroSeconds; |
155 iProperties[EPbPropertyVolumeRamp]=KPbFadeInDurationMicroSeconds; |
153 } |
156 } |
154 |
157 |
155 |
158 |
178 iVolumeIncrement = KMPXLargeVolumeIncrement; |
181 iVolumeIncrement = KMPXLargeVolumeIncrement; |
179 #endif |
182 #endif |
180 |
183 |
181 iMediaHelper = CMPXPlaybackMediaHelper::NewL( *this ); |
184 iMediaHelper = CMPXPlaybackMediaHelper::NewL( *this ); |
182 iDummyMediaObserver = new(ELeave) CMPXPlaybackDummyMediaObserver(); |
185 iDummyMediaObserver = new(ELeave) CMPXPlaybackDummyMediaObserver(); |
183 // Select local plugin by default if none selected |
186 iInitVolume = EFalse; |
184 iPluginHandler->SelectPlayersL( EPbLocal ); |
187 |
185 iInitVolume = ETrue; |
188 if (iCategory != EMPXCategoryVideo) |
|
189 { |
|
190 // Select local plugin by default if none selected |
|
191 iPluginHandler->SelectPlayersL( EPbLocal ); |
|
192 iInitVolume = ETrue; |
|
193 iPluginHandler->Plugin()->PropertyL( EPbPropertyVolume ); |
|
194 } |
|
195 |
186 #if defined(__HIGH_RESOLUTION_VOLUME) |
196 #if defined(__HIGH_RESOLUTION_VOLUME) |
187 iVolRoundedUp = EFalse; |
197 iVolRoundedUp = EFalse; |
188 #endif |
198 #endif |
189 iPluginHandler->Plugin()->PropertyL( EPbPropertyVolume ); |
199 |
190 iSyncMsgTimer = CPeriodic::NewL( CActive::EPriorityIdle ); |
200 iSyncMsgTimer = CPeriodic::NewL( CActive::EPriorityIdle ); |
191 iSyncMsgWait = new (ELeave) CActiveSchedulerWait; |
201 iSyncMsgWait = new (ELeave) CActiveSchedulerWait; |
192 } |
202 iProperties[EPbPropertyPosition] = 0; |
|
203 } |
193 |
204 |
194 // ---------------------------------------------------------------------------- |
205 // ---------------------------------------------------------------------------- |
195 // Destructor |
206 // Destructor |
196 // ---------------------------------------------------------------------------- |
207 // ---------------------------------------------------------------------------- |
197 // |
208 // |
302 iClientList->SendMsgL( |
313 iClientList->SendMsgL( |
303 TMPXPlaybackMessage( |
314 TMPXPlaybackMessage( |
304 TMPXPlaybackMessage::EInitializeComplete, |
315 TMPXPlaybackMessage::EInitializeComplete, |
305 0, |
316 0, |
306 EFalse)); |
317 EFalse)); |
307 |
318 |
308 iPluginUid = iPluginHandler->Plugin()->Uid(); |
319 if ( iPluginHandler->PlayerFound() ) |
|
320 { |
|
321 iPluginUid = iPluginHandler->Plugin()->Uid(); |
|
322 } |
309 |
323 |
310 RArray<TMPXAttribute> dummy; |
324 RArray<TMPXAttribute> dummy; |
311 CleanupClosePushL( dummy ); |
325 CleanupClosePushL( dummy ); |
312 dummy.AppendL( KMPXMediaGeneralUri ); // dummy attribute to get |
326 dummy.AppendL( KMPXMediaGeneralUri ); // dummy attribute to get |
313 iPlaylist->MediaL( dummy.Array(), *iDummyMediaObserver); |
327 iPlaylist->MediaL( dummy.Array(), *iDummyMediaObserver); |
1461 // Check if position is not past the duration |
1475 // Check if position is not past the duration |
1462 if ( iProperties[EPbPropertyPosition] >= iProperties[EPbPropertyDuration] ) |
1476 if ( iProperties[EPbPropertyPosition] >= iProperties[EPbPropertyDuration] ) |
1463 { |
1477 { |
1464 iProperties[EPbPropertyPosition] = 0; |
1478 iProperties[EPbPropertyPosition] = 0; |
1465 } |
1479 } |
1466 |
|
1467 // Set position to restore saved position. |
|
1468 TRAP_IGNORE( // uPnP leaves if set position in stop state |
|
1469 PluginL()->SetL( EPbPropertyPosition, iProperties[EPbPropertyPosition] )); |
|
1470 |
1480 |
1471 iAutoResumeHandler->HandleOpenFileComplete(); |
1481 iAutoResumeHandler->HandleOpenFileComplete(); |
1472 |
1482 |
1473 // Check if playback should not be started automatically. |
1483 // Check if playback should not be started automatically. |
1474 if ( iAccessPoint || ( iPlaylist && (!iPlaylist->AutoPlay()) ) ) |
1484 if ( iAccessPoint || ( iPlaylist && (!iPlaylist->AutoPlay()) ) ) |
1993 EPbStateInitialising, |
2003 EPbStateInitialising, |
1994 index ); |
2004 index ); |
1995 SetStateL( msg ); |
2005 SetStateL( msg ); |
1996 iProperties[EPbPropertyPosition]=0; |
2006 iProperties[EPbPropertyPosition]=0; |
1997 |
2007 |
|
2008 if ( KErrNotFound != iPreservedPosition ) |
|
2009 { |
|
2010 iProperties[EPbPropertyPosition] = iPreservedPosition; |
|
2011 iPreservedPosition = KErrNotFound; |
|
2012 } |
|
2013 else if ( KErrNotFound != iPositionFromMedia ) |
|
2014 { |
|
2015 iProperties[EPbPropertyPosition] = iPositionFromMedia; |
|
2016 iPositionFromMedia = KErrNotFound; |
|
2017 } |
|
2018 MPX_DEBUG2("CMPXPlaybackEngine::InitL iPropertyPosition %d", iProperties[EPbPropertyPosition] ); |
|
2019 |
1998 // make sure our interface is supported |
2020 // make sure our interface is supported |
1999 CDesCArray* interfaces = iPluginHandler->SupportedInterfacesL( p->Uid() ); |
2021 CDesCArray* interfaces = iPluginHandler->SupportedInterfacesL( p->Uid() ); |
2000 TBool version2InterfaceSupported = EFalse; |
2022 TBool version2InterfaceSupported = EFalse; |
2001 if (interfaces->MdcaCount()) |
2023 if (interfaces->MdcaCount()) |
2002 { |
2024 { |
2016 { |
2038 { |
2017 if ( iAccessPointSet ) |
2039 if ( iAccessPointSet ) |
2018 { |
2040 { |
2019 if (aSong && aType) |
2041 if (aSong && aType) |
2020 { |
2042 { |
2021 plugin->InitStreamingL( *aSong, *aType, aAccessPoint ); |
2043 plugin->InitStreamingL( *aSong, *aType, aAccessPoint, iProperties[EPbPropertyPosition] ); |
2022 } |
2044 } |
2023 else if (aFile) |
2045 else if (aFile) |
2024 { |
2046 { |
2025 plugin->InitStreamingL( *aFile, aAccessPoint ); |
2047 plugin->InitStreamingL( *aFile, aAccessPoint, iProperties[EPbPropertyPosition] ); |
2026 } |
2048 } |
2027 } |
2049 } |
2028 else |
2050 else |
2029 { |
2051 { |
2030 if (aSong && aType) |
2052 if (aSong && aType) |
2031 { |
2053 { |
2032 plugin->InitialiseL( *aSong ); |
2054 plugin->InitialiseWithPositionL( *aSong, iProperties[EPbPropertyPosition] ); |
2033 } |
2055 } |
2034 else if (aFile) |
2056 else if (aFile) |
2035 { |
2057 { |
2036 plugin->InitialiseL( *aFile ); |
2058 plugin->InitialiseWithPositionL( *aFile, iProperties[EPbPropertyPosition] ); |
2037 } |
2059 } |
2038 } |
2060 } |
2039 } |
2061 } |
2040 else // if (plugin) |
2062 else // if (plugin) |
2041 { |
2063 { |
2254 { |
2276 { |
2255 aError = KErrNotFound; |
2277 aError = KErrNotFound; |
2256 } |
2278 } |
2257 else |
2279 else |
2258 { |
2280 { |
|
2281 RestorePlaybackPositionL( aMedia ); |
2259 TRAP( aError, InitL( iUri, mimeType, NULL, iAccessPoint) ); |
2282 TRAP( aError, InitL( iUri, mimeType, NULL, iAccessPoint) ); |
2260 /* |
2283 /* |
2261 // 20 steps fix |
2284 // 20 steps fix |
2262 // check whether we are playing WMA files, if so |
2285 // check whether we are playing WMA files, if so |
2263 // the increment has to be KMPXLargeVolumeIncrement |
2286 // the increment has to be KMPXLargeVolumeIncrement |
3466 |
3489 |
3467 // ---------------------------------------------------------------------------- |
3490 // ---------------------------------------------------------------------------- |
3468 // Restore playback position if it was saved previously |
3491 // Restore playback position if it was saved previously |
3469 // ---------------------------------------------------------------------------- |
3492 // ---------------------------------------------------------------------------- |
3470 // |
3493 // |
3471 void CMPXPlaybackEngine::RestorePlaybackPositionAndStateL( |
3494 void CMPXPlaybackEngine::RestorePlaybackPositionL( |
3472 const CMPXMedia& aMedia ) |
3495 const CMPXMedia& aMedia ) |
3473 { |
3496 { |
3474 MPX_DEBUG1("CMPXPlaybackEngine::RestorePlaybackPositionAndStateL() entering"); |
3497 MPX_FUNC("CMPXPlaybackEngine::RestorePlaybackPositionL() "); |
3475 |
3498 |
3476 // Restore Position |
3499 // Restore Position |
3477 iProperties[EPbPropertyPosition] = 0; |
3500 iProperties[EPbPropertyPosition] = 0; |
3478 if ( KErrNotFound != iPreservedPosition ) |
3501 |
3479 { |
|
3480 iProperties[EPbPropertyPosition] = iPreservedPosition; |
|
3481 iPreservedPosition = KErrNotFound; |
|
3482 } |
|
3483 else |
|
3484 { |
|
3485 // Check media |
3502 // Check media |
3486 if (aMedia.IsSupported(KMPXMediaGeneralLastPlaybackPosition)) |
3503 if (aMedia.IsSupported(KMPXMediaGeneralLastPlaybackPosition)) |
3487 { |
3504 { |
3488 iProperties[EPbPropertyPosition] = |
3505 iPositionFromMedia = |
3489 aMedia.ValueTObjectL<TInt>( KMPXMediaGeneralLastPlaybackPosition ); |
3506 aMedia.ValueTObjectL<TInt>( KMPXMediaGeneralLastPlaybackPosition ); |
3490 } |
3507 } |
3491 } |
3508 MPX_DEBUG2("CMPXPlaybackEngine::RestorePlaybackPositionL iPositionFromMedia %d", iPositionFromMedia ); |
3492 |
3509 } |
|
3510 |
|
3511 |
|
3512 // ---------------------------------------------------------------------------- |
|
3513 // Restore playback state if it was saved previously |
|
3514 // ---------------------------------------------------------------------------- |
|
3515 // |
|
3516 void CMPXPlaybackEngine::RestorePlaybackStateL() |
|
3517 { |
|
3518 MPX_FUNC("CMPXPlaybackEngine::RestorePlaybackStateL() "); |
3493 // Restore State |
3519 // Restore State |
3494 if ( EPbStateNotInitialised != iPreservedState ) |
3520 if ( EPbStateNotInitialised != iPreservedState ) |
3495 { |
3521 { |
3496 iNextState = iPreservedState; |
3522 iNextState = iPreservedState; |
3497 iPreservedState = EPbStateNotInitialised; |
3523 iPreservedState = EPbStateNotInitialised; |
3498 } |
3524 } |
3499 |
|
3500 MPX_DEBUG1("CMPXPlaybackEngine::RestorePlaybackPositionAndStateL() exiting"); |
|
3501 } |
3525 } |
3502 |
3526 |
3503 // ---------------------------------------------------------------------------- |
3527 // ---------------------------------------------------------------------------- |
3504 // Sets the volume increment depending on accessory state |
3528 // Sets the volume increment depending on accessory state |
3505 // ---------------------------------------------------------------------------- |
3529 // ---------------------------------------------------------------------------- |
3830 EPbStateInitialising, |
3854 EPbStateInitialising, |
3831 index ); |
3855 index ); |
3832 SetStateL( msg ); |
3856 SetStateL( msg ); |
3833 iProperties[EPbPropertyPosition]=0; |
3857 iProperties[EPbPropertyPosition]=0; |
3834 |
3858 |
|
3859 if ( KErrNotFound != iPreservedPosition ) |
|
3860 { |
|
3861 iProperties[EPbPropertyPosition] = iPreservedPosition; |
|
3862 iPreservedPosition = KErrNotFound; |
|
3863 } |
|
3864 else if ( KErrNotFound != iPositionFromMedia ) |
|
3865 { |
|
3866 iProperties[EPbPropertyPosition] = iPositionFromMedia; |
|
3867 iPositionFromMedia = KErrNotFound; |
|
3868 } |
|
3869 MPX_DEBUG2("CMPXPlaybackEngine::InitL iPropertyPosition %d", iProperties[EPbPropertyPosition] ); |
|
3870 |
3835 // Check if version2 interface is supported. |
3871 // Check if version2 interface is supported. |
3836 CDesCArray* interfaces = iPluginHandler->SupportedInterfacesL( p->Uid() ); |
3872 CDesCArray* interfaces = iPluginHandler->SupportedInterfacesL( p->Uid() ); |
3837 TBool version2InterfaceSupported = EFalse; |
3873 TBool version2InterfaceSupported = EFalse; |
3838 if (interfaces->MdcaCount()) |
3874 if (interfaces->MdcaCount()) |
3839 { |
3875 { |
3851 // if cast was successful, then init streaming with access point |
3887 // if cast was successful, then init streaming with access point |
3852 if (plugin) |
3888 if (plugin) |
3853 { |
3889 { |
3854 if ( iAccessPointSet ) |
3890 if ( iAccessPointSet ) |
3855 { |
3891 { |
3856 plugin->InitStreaming64L( *aFile, aAccessPoint ); |
3892 plugin->InitStreaming64L( *aFile, aAccessPoint, iProperties[EPbPropertyPosition] ); |
3857 } |
3893 } |
3858 else |
3894 else |
3859 { |
3895 { |
3860 plugin->Initialise64L( *aFile ); |
3896 plugin->Initialise64L( *aFile, iProperties[EPbPropertyPosition] ); |
3861 } |
3897 } |
3862 } |
3898 } |
3863 else |
3899 else |
3864 { |
3900 { |
3865 MPX_DEBUG1("CMPXPlaybackEngine::Init64L(): -- failure to convert to expected interface"); |
3901 MPX_DEBUG1("CMPXPlaybackEngine::Init64L(): -- failure to convert to expected interface"); |