videoplayerapp/videoplayerengine/src/mpxvideoplayerappuiengine.cpp
changeset 36 8aed59de29f9
parent 35 3738fe97f027
child 37 4eb2df7f7cbe
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    13 *
    13 *
    14 * Description:  CMpxVideoPlayerAppUiEngine
    14 * Description:  CMpxVideoPlayerAppUiEngine
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 // Version : %version:  5 %
    18 // Version : %version:  7 %
    19 
    19 
    20 
    20 
    21 
    21 
    22 #include <mpxcommand.h>
    22 #include <mpxcommand.h>
    23 #include <mpxcommandgeneraldefs.h>
    23 #include <mpxcommandgeneraldefs.h>
    28 #include <mpxmediageneraldefs.h>
    28 #include <mpxmediageneraldefs.h>
    29 #include <mpxcollectionmessagedefs.h>
    29 #include <mpxcollectionmessagedefs.h>
    30 #include <vcxmyvideosdefs.h>
    30 #include <vcxmyvideosdefs.h>
    31 #include <mpxcollectionpath.h>
    31 #include <mpxcollectionpath.h>
    32 #include <videoplayeractivationmessage.h>
    32 #include <videoplayeractivationmessage.h>
    33 #include <AiwGenericParam.h>
       
    34 #include <mpxcollectionuihelper.h>
    33 #include <mpxcollectionuihelper.h>
    35 #include <mpxcollectionhelperfactory.h>
    34 #include <mpxcollectionhelperfactory.h>
    36 #include <mpxcollectionplugin.hrh>
    35 #include <mpxcollectionplugin.hrh>
    37 #include <mpxmediageneralextdefs.h>
    36 #include <mpxmediageneralextdefs.h>
    38 #include <mmf/common/mmfcontrollerframeworkbase.h>
    37 #include <mmf/common/mmfcontrollerframeworkbase.h>
    39 
    38 
    40 #include <streaminglinkmodel.h>
       
    41 #include <coeutils.h>
    39 #include <coeutils.h>
    42 #include <videoplaylistutility.h>
    40 #include <videoplaylistutility.h>
    43 #include <mpxvideoplaybackdefs.h>
    41 #include <mpxvideoplaybackdefs.h>
    44 
    42 
    45 #include "mpxvideoplayerappuiengine.h"
    43 #include "mpxvideoplayerappuiengine.h"
    46 #include "mpxvideoplayerconstants.h"
    44 #include "mpxvideoplayerconstants.h"
    47 #include "mpxvideoembeddedpdlhandler.h"
       
    48 #include "mpxvideoplaybackwrapper.h"
    45 #include "mpxvideoplaybackwrapper.h"
    49 #include "mpxhbvideocommondefs.h"
    46 #include "mpxhbvideocommondefs.h"
    50 
    47 
    51 #include "mpxvideo_debug.h"
    48 #include "mpxvideo_debug.h"
    52 
    49 
    55 // -------------------------------------------------------------------------------------------------
    52 // -------------------------------------------------------------------------------------------------
    56 //
    53 //
    57 CMpxVideoPlayerAppUiEngine::CMpxVideoPlayerAppUiEngine( QMpxVideoPlaybackWrapper* aWrapper )
    54 CMpxVideoPlayerAppUiEngine::CMpxVideoPlayerAppUiEngine( QMpxVideoPlaybackWrapper* aWrapper )
    58     : iPlaybackUtility( NULL ),
    55     : iPlaybackUtility( NULL ),
    59       iCollectionUtility( NULL ),
    56       iCollectionUtility( NULL ),
    60       iExitAo( NULL ),
       
    61       iRecognizer( NULL ),
    57       iRecognizer( NULL ),
    62       iAccessPointId( KUseDefaultIap ),
    58       iAccessPointId( KUseDefaultIap ),
    63       iMultilinkPlaylist( EFalse ),
    59       iMultilinkPlaylist( EFalse ),
    64       iSeekable( ETrue ),
    60       iSeekable( ETrue ),
    65       iUpdateSeekInfo( EFalse ),
    61       iUpdateSeekInfo( EFalse ),
    98 //   CMpxVideoPlayerAppUiEngine::PostInitL
    94 //   CMpxVideoPlayerAppUiEngine::PostInitL
    99 // -------------------------------------------------------------------------------------------------
    95 // -------------------------------------------------------------------------------------------------
   100 //
    96 //
   101 void CMpxVideoPlayerAppUiEngine::LateInitL()
    97 void CMpxVideoPlayerAppUiEngine::LateInitL()
   102 {	       
    98 {	       
   103     CreatePlaybackUtilityMemberVariablesL();
    99     CreatePlaybackUtilityL();
   104         
   100         
   105     iRecognizer = CMediaRecognizer::NewL();
   101     iRecognizer = CMediaRecognizer::NewL();               
   106                
       
   107     iExitAo = CIdle::NewL( CActive::EPriorityStandard );     
       
   108 }
   102 }
   109 
   103 
   110 // -------------------------------------------------------------------------------------------------
   104 // -------------------------------------------------------------------------------------------------
   111 //   CMpxVideoPlayerAppUiEngine::CreateCollectionUtilityMemberVariablesL
   105 //   CMpxVideoPlayerAppUiEngine::CreateCollectionUtilityMemberVariablesL
   112 // -------------------------------------------------------------------------------------------------
   106 // -------------------------------------------------------------------------------------------------
   126         iCollectionUiHelper = CMPXCollectionHelperFactory::NewCollectionUiHelperL();
   120         iCollectionUiHelper = CMPXCollectionHelperFactory::NewCollectionUiHelperL();
   127     }
   121     }
   128 }
   122 }
   129 
   123 
   130 // -------------------------------------------------------------------------------------------------
   124 // -------------------------------------------------------------------------------------------------
   131 //   CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityMemberVariablesL
   125 //   CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityL
   132 // -------------------------------------------------------------------------------------------------
   126 // -------------------------------------------------------------------------------------------------
   133 //
   127 //
   134 void CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityMemberVariablesL()
   128 void CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityL()
   135 {
   129 {
   136     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityMemberVariablesL()"));
   130     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityL()"));
   137 
   131 
   138     if ( ! iPlaybackUtility )
   132     if ( ! iPlaybackUtility )
   139     {
   133     {
   140         //
   134         //
   141         //  Create VideoHelix playback plugin
   135         //  Create VideoHelix playback plugin
   147         iPlaybackUtility->CommandL( EPbCmdSetAutoResume, EFalse );
   141         iPlaybackUtility->CommandL( EPbCmdSetAutoResume, EFalse );
   148     }
   142     }
   149 }
   143 }
   150 
   144 
   151 // -------------------------------------------------------------------------------------------------
   145 // -------------------------------------------------------------------------------------------------
   152 //   CMpxVideoPlayerAppUiEngine::CreateEmbeddedPdlPlaybackUtilityMemberVariablesL
       
   153 // -------------------------------------------------------------------------------------------------
       
   154 //
       
   155 void CMpxVideoPlayerAppUiEngine::CreateEmbeddedPdlPlaybackUtilityMemberVariablesL()
       
   156 {
       
   157     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::CreateEmbeddedPdlPlaybackUtilityMemberVariablesL()"));
       
   158 
       
   159 	  CreatePlaybackUtilityMemberVariablesL();
       
   160 }
       
   161 
       
   162 // -------------------------------------------------------------------------------------------------
       
   163 //   CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine
   146 //   CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine
   164 // -------------------------------------------------------------------------------------------------
   147 // -------------------------------------------------------------------------------------------------
   165 //
   148 //
   166 CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine()
   149 CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine()
   167 {
   150 {
   168     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine()"));
   151     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine()"));
   169 
       
   170     if ( iExitAo )
       
   171     {
       
   172         delete iExitAo;
       
   173         iExitAo = NULL;
       
   174     }
       
   175 
   152 
   176     if ( iRecognizer )
   153     if ( iRecognizer )
   177     {
   154     {
   178         delete iRecognizer;
   155         delete iRecognizer;
   179         iRecognizer = NULL;
   156         iRecognizer = NULL;
   180     }
       
   181 
       
   182     if ( iPdlHandler )
       
   183     {
       
   184         delete iPdlHandler;
       
   185         iPdlHandler = NULL;
       
   186     }
   157     }
   187 
   158 
   188     if ( iCollectionUtility )
   159     if ( iCollectionUtility )
   189     {
   160     {
   190         iCollectionUtility->Close();
   161         iCollectionUtility->Close();
   226 void CMpxVideoPlayerAppUiEngine::HandleViewActivation( const TUid& /*aCurrentViewType*/,
   197 void CMpxVideoPlayerAppUiEngine::HandleViewActivation( const TUid& /*aCurrentViewType*/,
   227                                                        const TUid& /*aPreviousViewType*/ )
   198                                                        const TUid& /*aPreviousViewType*/ )
   228 {
   199 {
   229 }
   200 }
   230 
   201 
   231 // ---------------------------------------------------------------------------------------------------------------------
   202 // -------------------------------------------------------------------------------------------------
   232 //   CMpxVideoPlayerAppUiEngine::HandleAiwGenericParamListL()
   203 //   CMpxVideoPlayerAppUiEngine::OpenFileL
   233 // ---------------------------------------------------------------------------------------------------------------------
   204 // -------------------------------------------------------------------------------------------------
   234 //
   205 //
   235 TInt CMpxVideoPlayerAppUiEngine::HandleAiwGenericParamListL( const CAiwGenericParamList* aParams )
   206 void CMpxVideoPlayerAppUiEngine::OpenFileL( RFile& aFile )
   236 {
   207 {
   237     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleAiwGenericParamListL()"));
   208     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenFileL(RFile)"));
   238 
   209 
   239     TInt retVal = KErrNone;
   210     TFileName filename;
   240 
   211     aFile.FullName(filename);
   241     TInt index = 0;
   212 
   242 
   213     CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL( filename, aFile );
   243     //
   214 
   244     //  Check if there is a terminate message.  If it exists, exit the application.
   215     if ( mediaType == CMediaRecognizer::ELocalRamFile ||
   245     //
   216          mediaType == CMediaRecognizer::ELocalAsxFile )
   246     TInt32 terminateID = 0;
   217     {
   247 
   218         HandleMultiLinksFileL( aFile, mediaType );
   248     const TAiwGenericParam* paramTerminate =
   219     }
   249         aParams->FindFirst( index, EGenericParamTerminate, EVariantTypeTInt32 );
   220     else if ( mediaType == CMediaRecognizer::ELocalSdpFile )
   250 
   221     {
   251     if ( paramTerminate )
   222         iPlaybackUtility->InitStreamingL( aFile, iAccessPointId );
   252     {
       
   253         paramTerminate->Value().Get( terminateID );
       
   254     }
       
   255 
       
   256     if ( terminateID )
       
   257     {
       
   258         MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::HandleAiwGenericParamListL()  Terminate message received"));
       
   259 
       
   260         //
       
   261         //  Embedded app is being closed
       
   262         //
       
   263 
       
   264         //
       
   265         // Workaround. Will handle it once AIW gets supported
       
   266         //
       
   267         //iAppUi->HandleCommandL( EEikCmdExit );
       
   268 
       
   269         retVal = KErrCancel;
       
   270     }
   223     }
   271     else
   224     else
   272     {
   225     {
   273         //
   226         iPlaybackUtility->InitL( aFile );
   274         //  Determine if these parameters are for PDL
   227     }    
   275         //
   228 
   276         index = 0;
   229     iRecognizer->FreeFilehandle();
   277         TInt32 dlId = KErrNotFound;
   230 
   278 
   231     aFile.Close();
   279         const TAiwGenericParam* genParamDlId =
   232 }
   280             aParams->FindFirst( index, EGenericParamDownloadId, EVariantTypeTInt32 );
   233 
   281 
       
   282         if ( genParamDlId )
       
   283         {
       
   284             genParamDlId->Value().Get( dlId );
       
   285 
       
   286             index = 0;
       
   287 
       
   288             const TAiwGenericParam* paramFileName =
       
   289                 aParams->FindFirst( index, EGenericParamFile, EVariantTypeDesC );
       
   290 
       
   291             TPtrC fileName;
       
   292 
       
   293             //
       
   294             //  Set the filename.  The LWPlayerAppUi checks for the
       
   295             //  filename and exits if it doesn't exist
       
   296             //
       
   297             fileName.Set( paramFileName->Value().AsDes() );
       
   298 
       
   299             if ( ! iPdlHandler )
       
   300             {
       
   301                 iPdlHandler = CMpxVideoEmbeddedPdlHandler::NewL( this );
       
   302             }
       
   303 
       
   304             iPdlHandler->ConnectToEmbeddedDownloadL( dlId, fileName );
       
   305         }
       
   306         else
       
   307         {
       
   308             //
       
   309             //  Check Access Point
       
   310             //
       
   311             index = 0;
       
   312 
       
   313             const TAiwGenericParam* genParamAccessPoint =
       
   314                 aParams->FindFirst( index, EGenericParamAccessPoint, EVariantTypeTInt32 );
       
   315 
       
   316             if ( index >= 0 && genParamAccessPoint )
       
   317             {
       
   318                 TInt32 apId = KErrUnknown;
       
   319                 genParamAccessPoint->Value().Get( apId );
       
   320                 iAccessPointId = apId;
       
   321             }
       
   322         }
       
   323     }
       
   324 
       
   325     return retVal;
       
   326 }
       
   327 
   234 
   328 // -------------------------------------------------------------------------------------------------
   235 // -------------------------------------------------------------------------------------------------
   329 //   CMpxVideoPlayerAppUiEngine::OpenFileL
   236 //   CMpxVideoPlayerAppUiEngine::OpenFileL
   330 // -------------------------------------------------------------------------------------------------
   237 // -------------------------------------------------------------------------------------------------
   331 //
   238 //
   332 void CMpxVideoPlayerAppUiEngine::OpenFileL( RFile& aFile, const CAiwGenericParamList* aParams )
       
   333 {
       
   334     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenFileL(RFile)"));
       
   335 
       
   336     TInt err = KErrNone;
       
   337 
       
   338     if ( aParams )
       
   339     {
       
   340         err = HandleAiwGenericParamListL( aParams );
       
   341     }
       
   342 
       
   343     if ( KErrNone == err && ! iPdlHandler )
       
   344     {
       
   345         TFileName filename;
       
   346         aFile.FullName(filename);
       
   347 
       
   348         CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL( filename, aFile );
       
   349 
       
   350         if ( mediaType == CMediaRecognizer::ELocalRamFile ||
       
   351              mediaType == CMediaRecognizer::ELocalAsxFile )
       
   352         {
       
   353             HandleMultiLinksFileL( aFile, mediaType );
       
   354         }
       
   355         else if ( mediaType == CMediaRecognizer::ELocalSdpFile )
       
   356         {
       
   357             iPlaybackUtility->InitStreamingL( aFile, iAccessPointId );
       
   358         }
       
   359         else
       
   360         {
       
   361             iPlaybackUtility->InitL( aFile );
       
   362         }
       
   363     }
       
   364 
       
   365     iRecognizer->FreeFilehandle();
       
   366 
       
   367     aFile.Close();
       
   368 }
       
   369 
       
   370 // -------------------------------------------------------------------------------------------------
       
   371 //   CMpxVideoPlayerAppUiEngine::OpenFileL
       
   372 // -------------------------------------------------------------------------------------------------
       
   373 //
       
   374 void CMpxVideoPlayerAppUiEngine::OpenFileL( const TDesC& aFileName )
   239 void CMpxVideoPlayerAppUiEngine::OpenFileL( const TDesC& aFileName )
   375 {
   240 {
   376     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenFileL()"),
   241     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenFileL()"),
   377                    _L("aFileName = %S"), &aFileName);
   242                    _L("aFileName = %S"), &aFileName);    
   378 
   243     
   379     CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL(aFileName);
   244     CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL(aFileName);
   380 
   245 
   381     if ( mediaType == CMediaRecognizer::ELocalVideoFile )
   246     if ( mediaType == CMediaRecognizer::ELocalVideoFile )
   382     {
   247     {
   383         iPlaybackUtility->InitL( aFileName );
   248         iPlaybackUtility->InitL( aFileName );
   517         TRAP_IGNORE( manager.ClearSelectPlayersL() );
   382         TRAP_IGNORE( manager.ClearSelectPlayersL() );
   518     }
   383     }
   519 }
   384 }
   520 
   385 
   521 // -------------------------------------------------------------------------------------------------
   386 // -------------------------------------------------------------------------------------------------
   522 // Sets AppUiEngine in stand alone "mode"
       
   523 // -------------------------------------------------------------------------------------------------
       
   524 //
       
   525 void CMpxVideoPlayerAppUiEngine::StartStandAloneL()
       
   526 {
       
   527     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::StartStandAloneL()"));
       
   528 
       
   529     //
       
   530     //  Create the utilities for the stand alone player
       
   531     //
       
   532     CreatePlaybackUtilityMemberVariablesL();
       
   533 
       
   534     // Fetch the video collection UID
       
   535     RArray<TUid> uid;
       
   536     CleanupClosePushL( uid );
       
   537 
       
   538     uid.AppendL( TUid::Uid( KVcxMediaIdMyVideos ) );
       
   539 
       
   540     iVideoCollectionId = iCollectionUtility->CollectionIDL( uid.Array() );
       
   541 
       
   542     CleanupStack::PopAndDestroy( &uid );
       
   543 
       
   544     //
       
   545     // Workaround. Don't use mpx view utility yet
       
   546     //
       
   547     // iViewUtility->SetAsDefaultViewL( KUidMyVideosViewType );
       
   548 }
       
   549 
       
   550 // -------------------------------------------------------------------------------------------------
       
   551 // Handle collection message
   387 // Handle collection message
   552 // -------------------------------------------------------------------------------------------------
   388 // -------------------------------------------------------------------------------------------------
   553 //
   389 //
   554 void CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL( CMPXMessage* aMessage )
   390 void CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL( CMPXMessage* aMessage )
   555 {
   391 {
   588 
   424 
   589                     attribs.Append( KMPXMediaGeneralUri );
   425                     attribs.Append( KMPXMediaGeneralUri );
   590                     attribs.Append( KVcxMediaMyVideosDownloadId );
   426                     attribs.Append( KVcxMediaMyVideosDownloadId );
   591                     iCollectionUtility->Collection().MediaL( *cPath, attribs.Array() );
   427                     iCollectionUtility->Collection().MediaL( *cPath, attribs.Array() );
   592 
   428 
   593                     // Create the playlist
       
   594                     // Create proper playlist
       
   595                     // InitPlaybackEngineL( *cPath );
       
   596 
       
   597                     CleanupStack::PopAndDestroy( &attribs );
   429                     CleanupStack::PopAndDestroy( &attribs );
   598                 }
   430                 }
   599 
   431 
   600                 CleanupStack::PopAndDestroy( cPath );
   432                 CleanupStack::PopAndDestroy( cPath );
   601             }
   433             }
   643 
   475 
   644     const TDesC& fileUri = aMedia.ValueText(KMPXMediaGeneralUri);
   476     const TDesC& fileUri = aMedia.ValueText(KMPXMediaGeneralUri);
   645 
   477 
   646     MPX_DEBUG(_L("Video URI: %S"), &fileUri );
   478     MPX_DEBUG(_L("Video URI: %S"), &fileUri );
   647 
   479 
   648     if ( aMedia.IsSupported( KVcxMediaMyVideosDownloadId ) &&
   480     //OpenMediaL( aMedia ); // Initialize and initiate playback of a single video
   649          aMedia.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ) != 0 )
   481 
   650     {
   482     TPtrC mediaFile( aMedia.ValueText( KMPXMediaGeneralUri ) );
   651         TUint32 dlId = aMedia.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
   483     CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL(mediaFile);
   652 
   484         
   653         if ( ! iPdlHandler )
   485     if ( mediaType == CMediaRecognizer::ELocalRamFile ||
   654         {
   486          mediaType == CMediaRecognizer::ELocalAsxFile )
   655             iPdlHandler = CMpxVideoEmbeddedPdlHandler::NewL( this );
   487     {        
   656         }
   488         HandleMultiLinksFileL( mediaFile, mediaType );
   657 
   489     }    
   658         iPdlHandler->ConnectToCollectionDownloadL( dlId, const_cast<TDesC&>( fileUri ) );
       
   659     }
       
   660     else
   490     else
   661     {
   491     {
   662         //OpenMediaL( aMedia ); // Initialize and initiate playback of a single video
   492         OpenMediaL( aMedia ); // Initialize and initiate playback of a single video
   663 
   493     }    
   664         TPtrC mediaFile( aMedia.ValueText( KMPXMediaGeneralUri ) );
       
   665         CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL(mediaFile);
       
   666         
       
   667         if ( mediaType == CMediaRecognizer::ELocalRamFile ||
       
   668              mediaType == CMediaRecognizer::ELocalAsxFile )
       
   669         {        
       
   670             HandleMultiLinksFileL( mediaFile, mediaType );
       
   671         }    
       
   672         else
       
   673         {
       
   674             OpenMediaL( aMedia ); // Initialize and initiate playback of a single video
       
   675         }
       
   676     }
       
   677 }
       
   678 
       
   679 // -------------------------------------------------------------------------------------------------
       
   680 // Steps back one level back in collection path. Will activate previous view if level exists
       
   681 // -------------------------------------------------------------------------------------------------
       
   682 //
       
   683 void CMpxVideoPlayerAppUiEngine::StepBackCollectionPathL()
       
   684 {
       
   685     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::StepBackCollectionPathL()"));
       
   686 
       
   687     // Back the collection path one level...
       
   688 
       
   689     CMPXCollectionPath* cPath = iCollectionUtility->Collection().PathL();
       
   690     CleanupStack::PushL( cPath );
       
   691 
       
   692     // Don't back up if there are no more levels or will panic
       
   693     if ( cPath->Levels() > 1 )
       
   694     {
       
   695         cPath->Back();
       
   696         iCollectionUtility->Collection().OpenL( *cPath );
       
   697 
       
   698         //
       
   699         // Workaround. Don't use mpx view utility yet
       
   700         //
       
   701         // iViewUtility->ActivatePreviousViewL();
       
   702     }
       
   703 
       
   704     CleanupStack::PopAndDestroy( cPath );
       
   705 }
       
   706 
       
   707 // -------------------------------------------------------------------------------------------------
       
   708 // Initialize the playback engine with a collection path
       
   709 // -------------------------------------------------------------------------------------------------
       
   710 //
       
   711 void CMpxVideoPlayerAppUiEngine::InitPlaybackEngineL( CMPXCollectionPath& aPath )
       
   712 {
       
   713     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::InitPlaybackEngineL()"));
       
   714 
       
   715     // Create a playlist with the current collection path
       
   716     CMPXCollectionPlaylist* playlist = CMPXCollectionPlaylist::NewL( aPath );
       
   717     CleanupStack::PushL( playlist );
       
   718 
       
   719     playlist->SetSingleItemPlaylist();
       
   720     iPlaybackUtility->InitL( *playlist, ETrue );
       
   721 
       
   722     CleanupStack::PopAndDestroy( playlist );
       
   723 }
   494 }
   724 
   495 
   725 // -------------------------------------------------------------------------------------------------
   496 // -------------------------------------------------------------------------------------------------
   726 //   CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL
   497 //   CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL
   727 // -------------------------------------------------------------------------------------------------
   498 // -------------------------------------------------------------------------------------------------
   839                                       (TDesC8*)(&KDATATYPEVIDEOHELIX),
   610                                       (TDesC8*)(&KDATATYPEVIDEOHELIX),
   840                                       iAccessPointId );
   611                                       iAccessPointId );
   841 }
   612 }
   842 
   613 
   843 // -------------------------------------------------------------------------------------------------
   614 // -------------------------------------------------------------------------------------------------
   844 //   CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL
       
   845 // -------------------------------------------------------------------------------------------------
       
   846 //
       
   847 void CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL( const TDesC8 &aMsg )
       
   848 {
       
   849     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL()"));
       
   850 
       
   851     if ( aMsg.Length() < KVideoPlayerActivationMessageMinLength )
       
   852     {
       
   853         User::Leave( KErrNotSupported );
       
   854     }
       
   855 
       
   856     TVideoPlayerActivationMessage msgHandler;
       
   857     TPckg<TVideoPlayerActivationMessage> paramsPckg( msgHandler );
       
   858     paramsPckg.Copy( aMsg );
       
   859 
       
   860     if ( msgHandler.iMsgType == TVideoPlayerActivationMessage::ELaunchVideoToPlayer )
       
   861     {
       
   862         // Launch video to player, it can be either local video or stream.
       
   863 
       
   864         // If there's path and mpx id,
       
   865         // clip can be played directly.
       
   866         if ( msgHandler.iServiceId && 
       
   867              msgHandler.iFullPath.Length() > 0 )
       
   868         {
       
   869             if ( iRecognizer->IdentifyMediaTypeL( msgHandler.iFullPath )
       
   870                   ==  CMediaRecognizer::ELocalVideoFile )
       
   871             {
       
   872                 TMPXItemId id;
       
   873                 id.iId1 = msgHandler.iServiceId;
       
   874 				CMPXMedia* media = CMPXMedia::NewL();
       
   875                 CleanupStack::PushL( media );
       
   876 				media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, id );
       
   877 				OpenMediaL( *media );
       
   878 				CleanupStack::PopAndDestroy( media );
       
   879             }
       
   880             else
       
   881             {
       
   882                 // Most likely the clip has been deleted
       
   883                 User::Leave( KErrNotFound );
       
   884             }
       
   885         }
       
   886     }
       
   887 }
       
   888 
       
   889 // -------------------------------------------------------------------------------------------------
       
   890 //   CMpxVideoPlayerAppUiEngine::HandleMessageL()
   615 //   CMpxVideoPlayerAppUiEngine::HandleMessageL()
   891 // -------------------------------------------------------------------------------------------------
   616 // -------------------------------------------------------------------------------------------------
   892 //
   617 //
   893 TBool CMpxVideoPlayerAppUiEngine::HandleMessageL( TUid aMessageUid,
   618 TBool CMpxVideoPlayerAppUiEngine::HandleMessageL( TUid /* aMessageUid */,
   894                                                   const TDesC8& aMessageParameters )
   619                                                   const TDesC8& /* aMessageParameters */ )
   895 {
   620 {
   896     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleMessageL()"));
   621     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleMessageL()"));
   897 
   622 
   898     TBool msgHandled = EFalse;
   623     TBool msgHandled = EFalse;
   899 
       
   900     switch ( aMessageUid.iUid )
       
   901     {
       
   902         // TVideoPlayerActivationMessage received.
       
   903         case KVideoPlayerVodStartPlayer:
       
   904         {
       
   905             ProcessActivationMessageL( aMessageParameters );
       
   906             msgHandled = ETrue;
       
   907             break;
       
   908         }
       
   909         case KVideoPlayerStartPDlPlayer:
       
   910         {
       
   911             // Start the PDl
       
   912             if ( iPdlHandler )
       
   913             {
       
   914                 CBufFlat* paramBuf = CBufFlat::NewL( 1 );
       
   915                 CleanupStack::PushL( paramBuf );
       
   916                 paramBuf->InsertL( 0, aMessageParameters );
       
   917                 RBufReadStream readStream( *paramBuf );
       
   918 
       
   919                 CAiwGenericParamList* genParamList = CAiwGenericParamList::NewLC( readStream );
       
   920 
       
   921                 HandleAiwGenericParamListL( genParamList );
       
   922 
       
   923                 CleanupStack::PopAndDestroy( genParamList );
       
   924                 CleanupStack::PopAndDestroy( paramBuf );
       
   925 
       
   926                 msgHandled = ETrue;
       
   927             }
       
   928 
       
   929             break;
       
   930         }
       
   931     }
       
   932 
   624 
   933     return msgHandled;
   625     return msgHandled;
   934 }
   626 }
   935 
   627 
   936 // -------------------------------------------------------------------------------------------------
   628 // -------------------------------------------------------------------------------------------------
  1008     {
   700     {
  1009         iPlaybackUtility->InitL( aPlaylist, EFalse );
   701         iPlaybackUtility->InitL( aPlaylist, EFalse );
  1010     }
   702     }
  1011 }
   703 }
  1012 
   704 
  1013 
       
  1014 
       
  1015 // -------------------------------------------------------------------------------------------------
   705 // -------------------------------------------------------------------------------------------------
  1016 // From MMPXCHelperEmbeddedOpenObserver
   706 // From MMPXCHelperEmbeddedOpenObserver
  1017 // Handles OpenL from that occured in embedded mode
   707 // Handles OpenL from that occured in embedded mode
  1018 // -------------------------------------------------------------------------------------------------
   708 // -------------------------------------------------------------------------------------------------
  1019 //
   709 //
  1020 void CMpxVideoPlayerAppUiEngine::HandleEmbeddedOpenL( TInt aErr, TMPXGeneralCategory /*aCategory*/ )
   710 void CMpxVideoPlayerAppUiEngine::HandleEmbeddedOpenL( TInt /*aErr*/, TMPXGeneralCategory /*aCategory*/ )
  1021 {
   711 {
  1022     MPX_DEBUG(_L("CMPXVideoAppUi::HandleEmbeddedOpenL()"));
   712     MPX_DEBUG(_L("CMPXVideoAppUi::HandleEmbeddedOpenL()"));
  1023 
       
  1024     if ( aErr != KErrNone )
       
  1025     {
       
  1026 
       
  1027         // Kill MPX
       
  1028         //RunAppShutter();
       
  1029     }
       
  1030     else // No error, set the launch mode
       
  1031     {
       
  1032         iPlaybackUtility->CommandL( EPbCmdDisableEffect );
       
  1033     }
       
  1034 }
       
  1035 
       
  1036 
       
  1037 void CMpxVideoPlayerAppUiEngine::HandleSoftKeyBackL()
       
  1038 {
       
  1039     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleSoftKeyBackL()"));
       
  1040 
       
  1041     //
       
  1042     //  if we're in top level of our local view stack,
       
  1043     //  back command exits the app.  otherwise activate
       
  1044     //  the previous view in our local view stack
       
  1045     //
       
  1046 
       
  1047     //
       
  1048     // Workaround. Don't use mpx view utility yet
       
  1049     //
       
  1050     // if ( iViewUtility->ViewHistoryDepth() <= 1 )
       
  1051     if ( ETrue )
       
  1052     {
       
  1053         ActivateExitActiveObject();
       
  1054     }
       
  1055     else
       
  1056     {
       
  1057         StepBackCollectionPathL();
       
  1058     }
       
  1059 }
       
  1060 
       
  1061 TBool CMpxVideoPlayerAppUiEngine::ProcessCommandParametersL( TApaCommand aCommand,
       
  1062                                                              TFileName& aDocumentName,
       
  1063                                                              const TDesC8& aTail )
       
  1064 {
       
  1065     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ProcessCommandParametersL()"));
       
  1066 
       
  1067     TBool retVal = EFalse;
       
  1068 
       
  1069     //
       
  1070     //  If command line has tail, this is probably a message from Matrix, Live TV
       
  1071     //  reminder, Video Center soft notification, or other VC component.
       
  1072     //
       
  1073     if ( aTail.Length() > 0 )
       
  1074     {
       
  1075         ProcessActivationMessageL( aTail );
       
  1076     }
       
  1077     else
       
  1078     {
       
  1079         //
       
  1080         //  If we are embedded or the command is to open a document
       
  1081         //
       
  1082 
       
  1083         //
       
  1084         // Workaround. Embedded doesn't work yet
       
  1085         //
       
  1086         // if ( iAppUi->IsEmbedded() || aCommand != EApaCommandRun )
       
  1087         if ( aCommand != EApaCommandRun )
       
  1088         {
       
  1089             if ( iRecognizer->IsValidStreamingPrefix( aDocumentName ) )
       
  1090             {
       
  1091                 retVal = ETrue;
       
  1092             }
       
  1093             else
       
  1094             {
       
  1095                 retVal = ConeUtils::FileExists( aDocumentName );
       
  1096             }
       
  1097         }
       
  1098         else
       
  1099         {
       
  1100             StartStandAloneL();
       
  1101         }
       
  1102     }
       
  1103 
       
  1104     return retVal;
       
  1105 }
       
  1106 
       
  1107 void CMpxVideoPlayerAppUiEngine::ActivateExitActiveObject()
       
  1108 {
       
  1109     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ActivateExitActiveObject()"));
       
  1110 
       
  1111     if ( ! iExitAo->IsActive() )
       
  1112     {
       
  1113         iExitAo->Start( TCallBack( CMpxVideoPlayerAppUiEngine::ExitApplicationL, this ) );
       
  1114     }
       
  1115 }
       
  1116 
       
  1117 // -------------------------------------------------------------------------------------------------
       
  1118 //   CMpxVideoPlayerAppUiEngine::ExitApplicationL
       
  1119 // -------------------------------------------------------------------------------------------------
       
  1120 //
       
  1121 TInt CMpxVideoPlayerAppUiEngine::ExitApplicationL( TAny* aPtr )
       
  1122 {
       
  1123     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ExitApplicationL()"));
       
  1124 
       
  1125     static_cast<CMpxVideoPlayerAppUiEngine*>(aPtr)->DoExitApplicationL();
       
  1126     return KErrNone;
       
  1127 }
       
  1128 
       
  1129 // -------------------------------------------------------------------------------------------------
       
  1130 //   CMpxVideoPlayerAppUiEngine::DoExitApplicationL
       
  1131 // -------------------------------------------------------------------------------------------------
       
  1132 //
       
  1133 void CMpxVideoPlayerAppUiEngine::DoExitApplicationL()
       
  1134 {
       
  1135     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoExitApplicationL()"));
       
  1136 
       
  1137     /*iAppUi->HandleCommandL( EEikCmdExit );*/
       
  1138 }
   713 }
  1139 
   714 
  1140 // -------------------------------------------------------------------------------------------------
   715 // -------------------------------------------------------------------------------------------------
  1141 //   CMpxVideoPlayerAppUiEngine::UpdatePbPluginMedia()
   716 //   CMpxVideoPlayerAppUiEngine::UpdatePbPluginMedia()
  1142 // -------------------------------------------------------------------------------------------------
   717 // -------------------------------------------------------------------------------------------------