Revision: 201009
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 16 Apr 2010 15:28:14 +0300
changeset 21 a05c44bc3c61
parent 20 b1fb57be53fe
child 25 d881023c13eb
Revision: 201009 Kit: 201015
mmappfw_plat/mpx_playback_common_definition_api/inc/mpxplaybackpluginversion2.h
mpx/playbackframework/playbackengine/inc/mpxplaybackengine.h
mpx/playbackframework/playbackengine/inc/mpxplaybackinitializer.h
mpx/playbackframework/playbackengine/src/mpxplaybackengine.cpp
mpx/playbackframework/playbackengine/src/mpxplaybackinitializer.cpp
package_definition.xml
--- a/mmappfw_plat/mpx_playback_common_definition_api/inc/mpxplaybackpluginversion2.h	Fri Mar 19 09:38:24 2010 +0200
+++ b/mmappfw_plat/mpx_playback_common_definition_api/inc/mpxplaybackpluginversion2.h	Fri Apr 16 15:28:14 2010 +0300
@@ -39,8 +39,9 @@
     * @param aUri URI of the item
     * @param aType the mime type of the item
     * @param aAccessPoint the access point
+    * @param aPosition the starting position
     */
-    virtual void InitStreamingL(const TDesC& aUri, const TDesC8& aType, TInt aAccessPoint) = 0;
+    virtual void InitStreamingL(const TDesC& aUri, const TDesC8& aType, TInt aAccessPoint, TInt aPosition = 0) = 0; 
 
     /**
     * Initializes a file handle for playback.
@@ -48,8 +49,9 @@
     * @since S60 9.2
     * @param aFile file handle of a file
     * @param aAccessPoint the access point
+    * @param aPosition the starting position
     */
-    virtual void InitStreamingL(RFile& aFile, TInt aAccessPoint) = 0;
+    virtual void InitStreamingL(RFile& aFile, TInt aAccessPoint, TInt aPosition = 0) = 0; 
     
 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
     /**
@@ -58,17 +60,39 @@
     * @since S60 9.2
     * @param aFile 64 bit file handle of a file
     * @param aAccessPoint the access point
+    * @param aPosition the starting position
     */
-    virtual void InitStreaming64L(RFile64& aFile, TInt aAccessPoint) = 0;
+    virtual void InitStreaming64L(RFile64& aFile, TInt aAccessPoint, TInt aPosition = 0) = 0; 
 
     /**
     * Initializes a song for playback.
     *
     * @since S60 9.2
     * @param aFile 64 bit file handle of a song
+    * @param aPosition the starting position
     */
-    virtual void Initialise64L(RFile64& aSong) = 0;
+    virtual void Initialise64L(RFile64& aSong, TInt aPosition = 0) = 0; 
 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    
+
+    /**
+    * Initializes a song for playback.
+    *
+    * @since S60 9.2
+    * @param aSong the song path
+    * @param aPosition the starting position
+    */
+    virtual void InitialiseWithPositionL(const TDesC& aSong, TInt aPosition = 0) = 0;
+    
+    /**
+    * Initializes a song for playback.
+    *
+    * @since S60 9.2
+    * @param aFile file handle of a song
+    * @param aPosition the starting position
+    */
+    virtual void InitialiseWithPositionL(RFile& aSong, TInt aPosition = 0) = 0;
+    
     };
     
 #endif // CMPXPLAYBACKPLUGINVERSION2_H
--- a/mpx/playbackframework/playbackengine/inc/mpxplaybackengine.h	Fri Mar 19 09:38:24 2010 +0200
+++ b/mpx/playbackframework/playbackengine/inc/mpxplaybackengine.h	Fri Apr 16 15:28:14 2010 +0300
@@ -857,11 +857,16 @@
     void SavePlaybackCompleteInfoL();
 
     /**
-    * Restore playback position and state if it was saved previously
+    * Restore playback position if it was saved previously
     */
-    void RestorePlaybackPositionAndStateL( const CMPXMedia& aMedia );
+    void RestorePlaybackPositionL( const CMPXMedia& aMedia );
 
     /**
+    * Restore playback state if it was saved previously
+    */
+    void RestorePlaybackStateL();
+  
+    /**
     * Sets the volume increment depending on accessory state
     */
     void SetVolumeIncrement( TMPXPlaybackAccessoryMode aMode );
@@ -1031,6 +1036,9 @@
 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
     RFile64 iFile64;
 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+    
+    TInt iPositionFromMedia; 
+    
     };
 
 #include "mpxplaybackengine.inl"
