videoplayerapp/videoplayerengine/src/mpxvideoplayerappuiengine.cpp
branchRCL_3
changeset 56 839377eedc2b
equal deleted inserted replaced
54:315810614048 56:839377eedc2b
       
     1 /*
       
     2 * Copyright (c) 2009 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:  CMpxVideoPlayerAppUiEngine
       
    15  *
       
    16 */
       
    17 
       
    18 // Version : %version:  12 %
       
    19 
       
    20 
       
    21 
       
    22 #include <mpxcommand.h>
       
    23 #include <mpxcommandgeneraldefs.h>
       
    24 #include <mpxmessagegeneraldefs.h>
       
    25 #include <mpxplaybackmessage.h>
       
    26 #include <mpxplaybackutility.h>
       
    27 #include <mpxcollectionmessage.h>
       
    28 #include <mpxmediageneraldefs.h>
       
    29 #include <mpxcollectionmessagedefs.h>
       
    30 #include <vcxmyvideosdefs.h>
       
    31 #include <mpxcollectionpath.h>
       
    32 #include <videoplayeractivationmessage.h>
       
    33 #include <mpxcollectionuihelper.h>
       
    34 #include <mpxcollectionhelperfactory.h>
       
    35 #include <mpxcollectionplugin.hrh>
       
    36 #include <mpxmediageneralextdefs.h>
       
    37 #include <mmf/common/mmfcontrollerframeworkbase.h>
       
    38 
       
    39 #include <coeutils.h>
       
    40 #include <textresolver.h>
       
    41 #include <videoplaylistutility.h>
       
    42 #include <mpxvideoplaybackdefs.h>
       
    43 #include <mpxmediacontainerdefs.h>
       
    44 #include <mpxmediaarray.h>
       
    45 
       
    46 #include "mpxvideoplayerappuiengine.h"
       
    47 #include "mpxvideoplayerconstants.h"
       
    48 #include "videoplaybackwrapper.h"
       
    49 #include "mpxhbvideocommondefs.h"
       
    50 #include "videoactivitystate.h" 
       
    51 
       
    52 #include "mpxvideo_debug.h"
       
    53 
       
    54 // -------------------------------------------------------------------------------------------------
       
    55 //   CMpxVideoPlayerAppUiEngine::CMpxVideoPlayerAppUiEngine
       
    56 // -------------------------------------------------------------------------------------------------
       
    57 //
       
    58 CMpxVideoPlayerAppUiEngine::CMpxVideoPlayerAppUiEngine( VideoPlaybackWrapper* aWrapper )
       
    59     : iPlaybackUtility( NULL ),
       
    60       iCollectionUtility( NULL ),
       
    61       iRecognizer( NULL ),
       
    62       iAccessPointId( KUseDefaultIap ),
       
    63       iMultilinkPlaylist( EFalse ),
       
    64       iSeekable( ETrue ),
       
    65       iUpdateSeekInfo( EFalse ),
       
    66       iPlaybackWrapper( aWrapper )
       
    67 {
       
    68 }
       
    69 
       
    70 // -------------------------------------------------------------------------------------------------
       
    71 //   CMpxVideoPlayerAppUiEngine::NewL
       
    72 // -------------------------------------------------------------------------------------------------
       
    73 //
       
    74 CMpxVideoPlayerAppUiEngine* CMpxVideoPlayerAppUiEngine::NewL( VideoPlaybackWrapper* aWrapper )
       
    75 {
       
    76     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::NewL()"));
       
    77 
       
    78     CMpxVideoPlayerAppUiEngine* self = new( ELeave) CMpxVideoPlayerAppUiEngine( aWrapper );
       
    79 
       
    80     CleanupStack::PushL(self);
       
    81     self->ConstructL();
       
    82     CleanupStack::Pop(self);
       
    83     return self;
       
    84 }
       
    85 
       
    86 // -------------------------------------------------------------------------------------------------
       
    87 //   CMpxVideoPlayerAppUiEngine::ConstructL
       
    88 // -------------------------------------------------------------------------------------------------
       
    89 //
       
    90 void CMpxVideoPlayerAppUiEngine::ConstructL()
       
    91 {    
       
    92     TUid collectionMode( KUidMpxVideoPlayerApplication );
       
    93 
       
    94     iCollectionUtility = MMPXCollectionUtility::NewL( this, collectionMode ); 
       
    95 }
       
    96 
       
    97 // -------------------------------------------------------------------------------------------------
       
    98 //   CMpxVideoPlayerAppUiEngine::PostInitL
       
    99 // -------------------------------------------------------------------------------------------------
       
   100 //
       
   101 void CMpxVideoPlayerAppUiEngine::LateInitL()
       
   102 {	       
       
   103     CreatePlaybackUtilityL();
       
   104     
       
   105     if ( ! iRecognizer )
       
   106     {
       
   107         iRecognizer = CMediaRecognizer::NewL();
       
   108     }
       
   109 }
       
   110 
       
   111 // -------------------------------------------------------------------------------------------------
       
   112 //   CMpxVideoPlayerAppUiEngine::CreateCollectionUtilityMemberVariablesL
       
   113 // -------------------------------------------------------------------------------------------------
       
   114 //
       
   115 void CMpxVideoPlayerAppUiEngine::CreateCollectionUtilityMemberVariablesL()
       
   116 {
       
   117     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::CreateCollectionUtilityMemberVariablesL()"));
       
   118 
       
   119     if ( ! iCollectionUtility )
       
   120     {
       
   121         //  PLAYLIST default mode
       
   122         iCollectionUtility = MMPXCollectionUtility::NewL( this );
       
   123     }
       
   124 
       
   125     if ( ! iCollectionUiHelper )
       
   126     {
       
   127         iCollectionUiHelper = CMPXCollectionHelperFactory::NewCollectionUiHelperL();
       
   128     }
       
   129 }
       
   130 
       
   131 // -------------------------------------------------------------------------------------------------
       
   132 //   CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityL
       
   133 // -------------------------------------------------------------------------------------------------
       
   134 //
       
   135 void CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityL()
       
   136 {
       
   137     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityL()"));
       
   138 
       
   139     if ( ! iPlaybackUtility )
       
   140     {
       
   141         //
       
   142         //  Create VideoHelix playback plugin
       
   143         //
       
   144         iPlaybackUtility = MMPXPlaybackUtility::UtilityL( EMPXCategoryVideo, KPbModeNewPlayer );
       
   145         MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
       
   146         manager.SelectPlayerL( KVideoHelixPlaybackPluginUid );
       
   147         iPlaybackUtility->AddObserverL( *this );
       
   148         iPlaybackUtility->CommandL( EPbCmdSetAutoResume, EFalse );
       
   149     }
       
   150 }
       
   151 
       
   152 // -------------------------------------------------------------------------------------------------
       
   153 //   CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine
       
   154 // -------------------------------------------------------------------------------------------------
       
   155 //
       
   156 CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine()
       
   157 {
       
   158     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine()"));
       
   159 
       
   160     if ( iRecognizer )
       
   161     {
       
   162         delete iRecognizer;
       
   163         iRecognizer = NULL;
       
   164     }
       
   165 
       
   166     if ( iCollectionUtility )
       
   167     {
       
   168         iCollectionUtility->Close();
       
   169     }
       
   170 
       
   171     if ( iCollectionUiHelper )
       
   172     {
       
   173         iCollectionUiHelper->Close();
       
   174     }
       
   175 
       
   176     if ( iPlaybackUtility )
       
   177     {
       
   178         TRAP_IGNORE( iPlaybackUtility->CommandL( EPbCmdClose ) );
       
   179         TRAP_IGNORE( iPlaybackUtility->RemoveObserverL( *this ) );
       
   180         iPlaybackUtility->Close();
       
   181     }
       
   182 }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // From MMPXPlaybackObserver
       
   186 // Handle playback message.
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 void CMpxVideoPlayerAppUiEngine::HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError )
       
   190 {
       
   191     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandlePlaybackMessage()"));
       
   192 
       
   193     if ( aError == KErrNone && aMessage )
       
   194     {
       
   195         TRAP_IGNORE( DoHandlePlaybackMessageL( *aMessage ) );
       
   196     }
       
   197 }
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // From MMPXViewActivationObserver.
       
   201 // Handle view activation.
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 void CMpxVideoPlayerAppUiEngine::HandleViewActivation( const TUid& /*aCurrentViewType*/,
       
   205                                                        const TUid& /*aPreviousViewType*/ )
       
   206 {
       
   207 }
       
   208 
       
   209 // -------------------------------------------------------------------------------------------------
       
   210 //   CMpxVideoPlayerAppUiEngine::OpenFileL
       
   211 // -------------------------------------------------------------------------------------------------
       
   212 //
       
   213 void CMpxVideoPlayerAppUiEngine::OpenFileL( RFile& aFile )
       
   214 {
       
   215     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenFileL(RFile)"));
       
   216 
       
   217     TFileName filename;
       
   218     aFile.FullName(filename);
       
   219     
       
   220     LateInitL();
       
   221 
       
   222     CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL( filename, aFile );
       
   223 
       
   224     if ( mediaType == CMediaRecognizer::ELocalRamFile ||
       
   225          mediaType == CMediaRecognizer::ELocalAsxFile )
       
   226     {
       
   227         HandleMultiLinksFileL( aFile, mediaType );
       
   228     }
       
   229     else if ( mediaType == CMediaRecognizer::ELocalSdpFile )
       
   230     {
       
   231         iPlaybackUtility->InitStreamingL( aFile, iAccessPointId );
       
   232     }
       
   233     else
       
   234     {
       
   235         iPlaybackUtility->InitL( aFile );
       
   236     }    
       
   237 
       
   238     iRecognizer->FreeFilehandle();
       
   239 
       
   240     aFile.Close();
       
   241 }
       
   242 
       
   243 
       
   244 // -------------------------------------------------------------------------------------------------
       
   245 //   CMpxVideoPlayerAppUiEngine::OpenFileL
       
   246 // -------------------------------------------------------------------------------------------------
       
   247 //
       
   248 void CMpxVideoPlayerAppUiEngine::OpenFileL( const TDesC& aFileName )
       
   249 {
       
   250     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenFileL()"),
       
   251                    _L("aFileName = %S"), &aFileName);    
       
   252     
       
   253     LateInitL();
       
   254     
       
   255     CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL(aFileName);
       
   256 
       
   257     if ( mediaType == CMediaRecognizer::ELocalVideoFile )
       
   258     {
       
   259         iPlaybackUtility->InitL( aFileName );
       
   260     }
       
   261     // check if aFileName is a path to a ram or asx file
       
   262     //          eg. c:\\data\\videos\\ramfile.ram
       
   263     else if ( mediaType == CMediaRecognizer::ELocalRamFile ||
       
   264               mediaType == CMediaRecognizer::ELocalAsxFile )
       
   265     {
       
   266         HandleMultiLinksFileL( aFileName, mediaType );
       
   267     }
       
   268     // check if this is a url eg. rtsp://someaddress/file.3gp
       
   269     //
       
   270     else if ( iRecognizer->IsValidStreamingPrefix(aFileName) )
       
   271     {
       
   272         HandleUrlDesL( aFileName );
       
   273     }
       
   274     else if ( mediaType == CMediaRecognizer::ELocalSdpFile )
       
   275     {
       
   276         iPlaybackUtility->InitStreamingL( aFileName,
       
   277                                          (TDesC8*)(&KDATATYPEVIDEOHELIX),
       
   278                                          iAccessPointId );
       
   279     }
       
   280     else
       
   281     {
       
   282         iPlaybackUtility->InitL( aFileName );
       
   283     }
       
   284 
       
   285     iRecognizer->FreeFilehandle();
       
   286 }
       
   287 
       
   288 // -------------------------------------------------------------------------------------------------
       
   289 // Open MPX media to player.
       
   290 // -------------------------------------------------------------------------------------------------
       
   291 //
       
   292 void CMpxVideoPlayerAppUiEngine::OpenMediaL( const CMPXMedia& aMedia )
       
   293 {
       
   294     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenMediaL()"));
       
   295 
       
   296     // Assume MPX medias are always local clips
       
   297     CMPXCollectionPath* mediaPath = CMPXCollectionPath::NewL();
       
   298     CleanupStack::PushL( mediaPath );
       
   299 
       
   300     //
       
   301     // Workaround. Need a file like vcxmyvideosuids.h 
       
   302     //
       
   303     mediaPath->AppendL( 0x20016B97 );
       
   304     mediaPath->AppendL( KVcxMvcCategoryIdAll );
       
   305         
       
   306     mediaPath->AppendL( aMedia.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
       
   307     mediaPath->SelectL( aMedia.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
       
   308 
       
   309     CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *mediaPath );
       
   310     CleanupStack::PushL( playList );
       
   311     playList->SetSingleItemPlaylist();
       
   312     playList->SetToFirst();
       
   313     
       
   314     LateInitL();
       
   315     
       
   316     iPlaybackUtility->InitL( *playList, ETrue );
       
   317 
       
   318     CleanupStack::PopAndDestroy( playList );
       
   319     CleanupStack::PopAndDestroy( mediaPath );
       
   320 }
       
   321 
       
   322 // -------------------------------------------------------------------------------------------------
       
   323 // Handle playback message.
       
   324 // -------------------------------------------------------------------------------------------------
       
   325 //
       
   326 void CMpxVideoPlayerAppUiEngine::DoHandlePlaybackMessageL( const CMPXMessage& aMessage )
       
   327 {
       
   328     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoHandlePlaybackMessageL()"));
       
   329 
       
   330     TMPXMessageId id( *aMessage.Value<TMPXMessageId>( KMPXMessageGeneralId ) );
       
   331 
       
   332     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandlePlaybackMessageL TMPXMessageId = 0x%08x"), id );
       
   333 
       
   334     if ( KMPXMessageGeneral == id )
       
   335     {
       
   336         TInt event( *aMessage.Value<TInt>( KMPXMessageGeneralEvent ) );
       
   337 
       
   338         MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandlePlaybackMessageL() event = %d"), event);
       
   339 
       
   340         switch ( event )
       
   341         {
       
   342             case TMPXPlaybackMessage::EPlayerChanged:
       
   343             {
       
   344                 MPX_DEBUG(_L("    EPlayerChanged"));
       
   345 
       
   346                 if ( iUpdateSeekInfo )
       
   347                 {
       
   348                     // The plugin has been instantiated, update the media
       
   349                     UpdatePbPluginMediaL();
       
   350                     iUpdateSeekInfo = EFalse;
       
   351                 }
       
   352 
       
   353                 HandlePlaybackPlayerChangedL();
       
   354                 break;
       
   355             }
       
   356         }
       
   357     }
       
   358 }
       
   359 
       
   360 // -------------------------------------------------------------------------------------------------
       
   361 // Handle playback message for player changed.
       
   362 // Activate the view which support this player
       
   363 // -------------------------------------------------------------------------------------------------
       
   364 //
       
   365 void CMpxVideoPlayerAppUiEngine::HandlePlaybackPlayerChangedL()
       
   366 {
       
   367     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandlePlaybackPlayerChangedL()"));
       
   368 
       
   369     ActivateVideoPlaybackView();
       
   370 }
       
   371 
       
   372 // -------------------------------------------------------------------------------------------------
       
   373 // Creates plugin resolver + creates & activates the video view
       
   374 // -------------------------------------------------------------------------------------------------
       
   375 //
       
   376 void CMpxVideoPlayerAppUiEngine::ActivateVideoPlaybackView()
       
   377 {
       
   378     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ActivateVideoPlaybackView()"));
       
   379     
       
   380     iPlaybackWrapper->openPlaybackView();
       
   381 }
       
   382 
       
   383 // -------------------------------------------------------------------------------------------------
       
   384 // Closed mpx components and readies to application takedown.
       
   385 // -------------------------------------------------------------------------------------------------
       
   386 //
       
   387 void CMpxVideoPlayerAppUiEngine::PrepareCloseMpxL()
       
   388 {
       
   389     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::PrepareCloseMpxL()"));
       
   390 
       
   391     if ( iPlaybackUtility )
       
   392     {
       
   393         iPlaybackUtility->CommandL( EPbCmdClose );
       
   394         MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
       
   395         TRAP_IGNORE( manager.ClearSelectPlayersL() );
       
   396     }
       
   397 }
       
   398 
       
   399 // -------------------------------------------------------------------------------------------------
       
   400 // Handle collection message
       
   401 // -------------------------------------------------------------------------------------------------
       
   402 //
       
   403 void CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL( CMPXMessage* aMessage )
       
   404 {
       
   405     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL()"));
       
   406 
       
   407     TMPXMessageId id = *(aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ));
       
   408 
       
   409     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL() TMPXMessageId = 0x%08x"), id );
       
   410 
       
   411     if ( id == KMPXMessageGeneral )
       
   412     {
       
   413         TInt event( *( aMessage->Value<TInt> ( KMPXMessageGeneralEvent )) );
       
   414         TInt type( *( aMessage->Value<TInt> ( KMPXMessageGeneralType )) );
       
   415         TInt data( *( aMessage->Value<TInt> ( KMPXMessageGeneralData )) );
       
   416 
       
   417         MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL event %d, type %d, data %d"), event, type, data );
       
   418 
       
   419         if ( event == TMPXCollectionMessage::EPathChanged && type == EMcPathChangedByOpen )
       
   420         {
       
   421             if ( data == EMcItemOpened )
       
   422             {
       
   423                 // An item was opened on the collection. Get the media attributes
       
   424                 // on the item so we can initiatiate playback
       
   425                 MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL: EMcItemOpened received. Can open video"));
       
   426 
       
   427                 CMPXCollectionPath* cPath = iCollectionUtility->Collection().PathL();
       
   428 
       
   429                 CleanupStack::PushL( cPath );
       
   430 
       
   431                 if ( cPath->Count() > 0 )
       
   432                 {
       
   433                     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL: Call MediaL() on collection."));
       
   434 
       
   435                      RArray<TMPXAttribute> attribs;
       
   436                     CleanupClosePushL( attribs );
       
   437 
       
   438                     attribs.Append( KMPXMediaGeneralUri );
       
   439                     attribs.Append( KVcxMediaMyVideosDownloadId );
       
   440                     iCollectionUtility->Collection().MediaL( *cPath, attribs.Array() );
       
   441 
       
   442                     CleanupStack::PopAndDestroy( &attribs );
       
   443                 }
       
   444 
       
   445                 CleanupStack::PopAndDestroy( cPath );
       
   446             }
       
   447             else if ( data == EMcContainerOpened && iMultilinkPlaylist )
       
   448             {
       
   449                 // start the playback for streaming playlists
       
   450                 // once the playlist is opened
       
   451                 iMultilinkPlaylist = EFalse;
       
   452 
       
   453                 // The playlist was opened, initiatiate playback
       
   454                 MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL: EMcContainerOpened received. initiatiate playback"));
       
   455 
       
   456                 CMPXCollectionPath* cPath = iCollectionUtility->Collection().PathL();
       
   457                 CleanupStack::PushL( cPath );
       
   458 
       
   459                 if ( cPath->Count() > 0 )
       
   460                 {
       
   461                     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL: Call Playback utility with the playlist."));
       
   462 
       
   463                     CMPXCollectionPlaylist* playlist = CMPXCollectionPlaylist::NewL( *cPath );
       
   464                     CleanupStack::PushL( playlist );
       
   465 
       
   466                     // Set the AutoPlay mode to false
       
   467                     playlist->SetAutoPlay(EFalse);
       
   468                     // set pre init plugin to false
       
   469                     playlist->SetPreInitPlugin(EFalse);
       
   470 
       
   471                     iPlaybackUtility->InitL( *playlist, ETrue );
       
   472                     CleanupStack::PopAndDestroy( playlist );
       
   473                 }
       
   474                 CleanupStack::PopAndDestroy( cPath );
       
   475             }
       
   476         }
       
   477     }
       
   478 }
       
   479 
       
   480 // -------------------------------------------------------------------------------------------------
       
   481 // From MMPXCollectionObserver.
       
   482 // Handle media properties.
       
   483 // -------------------------------------------------------------------------------------------------
       
   484 //
       
   485 void CMpxVideoPlayerAppUiEngine::DoHandelCollectionMediaL( const CMPXMedia& aMedia )
       
   486 {
       
   487     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoHandelCollectionMediaL()"));
       
   488 
       
   489     const TDesC& fileUri = aMedia.ValueText(KMPXMediaGeneralUri);
       
   490 
       
   491     MPX_DEBUG(_L("Video URI: %S"), &fileUri );
       
   492 
       
   493     //OpenMediaL( aMedia ); // Initialize and initiate playback of a single video
       
   494 
       
   495     LateInitL();
       
   496     
       
   497     TPtrC mediaFile( aMedia.ValueText( KMPXMediaGeneralUri ) );
       
   498     CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL(mediaFile);
       
   499         
       
   500     if ( mediaType == CMediaRecognizer::ELocalRamFile ||
       
   501          mediaType == CMediaRecognizer::ELocalAsxFile )
       
   502     {   
       
   503         HandleMultiLinksFileL( mediaFile, mediaType );
       
   504     }    
       
   505     else
       
   506     {
       
   507         OpenMediaL( aMedia ); // Initialize and initiate playback of a single video
       
   508     }    
       
   509 }
       
   510 
       
   511 // -------------------------------------------------------------------------------------------------
       
   512 //   CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL
       
   513 // -------------------------------------------------------------------------------------------------
       
   514 //
       
   515 void CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL( const TDesC& aFileName,
       
   516                                                         CMediaRecognizer::TMediaType aMediaType )
       
   517 {
       
   518     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL()"),
       
   519                    _L("aFileName = %S, type = %d"), &aFileName, aMediaType );
       
   520 
       
   521     TBool singleLink;
       
   522     TBool localFile;
       
   523 
       
   524     CVideoPlaylistUtility* playlistUtil = CVideoPlaylistUtility::NewL();
       
   525     CleanupStack::PushL(playlistUtil);
       
   526 
       
   527     playlistUtil->GetFileInfoL( aFileName, aMediaType, singleLink, localFile );
       
   528 
       
   529     DoHandleMultiLinksFileL( playlistUtil, singleLink, localFile );
       
   530 
       
   531     CleanupStack::PopAndDestroy( playlistUtil );
       
   532 }
       
   533 
       
   534 // -------------------------------------------------------------------------------------------------
       
   535 //   CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL
       
   536 // -------------------------------------------------------------------------------------------------
       
   537 //
       
   538 void CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL( RFile& aFile,
       
   539                                                         CMediaRecognizer::TMediaType aMediaType )
       
   540 {
       
   541     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL(RFile)"));
       
   542 
       
   543     // playlist
       
   544     TBool singleLink;
       
   545     TBool localFile;
       
   546 
       
   547     CVideoPlaylistUtility* playlistUtil = CVideoPlaylistUtility::NewL();
       
   548     CleanupStack::PushL(playlistUtil);
       
   549 
       
   550     playlistUtil->GetFileInfoL( aFile, aMediaType, singleLink, localFile );
       
   551 
       
   552     DoHandleMultiLinksFileL( playlistUtil, singleLink, localFile );
       
   553 
       
   554     CleanupStack::PopAndDestroy( playlistUtil );
       
   555 }
       
   556 
       
   557 
       
   558 void CMpxVideoPlayerAppUiEngine::DoHandleMultiLinksFileL( CVideoPlaylistUtility* aPlaylistUtil,
       
   559                                                           TBool aSingleLink,
       
   560                                                           TBool aLocalFile )
       
   561 {
       
   562     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoHandleMultiLinksFileL()"),
       
   563                    _L("aSingleLink = %d aLocalFile %d "), aSingleLink, aLocalFile);
       
   564 
       
   565     if ( aSingleLink )
       
   566     {
       
   567         TPtrC link;
       
   568         link.Set( aPlaylistUtil->GetLinkLC() );
       
   569         iUpdateSeekInfo = ETrue;
       
   570         iSeekable = aPlaylistUtil->IsSeekable();
       
   571 
       
   572         if ( aLocalFile )
       
   573         {
       
   574             iPlaybackUtility->InitL( link );
       
   575         }
       
   576         else
       
   577         {
       
   578             iPlaybackUtility->InitStreamingL( link,
       
   579                                              (TDesC8*)(&KDATATYPEVIDEOHELIX),
       
   580                                              iAccessPointId );
       
   581         }
       
   582         CleanupStack::PopAndDestroy();  // link
       
   583     }
       
   584     else
       
   585     {
       
   586 
       
   587         CMPXMedia* playlist = aPlaylistUtil->GetPlayListL( iAccessPointId );
       
   588         CleanupStack::PushL( playlist );
       
   589 
       
   590         //  Create FW utility member variables for playlist embedded use case
       
   591         CreateCollectionUtilityMemberVariablesL();
       
   592 
       
   593         // Set the flag to true
       
   594         iMultilinkPlaylist = ETrue;
       
   595 
       
   596         // load the in memory plugin
       
   597         iCollectionUiHelper->OpenL( KUidMpxVideoPlayerApplication,
       
   598                                     *playlist,
       
   599                                     this,
       
   600                                     EMPXCollectionPluginGallery );
       
   601 
       
   602         CleanupStack::PopAndDestroy( playlist );
       
   603     }
       
   604 }
       
   605 
       
   606 // -------------------------------------------------------------------------------------------------
       
   607 //   CMpxVideoPlayerAppUiEngine::HandleUrlDesL
       
   608 // -------------------------------------------------------------------------------------------------
       
   609 //
       
   610 void CMpxVideoPlayerAppUiEngine::HandleUrlDesL( const TDesC& aUrl )
       
   611 {
       
   612     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleUrlDesL()"),
       
   613                    _L("aUrl = %S"), &aUrl );
       
   614 
       
   615     iPlaybackUtility->InitStreamingL( aUrl,
       
   616                                       (TDesC8*)(&KDATATYPEVIDEOHELIX),
       
   617                                       iAccessPointId );
       
   618 }
       
   619 
       
   620 // -------------------------------------------------------------------------------------------------
       
   621 //   CMpxVideoPlayerAppUiEngine::HandleMessageL()
       
   622 // -------------------------------------------------------------------------------------------------
       
   623 //
       
   624 TBool CMpxVideoPlayerAppUiEngine::HandleMessageL( TUid /* aMessageUid */,
       
   625                                                   const TDesC8& /* aMessageParameters */ )
       
   626 {
       
   627     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleMessageL()"));
       
   628 
       
   629     TBool msgHandled = EFalse;
       
   630 
       
   631     return msgHandled;
       
   632 }
       
   633 
       
   634 // -------------------------------------------------------------------------------------------------
       
   635 // Handle Custom messages from the collection
       
   636 // -------------------------------------------------------------------------------------------------
       
   637 //
       
   638 void CMpxVideoPlayerAppUiEngine::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
       
   639 {
       
   640     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleCollectionMessage()"));
       
   641 
       
   642     if ( aError == KErrNone && aMessage )
       
   643     {
       
   644         TRAP_IGNORE( DoHandleCollectionMessageL( aMessage ) )
       
   645     }
       
   646 }
       
   647 
       
   648 // -------------------------------------------------------------------------------------------------
       
   649 // From MMPXCollectionObserver.
       
   650 // Handle media properties.
       
   651 // -------------------------------------------------------------------------------------------------
       
   652 //
       
   653 void CMpxVideoPlayerAppUiEngine::HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError )
       
   654 {
       
   655     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleCollectionMediaL()"));
       
   656 
       
   657     if ( aError == KErrNone )
       
   658     {
       
   659         DoHandelCollectionMediaL( aMedia );
       
   660     }
       
   661 }
       
   662 
       
   663 // -------------------------------------------------------------------------------------------------
       
   664 // From MMPXCollectionObserver.
       
   665 // Handles the collection entries being opened.
       
   666 // -------------------------------------------------------------------------------------------------
       
   667 //
       
   668 void CMpxVideoPlayerAppUiEngine::HandleOpenL( const CMPXMedia& /* aEntries */,
       
   669                                               TInt /* aIndex */,
       
   670                                               TBool /* aComplete */,
       
   671                                               TInt aError )
       
   672 {
       
   673     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleOpenL(CMPXMedia)"));
       
   674 
       
   675     if ( aError != KErrNone )
       
   676     {
       
   677         //
       
   678         //  Clip the collection path to root level and reopen
       
   679         //  This could happen after a USB refresh event where the
       
   680         //  item no longer exists
       
   681         //
       
   682         CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
       
   683 
       
   684         CleanupStack::PushL( path );
       
   685 
       
   686         while( path->Levels() > 1 )
       
   687         {
       
   688             path->Back();
       
   689         }
       
   690 
       
   691         iCollectionUtility->Collection().OpenL( *path );
       
   692         CleanupStack::PopAndDestroy( path );
       
   693     }
       
   694 }
       
   695 
       
   696 // -------------------------------------------------------------------------------------------------
       
   697 // From MMPXCollectionObserver.
       
   698 // Handles the item being opened.
       
   699 // -------------------------------------------------------------------------------------------------
       
   700 //
       
   701 void CMpxVideoPlayerAppUiEngine::HandleOpenL( const CMPXCollectionPlaylist& aPlaylist, TInt aError )
       
   702 {
       
   703     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleOpenL(CMPXCollectionPlaylist)"));
       
   704 
       
   705     if ( aError == KErrNone )
       
   706     {
       
   707         iPlaybackUtility->InitL( aPlaylist, EFalse );
       
   708     }
       
   709 }
       
   710 
       
   711 // -------------------------------------------------------------------------------------------------
       
   712 // From MMPXCHelperEmbeddedOpenObserver
       
   713 // Handles OpenL from that occured in embedded mode
       
   714 // -------------------------------------------------------------------------------------------------
       
   715 //
       
   716 void CMpxVideoPlayerAppUiEngine::HandleEmbeddedOpenL( TInt /*aErr*/, TMPXGeneralCategory /*aCategory*/ )
       
   717 {
       
   718     MPX_DEBUG(_L("CMPXVideoAppUi::HandleEmbeddedOpenL()"));
       
   719 }
       
   720 
       
   721 // -------------------------------------------------------------------------------------------------
       
   722 //   CMpxVideoPlayerAppUiEngine::UpdatePbPluginMedia()
       
   723 // -------------------------------------------------------------------------------------------------
       
   724 //
       
   725 void CMpxVideoPlayerAppUiEngine::UpdatePbPluginMediaL()
       
   726 {
       
   727     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::UpdatePbPluginMediaL()iSeekable %d"), iSeekable);
       
   728 
       
   729     CMPXCommand* cmd = CMPXCommand::NewL();
       
   730     CleanupStack::PushL( cmd );
       
   731 
       
   732     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
   733 
       
   734     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
   735 
       
   736     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand, 
       
   737                                                      EPbCmdUpdateSeekable );
       
   738 
       
   739     cmd->SetTObjectValueL<TBool>( KMPXMediaGeneralExtVideoSeekable, iSeekable );
       
   740 
       
   741     iPlaybackUtility->CommandL( *cmd );
       
   742     
       
   743     CleanupStack::PopAndDestroy( cmd );
       
   744 }
       
   745 
       
   746 
       
   747 // -------------------------------------------------------------------------------------------------
       
   748 //   CMpxVideoPlayerAppUiEngine::ReplayAfterPriorTermination()
       
   749 // -------------------------------------------------------------------------------------------------
       
   750 //
       
   751 TInt CMpxVideoPlayerAppUiEngine::ReplayAfterPriorTermination(const TDesC& aFileName)
       
   752 {
       
   753     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ReplayAfterPriorTermination()"));        
       
   754     
       
   755     ReadActivityData();
       
   756     TMPXItemId mpxItemId(iLastPlayedItemId);
       
   757     
       
   758     TInt error = KErrNone;    
       
   759     
       
   760     MPX_TRAP( error,         
       
   761         CMPXMedia* media = CMPXMedia::NewL();
       
   762         CleanupStack::PushL(media);
       
   763         
       
   764         media->SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem );  
       
   765         media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, mpxItemId );
       
   766         media->SetTextValueL( KMPXMediaGeneralTitle, aFileName );
       
   767         media->SetTextValueL( KMPXMediaGeneralUri, aFileName );    
       
   768         
       
   769         OpenMediaL( *media );
       
   770         
       
   771         CleanupStack::PopAndDestroy( media );
       
   772         );
       
   773     
       
   774     return error;
       
   775 }
       
   776 
       
   777 // -------------------------------------------------------------------------------------------------
       
   778 //   CMpxVideoPlayerAppUiEngine::ReadActivityData()
       
   779 // -------------------------------------------------------------------------------------------------
       
   780 //
       
   781 void CMpxVideoPlayerAppUiEngine::ReadActivityData()
       
   782 {
       
   783     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ReadActivityData()"));   
       
   784         
       
   785     iLastPlayedItemId = 
       
   786             VideoActivityState::instance().getActivityData(KEY_LAST_PLAYED_MEDIA_ID).toUInt();    
       
   787     
       
   788 }
       
   789 
       
   790 
       
   791 // -------------------------------------------------------------------------------------------------
       
   792 //   CMpxVideoPlayerAppUiEngine::ResolveErrorStringL()
       
   793 // -------------------------------------------------------------------------------------------------
       
   794 //
       
   795 const TDesC& CMpxVideoPlayerAppUiEngine::ResolveErrorStringL(TInt aErrorCode)
       
   796 {
       
   797     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ResolveErrorStringL()"));   
       
   798     
       
   799     CTextResolver* textresolver = CTextResolver::NewL();
       
   800     
       
   801     const TDesC& text = textresolver->ResolveErrorString( aErrorCode );
       
   802     
       
   803     delete textresolver;
       
   804     
       
   805     return text;       
       
   806 }
       
   807 
       
   808 // EOF
       
   809