--- a/mpx/playbackframework/playbackengine/inc/mpxplaybackinitializer.h	Fri Mar 19 09:38:24 2010 +0200
+++ b/mpx/playbackframework/playbackengine/inc/mpxplaybackinitializer.h	Fri Apr 16 15:28:14 2010 +0300
@@ -193,7 +193,7 @@
     /**
      * Initialize streaming
      */
-    void InitL(const TDesC& aUri, const TDesC8& aType, TInt aAccessPoint);
+    void InitL(const TDesC& aUri, const TDesC8& aType ); 
     
 private:
     /**
--- a/mpx/playbackframework/playbackengine/src/mpxplaybackengine.cpp	Fri Mar 19 09:38:24 2010 +0200
+++ b/mpx/playbackframework/playbackengine/src/mpxplaybackengine.cpp	Fri Apr 16 15:28:14 2010 +0300
@@ -109,6 +109,7 @@
     iState(EPbStateNotInitialised),
     iNextState(EPbStateNotInitialised),
     iPluginState(EPbStateNotInitialised),
+    iCategory(EMPXCategoryUndefined),
     iModeId(aModeId),
     iObserver(aObserver),
     iPreservedState( EPbStateNotInitialised ),
@@ -116,7 +117,8 @@
     iSkipping(EFalse),
     iPluginUid(KNullUid),
     iLastActiveProcess(KNullProcessId),
-    iLastInactiveProcess(KNullProcessId)
+    iLastInactiveProcess(KNullProcessId),
+    iPositionFromMedia( KErrNotFound ) 
     {
     iProperties[EPbPropertyVolumeRamp]=KPbFadeInDurationMicroSeconds;
     }
@@ -140,6 +142,7 @@
     iNextState(EPbStateNotInitialised),
     iPluginState(EPbStateNotInitialised),
     iModeId(aModeId),
+    iCategory(aCategory),
     iObserver(aObserver),
     iPreservedState( EPbStateNotInitialised ),
     iPreservedPosition( KErrNotFound ),
@@ -147,7 +150,7 @@
     iPluginUid(KNullUid),
     iLastActiveProcess(KNullProcessId),
     iLastInactiveProcess(KNullProcessId),
-    iCategory(aCategory)
+    iPositionFromMedia( KErrNotFound ) 
     {
     iProperties[EPbPropertyVolumeRamp]=KPbFadeInDurationMicroSeconds;
     }
@@ -180,16 +183,24 @@
 
     iMediaHelper = CMPXPlaybackMediaHelper::NewL( *this );
     iDummyMediaObserver = new(ELeave) CMPXPlaybackDummyMediaObserver();
-    // Select local plugin by default if none selected
-    iPluginHandler->SelectPlayersL( EPbLocal );
-    iInitVolume = ETrue;
+    iInitVolume = EFalse;
+    
+    if (iCategory != EMPXCategoryVideo)
+        {
+        // Select local plugin by default if none selected
+        iPluginHandler->SelectPlayersL( EPbLocal );
+        iInitVolume = ETrue;
+        iPluginHandler->Plugin()->PropertyL( EPbPropertyVolume );
+        }
+    
 #if defined(__HIGH_RESOLUTION_VOLUME)
     iVolRoundedUp = EFalse;
 #endif
-    iPluginHandler->Plugin()->PropertyL( EPbPropertyVolume );
+    
     iSyncMsgTimer = CPeriodic::NewL( CActive::EPriorityIdle ); 
     iSyncMsgWait = new (ELeave) CActiveSchedulerWait; 
-    }
+    iProperties[EPbPropertyPosition] = 0; 
+    	}
 
 // ----------------------------------------------------------------------------
 // Destructor
@@ -305,7 +316,10 @@
                 0,
                 EFalse));
 
-        iPluginUid = iPluginHandler->Plugin()->Uid();
+        if ( iPluginHandler->PlayerFound() )
+        {
+            iPluginUid = iPluginHandler->Plugin()->Uid();
+        }
 
         RArray<TMPXAttribute> dummy;
         CleanupClosePushL( dummy );
@@ -1462,11 +1476,7 @@
 	if ( iProperties[EPbPropertyPosition] >= iProperties[EPbPropertyDuration] )
             {
             iProperties[EPbPropertyPosition] = 0;
-            }
-
-    // Set position to restore saved position.
-    TRAP_IGNORE( // uPnP leaves if set position in stop state
-            PluginL()->SetL( EPbPropertyPosition, iProperties[EPbPropertyPosition] ));
+            }    
 
     iAutoResumeHandler->HandleOpenFileComplete();
     
@@ -1995,6 +2005,18 @@
     SetStateL( msg );
     iProperties[EPbPropertyPosition]=0;
     
+    if ( KErrNotFound != iPreservedPosition )
+          {
+          iProperties[EPbPropertyPosition] = iPreservedPosition;
+          iPreservedPosition = KErrNotFound;
+          }
+    else if ( KErrNotFound != iPositionFromMedia )
+        {
+        iProperties[EPbPropertyPosition] = iPositionFromMedia;
+        iPositionFromMedia = KErrNotFound;
+        }
+    MPX_DEBUG2("CMPXPlaybackEngine::InitL iPropertyPosition %d", iProperties[EPbPropertyPosition] );
+      
     // make sure our interface is supported
     CDesCArray* interfaces = iPluginHandler->SupportedInterfacesL( p->Uid() );
     TBool version2InterfaceSupported = EFalse;
@@ -2018,22 +2040,22 @@
                 {
                 if (aSong && aType)
                     {
-                    plugin->InitStreamingL( *aSong, *aType, aAccessPoint );
+                    plugin->InitStreamingL( *aSong, *aType, aAccessPoint, iProperties[EPbPropertyPosition] ); 
                     }
                 else if (aFile)
                     {
-                    plugin->InitStreamingL( *aFile, aAccessPoint );
+                    plugin->InitStreamingL( *aFile, aAccessPoint, iProperties[EPbPropertyPosition] ); 
                     }
                 }
             else
                 {
                 if (aSong && aType)
                     {
-                    plugin->InitialiseL( *aSong );
+                    plugin->InitialiseWithPositionL( *aSong, iProperties[EPbPropertyPosition] ); 
                     }
                 else if (aFile)
                     {
-                    plugin->InitialiseL( *aFile );
+                    plugin->InitialiseWithPositionL( *aFile, iProperties[EPbPropertyPosition] ); 
                     }        
                 }
             }
@@ -2256,6 +2278,7 @@
             }
         else
             {
+            RestorePlaybackPositionL( aMedia );  
             TRAP( aError, InitL( iUri, mimeType, NULL, iAccessPoint) );
             /*
             // 20 steps  fix
@@ -2284,7 +2307,7 @@
                */
             if ( KErrNone == aError )
                 {
-                RestorePlaybackPositionAndStateL( aMedia );
+                RestorePlaybackStateL(); 
                 }
             else
                 {
@@ -3468,36 +3491,37 @@
 // Restore playback position if it was saved previously
 // ----------------------------------------------------------------------------
 //
-void CMPXPlaybackEngine::RestorePlaybackPositionAndStateL(
+void CMPXPlaybackEngine::RestorePlaybackPositionL(
     const CMPXMedia& aMedia )
     {
-    MPX_DEBUG1("CMPXPlaybackEngine::RestorePlaybackPositionAndStateL() entering");
+    MPX_FUNC("CMPXPlaybackEngine::RestorePlaybackPositionL() ");
 
     // Restore Position
     iProperties[EPbPropertyPosition] = 0;
-    if ( KErrNotFound != iPreservedPosition )
-        {
-        iProperties[EPbPropertyPosition] = iPreservedPosition;
-        iPreservedPosition = KErrNotFound;
-        }
-    else
-        {
+
         // Check media
         if (aMedia.IsSupported(KMPXMediaGeneralLastPlaybackPosition))
             {
-            iProperties[EPbPropertyPosition] =
-                aMedia.ValueTObjectL<TInt>( KMPXMediaGeneralLastPlaybackPosition );
+            iPositionFromMedia =
+                aMedia.ValueTObjectL<TInt>( KMPXMediaGeneralLastPlaybackPosition ); 
             }
-        }
+        MPX_DEBUG2("CMPXPlaybackEngine::RestorePlaybackPositionL iPositionFromMedia %d", iPositionFromMedia ); 
+    }
+
 
+// ----------------------------------------------------------------------------
+// Restore playback state if it was saved previously
+// ----------------------------------------------------------------------------
+//
+void CMPXPlaybackEngine::RestorePlaybackStateL()
+    {
+    MPX_FUNC("CMPXPlaybackEngine::RestorePlaybackStateL() ");
     // Restore State
     if ( EPbStateNotInitialised != iPreservedState )
         {
         iNextState = iPreservedState;
         iPreservedState = EPbStateNotInitialised;
-        }
-
-    MPX_DEBUG1("CMPXPlaybackEngine::RestorePlaybackPositionAndStateL() exiting");
+        }   
     }
 
 // ----------------------------------------------------------------------------
@@ -3832,6 +3856,18 @@
     SetStateL( msg );
     iProperties[EPbPropertyPosition]=0;
     
+        if ( KErrNotFound != iPreservedPosition )
+              {
+              iProperties[EPbPropertyPosition] = iPreservedPosition;
+              iPreservedPosition = KErrNotFound;
+              }
+        else if ( KErrNotFound != iPositionFromMedia )
+            {
+            iProperties[EPbPropertyPosition] = iPositionFromMedia;
+            iPositionFromMedia = KErrNotFound;
+            }
+        MPX_DEBUG2("CMPXPlaybackEngine::InitL iPropertyPosition %d", iProperties[EPbPropertyPosition] );
+            
     // Check if version2 interface is supported.
     CDesCArray* interfaces = iPluginHandler->SupportedInterfacesL( p->Uid() );
     TBool version2InterfaceSupported = EFalse;
@@ -3853,11 +3889,11 @@
             {
             if ( iAccessPointSet )
                 {
-                plugin->InitStreaming64L( *aFile, aAccessPoint );
+                plugin->InitStreaming64L( *aFile, aAccessPoint, iProperties[EPbPropertyPosition] ); 
                 }
             else
                 {
-                plugin->Initialise64L( *aFile );
+                plugin->Initialise64L( *aFile, iProperties[EPbPropertyPosition] ); 
                 }
             }
         else
--- a/mpx/playbackframework/playbackengine/src/mpxplaybackinitializer.cpp	Fri Mar 19 09:38:24 2010 +0200
+++ b/mpx/playbackframework/playbackengine/src/mpxplaybackinitializer.cpp	Fri Apr 16 15:28:14 2010 +0300
@@ -424,7 +424,8 @@
         {
         if ( iMedia )
             {
-            iEngine.RestorePlaybackPositionAndStateL( *iMedia );
+            iEngine.RestorePlaybackPositionL( *iMedia );
+            iEngine.RestorePlaybackStateL(); 
             }
         //
         // Set plug-in handler
@@ -621,12 +622,9 @@
                     iHandler->SelectPlayersL(t);
                     }
                 }
-            TInt accessPoint = 0;
-            if ( aMedia.IsSupported(KMPXMediaGeneralExtAccessPoint) )
-                {
-                accessPoint = aMedia.ValueTObjectL<TInt>( KMPXMediaGeneralExtAccessPoint );
-                MPX_DEBUG2("CMPXPlaybackInitializer::InitL accessPoint %d", accessPoint );
-                }
+           
+
+            
             HBufC8* mimeType =
                     MPXUser::Alloc8L(aMedia.ValueText(KMPXMediaGeneralMimeType));
             CleanupStack::PushL(mimeType);
@@ -635,7 +633,7 @@
             // Plugin handler guarantee to choose a plugin
             // In case there is file open in the audio controller
             iHandler->Plugin()->CommandL(EPbCmdClose);
-            InitL(uri, *mimeType, accessPoint);
+            InitL(uri, *mimeType); 
             CleanupStack::PopAndDestroy(mimeType);
             }
         else  // No URI
@@ -840,7 +838,7 @@
 // Initialize.
 // ----------------------------------------------------------------------------
 //
-void CMPXPlaybackInitializer::InitL(const TDesC& aUri, const TDesC8& aType, TInt aAccessPoint)
+void CMPXPlaybackInitializer::InitL(const TDesC& aUri, const TDesC8& aType ) 
     {
     MPX_FUNC("CMPXPlaybackInitializer::InitL");
     CMPXPlaybackPlugin* p = iHandler->Plugin();
@@ -869,13 +867,29 @@
         // if cast was successful, then init streaming with access point
         if (plugin)
             {
-            if ( aAccessPoint )
+            
+            TInt accessPoint = 0;
+            if ( iMedia->IsSupported(KMPXMediaGeneralExtAccessPoint) ) 
                 {
-                plugin->InitStreamingL( aUri, aType, aAccessPoint );
+                accessPoint = iMedia->ValueTObjectL<TInt>( KMPXMediaGeneralExtAccessPoint ); 
+                MPX_DEBUG2("CMPXPlaybackInitializer::InitL accessPoint %d", accessPoint );
+                }            
+            
+            TInt position = 0;            
+            if (iMedia->IsSupported(KMPXMediaGeneralLastPlaybackPosition))
+                {
+                position = iMedia->ValueTObjectL<TInt>( KMPXMediaGeneralLastPlaybackPosition );
+                MPX_DEBUG2("CMPXPlaybackInitializer::InitL position %d", position );
+                }
+            
+                        
+            if ( accessPoint ) 
+                {
+                plugin->InitStreamingL( aUri, aType, accessPoint, position ); 
                 }
             else
                 {
-                plugin->InitialiseL(aUri);
+                plugin->InitialiseWithPositionL(aUri, position); 
                 }
             }
         else
--- a/package_definition.xml	Fri Mar 19 09:38:24 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<SystemDefinition schema="3.0.0">
-  <package id="mmappfw" name="Multimedia App Framework" levels="fw utils if">
-    <collection id="mmappcomponents" name="Multimedia App Components" level="utils">
-      <component id="collectionhelper" filter="s60" name="Media Player Collection Helper" introduced="^1">
-        <unit bldFile="mmappcomponents/collectionhelper/group"/>
-      </component>
-      <component id="playlistengine" filter="s60" name="Playlist Engine" introduced="^1">
-        <unit bldFile="mmappcomponents/playlistengine/group"/>
-      </component>
-      <component id="mpxharvester" filter="s60" name="Media Player Harvester" introduced="^1">
-        <unit bldFile="mmappcomponents/harvester/group"/>
-      </component>
-      <component id="mmappcommonui" filter="s60" name="Multimedia App Common UI" introduced="^1">
-        <unit bldFile="mmappcomponents/mmappcommonui/group"/>
-      </component>
-      <component id="mediaplayersettingsengine" filter="s60" name="Media Player Settings Engine" introduced="^1">
-        <unit bldFile="mmappcomponents/mediaplayersettingsengine/group"/>
-      </component>
-      <component id="audiofetcher" filter="s60" name="Audio Fetcher" class="plugin" introduced="^1">
-        <unit bldFile="mmappcomponents/audiofetcher/group"/>
-      </component>
-      <component id="asxparser" filter="s60" name="ASX Parser" introduced="^1">
-        <unit bldFile="mmappcomponents/asxparser/group"/>
-        <!-- does the test bld.inf need to be #included? -->
-        <!-- <unit bldFile="mmappcomponents/asxparser/test"/> -->
-      </component>
-    </collection>
-    <collection id="mpx" name="Multimedia Player" level="fw">
-      <component id="commonframework" filter="s60" name="MPX Common Framework" introduced="^1">
-        <unit bldFile="mpx/commonframework/group"/>
-      </component>
-      <component id="playbackframework" filter="s60" name="MPX Playback Framework" introduced="^1">
-        <unit bldFile="mpx/playbackframework/group"/>
-      </component>
-      <component id="mpxcollectionfw" filter="s60" name="MPX Collection Framework" introduced="^1">
-        <unit bldFile="mpx/collectionframework/group"/>
-      </component>
-      <component id="mpxviewfw" filter="s60" name="MPX View Framework" introduced="^1">
-        <unit bldFile="mpx/viewframework/group"/>
-      </component>
-      <component id="mpx_build" filter="s60" name="MPX Build" introduced="^1">
-      	<!--  can the exports from here be distribtued to the above bld.infs? -->
-        <unit bldFile="mpx/group"/>
-      </component>
-    </collection>
-    <collection id="mmappfw_info" name="Multimedia App Framework Info" level="if">
-      <component id="mmappfw_build" filter="s60" name="Multimedia App Framework Build" introduced="^1">
-      <!--  does the export from ehre really belong in one of the other components? -->
-        <unit bldFile="group"/>
-      </component>
-      <component id="mmappfw_test" filter="s60" name="Multimedia App Framework Test" purpose="development" introduced="^1">
-      	<!--  should this component exist? -->
-        <!-- <unit bldFile="tsrc/group"/> -->
-      </component>
-      <component id="mmappfw_plat" filter="s60" name="Multimedia App Framework Platform Interfaces" class="api" introduced="^1">
-      	<!-- there can only be a single unit, these should be #included from a main bld.inf -->
-        <unit bldFile="mmappfw_plat/group"/>
-        <unit bldFile="mmappfw_plat/asx_parser_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/collection_helper_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/harvester_collection_mediator_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/harvester_metadata_extractor_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/harvester_utility_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/media_player_settings_engine_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/mpx_albumart_utility_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/mpx_base_view_plugins_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/mpx_collection_utility_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/mpx_common_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/mpx_playback_utility_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/mpx_view_utility_api/tsrc/group"/>
-        <unit bldFile="mmappfw_plat/playlist_engine_api/tsrc/group"/>
-      </component>
-    </collection>
-  </package>
-</SystemDefinition>