videoplayback/videoplaybackviews/src/mpxvideobaseplaybackview.cpp
changeset 0 96612d01cf9f
child 1 6711b85517b7
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2008 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:   Implementation of Video base playback view
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 56 %
       
    19 
       
    20 
       
    21 //  Include Files
       
    22 
       
    23 #include <aknViewAppUi.h>
       
    24 #include <w32std.h>
       
    25 #include <eikenv.h>
       
    26 #include <bautils.h>
       
    27 #include <AknUtils.h>
       
    28 #include <coemain.h>
       
    29 #include <hlplch.h>
       
    30 #include <akntoolbar.h>
       
    31 #include <AknUtils.h>
       
    32 #include <data_caging_path_literals.hrh>
       
    33 
       
    34 #include <mpxplaybackcommanddefs.h>
       
    35 #include <mpxcommandgeneraldefs.h>
       
    36 #include <mpxcommand.h>
       
    37 #include <mpxmessagegeneraldefs.h>
       
    38 #include <mpxplaybackmessage.h>
       
    39 #include <mpxmediageneraldefs.h>
       
    40 #include <mpxplaybackutility.h>
       
    41 #include <mpxviewutility.h>
       
    42 #include <StringLoader.h>
       
    43 #include <aknnotewrappers.h>
       
    44 #include <mpxvideoplaybackviews.rsg>
       
    45 #include <textresolver.h>
       
    46 #include <mmf/common/mmferrors.h>
       
    47 #include <DRMHelper.h>
       
    48 #include <mpxcollectionutility.h>
       
    49 #include <mpxcollectionutility.h>
       
    50 #include <mpxcollectionplaylist.h>
       
    51 #include <mpxcollectionpath.h>
       
    52 #include <mpxmediageneralextdefs.h>
       
    53 
       
    54 #include <drmuihandling.h>
       
    55 #include <drmerrorhandling.h>
       
    56 
       
    57 #include "mpxvideobaseplaybackview.h"
       
    58 #include "mpxvideoplaybackcontainer.h"
       
    59 #include "mpxvideoplaybackcontrol.hrh"
       
    60 #include "mpxcommonvideoplaybackview.hrh"
       
    61 #include "mpxvideoplaybackviewfiledetails.h"
       
    62 #include "mpxvideoplaybackuids.hrh"
       
    63 #include "MPFileDetailsDialog.h"
       
    64 #include <mpxvideoplaybackdefs.h>
       
    65 #include "mpxmediavideodefs.h"
       
    66 #include "mpxvideo_debug.h"
       
    67 
       
    68 //  Member Functions
       
    69 
       
    70 // -------------------------------------------------------------------------------------------------
       
    71 // CMPXVideoBasePlaybackView::CMPXVideoBasePlaybackView()
       
    72 // -------------------------------------------------------------------------------------------------
       
    73 //
       
    74 CMPXVideoBasePlaybackView::CMPXVideoBasePlaybackView()
       
    75 // note, CBase initialises all member variables to zero
       
    76 {
       
    77 }
       
    78 
       
    79 // -------------------------------------------------------------------------------------------------
       
    80 //   CMPXVideoBasePlaybackView::InitializeVideoPlaybackViewL()
       
    81 // -------------------------------------------------------------------------------------------------
       
    82 //
       
    83 void CMPXVideoBasePlaybackView::InitializeVideoPlaybackViewL()
       
    84 {
       
    85     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::InitializeVideoPlaybackViewL()"));
       
    86 
       
    87     _LIT( KMPXVideoPlaybackViewsRscPath, "mpxvideoplaybackviews.rsc" );
       
    88 
       
    89     CCoeEnv* coeEnv = iEikonEnv;
       
    90     TParse parse;
       
    91     parse.Set( KMPXVideoPlaybackViewsRscPath, &KDC_APP_RESOURCE_DIR, NULL );
       
    92     TFileName resourceFile = parse.FullName();
       
    93     User::LeaveIfError( AddDllPath( resourceFile ) );
       
    94     BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile );
       
    95 
       
    96     iVideoResourceOffset = coeEnv->AddResourceFileL( resourceFile );
       
    97 
       
    98     //
       
    99     //  Get an instance of view utility
       
   100     //
       
   101     iViewUtility = MMPXViewUtility::UtilityL();
       
   102 
       
   103     //
       
   104     //  Get an instance of collection utility
       
   105     //
       
   106     iCollectionUtility = MMPXCollectionUtility::NewL( this );
       
   107 
       
   108     //
       
   109     //  Create Active Object for closing player
       
   110     //
       
   111     iCloseAO = CIdle::NewL( CActive::EPriorityStandard );
       
   112 
       
   113     BaseConstructL( R_MPX_VIDEO_PLAYBACK_VIEW );
       
   114 }
       
   115 
       
   116 // -------------------------------------------------------------------------------------------------
       
   117 // CMPXVideoBasePlaybackView::~CMPXVideoBasePlaybackView()
       
   118 // -------------------------------------------------------------------------------------------------
       
   119 //
       
   120 CMPXVideoBasePlaybackView::~CMPXVideoBasePlaybackView()
       
   121 {
       
   122     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::~CMPXVideoBasePlaybackView()"));
       
   123 
       
   124     if ( iClipName )
       
   125     {
       
   126         delete iClipName;
       
   127         iClipName = NULL;
       
   128     }
       
   129 
       
   130     if ( iCloseAO )
       
   131     {
       
   132         delete iCloseAO;
       
   133         iCloseAO = NULL;
       
   134     }
       
   135 
       
   136     if ( iDisplayHandler )
       
   137     {
       
   138         delete iDisplayHandler;
       
   139         iDisplayHandler = NULL;
       
   140     }
       
   141 
       
   142     if ( iFileDetails )
       
   143     {
       
   144         delete iFileDetails;
       
   145         iFileDetails = NULL;
       
   146     }
       
   147 
       
   148     if ( iPlaybackUtility )
       
   149     {
       
   150         TRAP_IGNORE( iPlaybackUtility->RemoveObserverL( *this ) );
       
   151         iPlaybackUtility->Close();
       
   152         iPlaybackUtility = NULL;
       
   153     }
       
   154 
       
   155     if ( iViewUtility )
       
   156     {
       
   157         iViewUtility->Close();
       
   158         iViewUtility = NULL;
       
   159     }
       
   160 
       
   161     if ( iCollectionUtility )
       
   162     {
       
   163         iCollectionUtility->Close();
       
   164     }
       
   165 
       
   166     if ( iVideoResourceOffset )
       
   167     {
       
   168         iEikonEnv->DeleteResourceFile( iVideoResourceOffset );
       
   169     }
       
   170 
       
   171     if ( iContainer )
       
   172     {
       
   173         AppUi()->RemoveFromStack( iContainer );
       
   174         delete iContainer;
       
   175         iContainer = NULL;
       
   176     }
       
   177 }
       
   178 
       
   179 // -------------------------------------------------------------------------------------------------
       
   180 //   CMPXVideoBasePlaybackView::CreateGeneralPlaybackCommandL()
       
   181 // -------------------------------------------------------------------------------------------------
       
   182 //
       
   183 void CMPXVideoBasePlaybackView::CreateGeneralPlaybackCommandL( TMPXPlaybackCommand aCmd )
       
   184 {
       
   185     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::CreateGeneralPlaybackCommandL(%d)"), aCmd );
       
   186 
       
   187     CMPXCommand* cmd = CMPXCommand::NewL();
       
   188     CleanupStack::PushL( cmd );
       
   189 
       
   190     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
   191     cmd->SetTObjectValueL<TBool>( KMPXCommandPlaybackGeneralNoBuffer, ETrue );
       
   192     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral );
       
   193     cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralType, aCmd );
       
   194 
       
   195     iPlaybackUtility->CommandL( *cmd );
       
   196 
       
   197     CleanupStack::PopAndDestroy( cmd );
       
   198 }
       
   199 
       
   200 // -------------------------------------------------------------------------------------------------
       
   201 //   CMPXVideoBasePlaybackView::HandleCommandL()
       
   202 // -------------------------------------------------------------------------------------------------
       
   203 //
       
   204 void CMPXVideoBasePlaybackView::HandleCommandL( TInt aCommand )
       
   205 {
       
   206     MPX_ENTER_EXIT(
       
   207         _L("CMPXVideoBasePlaybackView::HandleCommandL()"),
       
   208         _L("aCommand = %d"), aCommand );
       
   209 
       
   210     switch ( aCommand )
       
   211     {
       
   212         case EMPXPbvCmdPlay:
       
   213         {
       
   214             IssuePlayCommandL();
       
   215             break;
       
   216         }
       
   217         case EMPXPbvCmdPause:
       
   218         {
       
   219             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdPause"));
       
   220             CreateGeneralPlaybackCommandL( EPbCmdPause );
       
   221             break;
       
   222         }
       
   223         case EMPXPbvCmdClose:
       
   224         {
       
   225             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdClose"));
       
   226             CreateGeneralPlaybackCommandL( EPbCmdClose );
       
   227             break;
       
   228         }
       
   229         case EMPXPbvCmdSeekForward:
       
   230         {
       
   231             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdSeekForward"));
       
   232             CreateVideoSpecificCmdL( EPbCmdStartVideoSeekingForward );
       
   233             break;
       
   234         }
       
   235         case EMPXPbvCmdSeekBackward:
       
   236         {
       
   237             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdSeekBackward"));
       
   238             CreateVideoSpecificCmdL( EPbCmdStartVideoSeekingBackward );
       
   239             break;
       
   240         }
       
   241         case EMPXPbvCmdEndSeek:
       
   242         {
       
   243             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdEndSeek"));
       
   244             CreateVideoSpecificCmdL( EPbCmdStopVideoSeeking );
       
   245             break;
       
   246         }
       
   247         case EMPXPbvCmdPlayPause:
       
   248         {
       
   249             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdPause"));
       
   250             iPlaybackUtility->CommandL( EPbCmdPlayPause );
       
   251             break;
       
   252         }
       
   253         case EAknSoftkeyBack:
       
   254         {
       
   255             ClosePlaybackViewL();
       
   256             break;
       
   257         }
       
   258         case EMPXPbvCmdStop:
       
   259         {
       
   260             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdStop"));
       
   261             CreateGeneralPlaybackCommandL( EPbCmdStop );
       
   262             break;
       
   263         }
       
   264         case EMPXPbvCmdDecreaseVolume:
       
   265         {
       
   266             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdDecreaseVolume"));
       
   267             HandleVolumeCmdL( EPbCmdDecreaseVolume );
       
   268             break;
       
   269         }
       
   270         case EMPXPbvCmdIncreaseVolume:
       
   271         {
       
   272             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdIncreaseVolume"));
       
   273             HandleVolumeCmdL( EPbCmdIncreaseVolume );
       
   274             break;
       
   275         }
       
   276         case EMPXPbvCmdNaturalAspectRatio:
       
   277         {
       
   278             MPX_DEBUG(
       
   279                 _L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdNaturalAspectRatio"));
       
   280             SetAspectRatioL( EPbCmdNaturalAspectRatio );
       
   281             break;
       
   282         }
       
   283         case EMPXPbvCmdZoomAspectRatio:
       
   284         {
       
   285             MPX_DEBUG(
       
   286                 _L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdZoomAspectRatio"));
       
   287             SetAspectRatioL( EPbCmdZoomAspectRatio );
       
   288             break;
       
   289         }
       
   290         case EMPXPbvCmdStretchAspectRatio:
       
   291         {
       
   292             MPX_DEBUG(
       
   293                 _L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdStretchAspectRatio"));
       
   294             SetAspectRatioL( EPbCmdStretchAspectRatio );
       
   295             break;
       
   296         }
       
   297         case EMPXPbvCmdMute:
       
   298         {
       
   299             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdMute"));
       
   300             HandleVolumeCmdL( EPbCmdMuteVolume );
       
   301             break;
       
   302         }
       
   303         case EMPXPbvCmdUnMute:
       
   304         {
       
   305             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdUnMute"));
       
   306             HandleVolumeCmdL( EPbCmdUnMuteVolume );
       
   307             break;
       
   308         }
       
   309         case EMPXPbvCmdShortPressBackward:
       
   310         {
       
   311             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleCommandL() EMPXPbvCmdShortPressBackward"));
       
   312 
       
   313             HandleShortPressBackwardL();
       
   314             break;
       
   315         }
       
   316         case EAknCmdHelp:
       
   317         {
       
   318             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   319                                                  AppUi()->AppHelpContextL() );
       
   320             break;
       
   321         }
       
   322         case EMPXPbvCmdShowFileDetails:
       
   323         {
       
   324             if ( AknLayoutUtils::PenEnabled() )
       
   325             {
       
   326                 iContainer->HandleEventL(EMPXControlCmdShowFileDetailsViewer);
       
   327             }
       
   328             else
       
   329             {
       
   330                 ShowFileDetailsDialogL();
       
   331             }
       
   332             break;
       
   333         }
       
   334         case EMPXPbvCmdEndOfClip:
       
   335         {
       
   336             CreateVideoSpecificCmdL( EPbCmdEndofClipReached );
       
   337             break;
       
   338         }
       
   339         case EMPXPbvCmdCustomPause:
       
   340         {
       
   341             CreateVideoSpecificCmdL( EPbCmdCustomPause );
       
   342             break;
       
   343         }
       
   344         case EMPXPbvCmdCustomPlay:
       
   345         {
       
   346             CreateVideoSpecificCmdL( EPbCmdCustomPlay );
       
   347             break;
       
   348         }
       
   349         case EMPXPbvLaunchDRMDetails:
       
   350         {
       
   351             LaunchDRMDetailsL();
       
   352             break;
       
   353         }
       
   354 
       
   355     }
       
   356 }
       
   357 
       
   358 // -------------------------------------------------------------------------------------------------
       
   359 //   CMPXVideoBasePlaybackView::ProcessCommandL()
       
   360 // -------------------------------------------------------------------------------------------------
       
   361 //
       
   362 void CMPXVideoBasePlaybackView::ProcessCommandL( TInt aCommand )
       
   363 {
       
   364     MPX_ENTER_EXIT(
       
   365         _L("CMPXVideoBasePlaybackView::ProcessCommandL()"),
       
   366         _L("aCommand = %d"), aCommand );
       
   367 
       
   368     if ( aCommand == EAknCmdExit )
       
   369     {
       
   370         MPX_DEBUG(_L("CMPXVideoBasePlaybackView::ProcessCommandL() EAknCmdExit"));
       
   371 
       
   372         if ( MenuBar() )
       
   373         {
       
   374             MenuBar()->StopDisplayingMenuBar();
       
   375         }
       
   376     }
       
   377 
       
   378     CAknView::ProcessCommandL( aCommand );
       
   379 }
       
   380 
       
   381 // -------------------------------------------------------------------------------------------------
       
   382 //   CMPXVideoBasePlaybackView::HandleStatusPaneSizeChange()
       
   383 // -------------------------------------------------------------------------------------------------
       
   384 //
       
   385 void CMPXVideoBasePlaybackView::HandleStatusPaneSizeChange()
       
   386 {
       
   387     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleStatusPaneSizeChange()"));
       
   388 }
       
   389 
       
   390 // -------------------------------------------------------------------------------------------------
       
   391 //   CMPXVideoBasePlaybackView::DoActivateL()
       
   392 // -------------------------------------------------------------------------------------------------
       
   393 //
       
   394 void CMPXVideoBasePlaybackView::DoActivateL( const TVwsViewId& /* aPrevViewId */,
       
   395                                              TUid /* aCustomMessageId */,
       
   396                                              const TDesC8& /* aCustomMessage */ )
       
   397 {
       
   398     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::DoActivateL()"));
       
   399 
       
   400     //
       
   401     //  Get the playback utility instance from playback utility
       
   402     //
       
   403     iPlaybackUtility = MMPXPlaybackUtility::UtilityL( EMPXCategoryVideo, KPbModeDefault );
       
   404     iPlaybackUtility->AddObserverL( *this );
       
   405 
       
   406     //
       
   407     //  Initialize the playback state
       
   408     //
       
   409     iPlaybackState = iPlaybackUtility->StateL();
       
   410 
       
   411     //
       
   412     //  Observe the View Framework when the view is active
       
   413     //
       
   414     iViewUtility->AddObserverL( this );
       
   415 
       
   416     //
       
   417     //  Create Video Playback Display Handler
       
   418     //
       
   419     iDisplayHandler = CMPXVideoPlaybackDisplayHandler::NewL( iPlaybackUtility );
       
   420 
       
   421     //
       
   422     //  Disable tool bar in playback view
       
   423     //
       
   424     AppUi()->CurrentFixedToolbar()->SetToolbarVisibility( EFalse );
       
   425 
       
   426     if ( ! iContainer )
       
   427     {
       
   428         AppUi()->SetOrientationL( CAknAppUiBase::EAppUiOrientationLandscape );
       
   429 
       
   430         iContainer = CMPXVideoPlaybackContainer::NewL( this );
       
   431 
       
   432         AppUi()->AddToStackL( *this, iContainer );
       
   433 
       
   434         iContainer->GetWindow().SetVisible( ETrue );
       
   435     }
       
   436 
       
   437     // Deactivate the CBA set the LSK&RSK to empty
       
   438     Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY);
       
   439 
       
   440     //
       
   441     //  Determine if the playback is from a playlist on view activation
       
   442     //
       
   443     MMPXSource* s = iPlaybackUtility->Source();
       
   444     CMPXCollectionPlaylist* playlist = s->PlaylistL();
       
   445     iPlaylistView = (playlist) ? ETrue : EFalse;
       
   446     delete playlist;
       
   447 
       
   448     //
       
   449     //  Retrieve PDL information for container
       
   450     //
       
   451     RetrievePdlInformationL();
       
   452 
       
   453     //
       
   454     //  Request the needed Media from the Playback Plugin
       
   455     //
       
   456     RequestMediaL();
       
   457 }
       
   458 
       
   459 // -------------------------------------------------------------------------------------------------
       
   460 // From CAknView
       
   461 // View deactivation function.
       
   462 // -------------------------------------------------------------------------------------------------
       
   463 //
       
   464 void CMPXVideoBasePlaybackView::DoDeactivate()
       
   465 {
       
   466     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::DoDeactivate()"));
       
   467 
       
   468     //
       
   469     //  Close the playback plugin to release all references to previous clip
       
   470     //
       
   471     MPX_TRAPD( err, HandleCommandL( EMPXPbvCmdClose ) );
       
   472 
       
   473     //
       
   474     //  Delete the display handler when the view is deactivated
       
   475     //
       
   476     iDisplayHandler->RemoveDisplayWindow();
       
   477 
       
   478     delete iDisplayHandler;
       
   479     iDisplayHandler = NULL;
       
   480 
       
   481     if ( iPlaybackUtility )
       
   482     {
       
   483         TRAP_IGNORE( iPlaybackUtility->RemoveObserverL( *this ) );
       
   484         iPlaybackUtility->Close();
       
   485         iPlaybackUtility = NULL;
       
   486     }
       
   487 
       
   488     //
       
   489     //  Stop observing the view framework when this view is deactivated
       
   490     //
       
   491     iViewUtility->RemoveObserver( this );
       
   492 
       
   493     if ( iContainer )
       
   494     {
       
   495         iContainer->GetWindow().SetVisible( EFalse );
       
   496         AppUi()->RemoveFromStack( iContainer );
       
   497         delete iContainer;
       
   498         iContainer = NULL;
       
   499     }
       
   500 
       
   501     iMediaRequested = EFalse;
       
   502     iPlaybackState = EPbStateNotInitialised;
       
   503 
       
   504     if ( iClipName )
       
   505     {
       
   506         delete iClipName;
       
   507         iClipName = NULL;
       
   508     }
       
   509 }
       
   510 
       
   511 // -------------------------------------------------------------------------------------------------
       
   512 // From CAknView
       
   513 // Foreground event handling function.
       
   514 // -------------------------------------------------------------------------------------------------
       
   515 //
       
   516 void CMPXVideoBasePlaybackView::HandleForegroundEventL( TBool aForeground )
       
   517 {
       
   518     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleForegroundEventL()"),
       
   519                    _L("aForeground = %d"), aForeground );
       
   520 
       
   521     TMPXVideoPlaybackCommand videoCmd = EPbCmdHandleBackground;
       
   522 
       
   523     if ( aForeground )
       
   524     {
       
   525         videoCmd = EPbCmdHandleForeground;
       
   526         iContainer->HandleEventL(EMPXControlCmdHandleForegroundEvent);
       
   527     }
       
   528     else
       
   529     {
       
   530         iContainer->HandleEventL(EMPXControlCmdHandleBackgroundEvent);
       
   531     }
       
   532 
       
   533     //
       
   534     //  create command to pass to playback plugin
       
   535     //
       
   536     CMPXCommand* cmd = CMPXCommand::NewL();
       
   537     CleanupStack::PushL( cmd );
       
   538 
       
   539     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
   540     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
   541     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand, videoCmd );
       
   542     cmd->SetTObjectValueL<TBool>( KMPXMediaVideoAppForeground, IsAppInFrontL() );
       
   543 
       
   544     iPlaybackUtility->CommandL( *cmd );
       
   545     CleanupStack::PopAndDestroy( cmd );
       
   546 
       
   547     CAknView::HandleForegroundEventL( aForeground );
       
   548 }
       
   549 
       
   550 // -------------------------------------------------------------------------------------------------
       
   551 // From MEikMenuObserver
       
   552 // Dynamically initialises a menu pane.
       
   553 // -------------------------------------------------------------------------------------------------
       
   554 //
       
   555 void CMPXVideoBasePlaybackView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   556 {
       
   557     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::DynInitMenuPaneL()"));
       
   558 
       
   559     if ( aResourceId == R_MPX_VIDEO_PLAYBACK_VIEW_MENU  )
       
   560     {
       
   561         //
       
   562         //  Make EMPXPbvCmdChangeAspectRatio menu dimmed in the followings cases:
       
   563         //  -  support touch
       
   564         //  -  a mmf controller is not prepared
       
   565         //  -  clip doesn't have a video track
       
   566         //  -  TV-out cable gets connected
       
   567         //
       
   568         if ( AknLayoutUtils::PenEnabled() ||
       
   569              ! iFileDetails ||
       
   570              ! iFileDetails->iVideoEnabled ||
       
   571              iFileDetails->iVideoHeight <= 0 ||
       
   572              iFileDetails->iVideoWidth <= 0 )
       
   573         {
       
   574             aMenuPane->SetItemDimmed( EMPXPbvCmdChangeAspectRatio, ETrue );
       
   575         }
       
   576     }
       
   577 }
       
   578 
       
   579 void CMPXVideoBasePlaybackView::HandleViewActivation( const TUid& aCurrentViewType,
       
   580                                                       const TUid& aPreviousViewType )
       
   581 {
       
   582     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleViewActivation()"),
       
   583                    _L("aCurrentViewType = 0x%08x, aPreviousViewType = 0x%08x"),
       
   584                    aCurrentViewType.iUid, aPreviousViewType.iUid );
       
   585 
       
   586     //
       
   587     //  This view is active since we are receiving the callback.
       
   588     //  Some new view is being activated so stop playback and return to automatic orientation
       
   589     //
       
   590     HandleCommandL( EMPXPbvCmdStop );
       
   591     AppUi()->SetOrientationL( CAknAppUiBase::EAppUiOrientationAutomatic );
       
   592 }
       
   593 
       
   594 // -------------------------------------------------------------------------------------------------
       
   595 // From MMPXPlaybackObserver
       
   596 // Handle playback message.
       
   597 // -------------------------------------------------------------------------------------------------
       
   598 //
       
   599 void CMPXVideoBasePlaybackView::HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError )
       
   600 {
       
   601     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandlePlaybackMessage()"),
       
   602                    _L("aError = %d"), aError );
       
   603 
       
   604     if ( aError )
       
   605     {
       
   606         MPX_TRAPD( err, DoHandleErrorPlaybackMessageL( aError ) );
       
   607     }
       
   608     else if ( aMessage )
       
   609     {
       
   610         MPX_TRAPD( err, DoHandlePlaybackMessageL( aMessage ) );
       
   611     }
       
   612 }
       
   613 
       
   614 // -------------------------------------------------------------------------------------------------
       
   615 // Request for the media object
       
   616 // -------------------------------------------------------------------------------------------------
       
   617 //
       
   618 void CMPXVideoBasePlaybackView::RequestMediaL()
       
   619 {
       
   620     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::RequestMediaL()"));
       
   621 
       
   622     if ( ! iMediaRequested && iPlaybackState == EPbStateInitialised )
       
   623     {
       
   624         iMediaRequested = ETrue;
       
   625 
       
   626         if ( iPlaylistView )
       
   627         {
       
   628             // Get the media attributes from the collection plugin
       
   629             RequestCollectionMediaL();
       
   630         }
       
   631         else
       
   632         {
       
   633             // Get the file details from playback plugin
       
   634             RequestPlaybackMediaL();
       
   635         }
       
   636     }
       
   637 }
       
   638 
       
   639 // -------------------------------------------------------------------------------------------------
       
   640 // Request for the media object
       
   641 // -------------------------------------------------------------------------------------------------
       
   642 //
       
   643 void CMPXVideoBasePlaybackView::RequestPlaybackMediaL()
       
   644 {
       
   645     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::RequestPlaybackMediaL()"));
       
   646 
       
   647     //
       
   648     //  Request the volume for the controls
       
   649     //
       
   650     iPlaybackUtility->PropertyL( *this, EPbPropertyVolume );
       
   651 
       
   652     //
       
   653     //  Request the clip's meta data
       
   654     //
       
   655     MMPXSource* s = iPlaybackUtility->Source();
       
   656 
       
   657     if ( s )
       
   658     {
       
   659         RArray<TMPXAttribute> attrs;
       
   660         CleanupClosePushL(attrs);
       
   661 
       
   662         //
       
   663         //  General Media Attributes
       
   664         //
       
   665         attrs.Append( KMPXMediaGeneralUri |
       
   666                       KMPXMediaGeneralDuration |
       
   667                       KMPXMediaGeneralTitle |
       
   668                       KMPXMediaGeneralMimeType );
       
   669 
       
   670         //
       
   671         //  Video specific Attributes
       
   672         //
       
   673         attrs.Append( KMPXMediaVideoAll );
       
   674 
       
   675         // Set the attribute to always route the media call to playback plugin
       
   676         CMPXAttributeSpecs* specs = CMPXAttributeSpecs::NewL();
       
   677         CleanupStack::PushL( specs );
       
   678 
       
   679         specs->SetTObjectValueL<TBool>(KMPXMediaGeneralExtMediaRedirect, ETrue);
       
   680 
       
   681         s->MediaL( attrs.Array(), *this, specs);
       
   682 
       
   683         CleanupStack::PopAndDestroy( specs );
       
   684         CleanupStack::PopAndDestroy( &attrs );
       
   685     }
       
   686 }
       
   687 
       
   688 // -------------------------------------------------------------------------------------------------
       
   689 // Request for the media object
       
   690 // -------------------------------------------------------------------------------------------------
       
   691 //
       
   692 void CMPXVideoBasePlaybackView::RequestCollectionMediaL()
       
   693 {
       
   694     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::RequestCollectionMediaL()"));
       
   695 
       
   696     //  Request the clip's meta data
       
   697     MMPXSource* s = iPlaybackUtility->Source();
       
   698 
       
   699     if ( s )
       
   700     {
       
   701         RArray<TMPXAttribute> attrs;
       
   702         CleanupClosePushL(attrs);
       
   703 
       
   704         //  General Media Attributes
       
   705         attrs.Append( KMPXMediaGeneralUri );
       
   706         attrs.Append( KMPXMediaGeneralExtAccessPoint );
       
   707         attrs.Append( KMPXMediaGeneralExtVideoSeekable );
       
   708 
       
   709         s->MediaL( attrs.Array(), *this);
       
   710 
       
   711         // Set the falg to indicate that media was reuqested from collection FW
       
   712         iCollectionMediaRequested = ETrue;
       
   713 
       
   714         CleanupStack::PopAndDestroy( &attrs );
       
   715     }
       
   716 }
       
   717 
       
   718 // -------------------------------------------------------------------------------------------------
       
   719 //   CMPXVideoBasePlaybackView::DoHandlePlaybackMessageL()
       
   720 // -------------------------------------------------------------------------------------------------
       
   721 //
       
   722 void CMPXVideoBasePlaybackView::DoHandlePlaybackMessageL( CMPXMessage* aMessage )
       
   723 {
       
   724     TMPXMessageId id( *(aMessage->Value<TMPXMessageId>(KMPXMessageGeneralId)) );
       
   725 
       
   726     MPX_ENTER_EXIT(
       
   727         _L("CMPXVideoBasePlaybackView::DoHandlePlaybackMessageL()"),
       
   728         _L("id = 0x%08x"), id );
       
   729 
       
   730     if ( KMPXMessageGeneral == id )
       
   731     {
       
   732         HandleGeneralPlaybackMessageL( aMessage );
       
   733     }
       
   734     else if ( KMPXMediaIdVideoPlayback == id )
       
   735     {
       
   736         HandleVideoPlaybackMessage( aMessage );
       
   737     }
       
   738     else if ( KMPXMediaIdVideoDisplayMessage == id )
       
   739     {
       
   740         if ( iDisplayHandler )
       
   741         {
       
   742             TMPXVideoDisplayCommand cmdId = iDisplayHandler->HandleVideoDisplayMessageL( aMessage );
       
   743 
       
   744             if ( cmdId == EPbMsgVideoSurfaceCreated )
       
   745 			{
       
   746                 //
       
   747             	//  Notify container that surface has been created to make window transparent
       
   748             	//
       
   749                 if ( iContainer )
       
   750                 {
       
   751                     iContainer->HandleCommandL( EMPXPbvSurfaceCreated );
       
   752                 }
       
   753 			}
       
   754         }
       
   755     }
       
   756 }
       
   757 
       
   758 // -------------------------------------------------------------------------------------------------
       
   759 //   CMPXVideoBasePlaybackView::HandleGeneralPlaybackMessageL()
       
   760 // -------------------------------------------------------------------------------------------------
       
   761 //
       
   762 void CMPXVideoBasePlaybackView::HandleGeneralPlaybackMessageL( CMPXMessage* aMessage )
       
   763 {
       
   764     TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ) );
       
   765     TInt type( *aMessage->Value<TInt>( KMPXMessageGeneralType ) );
       
   766     TInt data( *aMessage->Value<TInt>( KMPXMessageGeneralData ) );
       
   767 
       
   768     MPX_DEBUG(
       
   769       _L("CMPXVideoBasePlaybackView::HandleGeneralPlaybackMessageL() event = %d type = %d  value = %d"),
       
   770       event, type, data );
       
   771 
       
   772     switch ( event )
       
   773     {
       
   774         case TMPXPlaybackMessage::EStateChanged:
       
   775         {
       
   776             DoHandleStateChangeL( type );
       
   777 
       
   778             break;
       
   779         }
       
   780         case TMPXPlaybackMessage::EPropertyChanged:
       
   781         {
       
   782             TMPXPlaybackProperty property(
       
   783                  static_cast<TMPXPlaybackProperty>( type ) );
       
   784 
       
   785             HandlePropertyL( property, data, KErrNone );
       
   786             break;
       
   787         }
       
   788         case TMPXPlaybackMessage::EDownloadPositionChanged:
       
   789         {
       
   790             if ( iContainer )
       
   791             {
       
   792                 iContainer->HandleEventL( EMPXControlCmdDownloadUpdated, data );
       
   793             }
       
   794 
       
   795             break;
       
   796         }
       
   797         case TMPXPlaybackMessage::EDownloadStateChanged:
       
   798         {
       
   799             HandlePdlStateChangeL( data );
       
   800 
       
   801             break;
       
   802         }
       
   803         case TMPXPlaybackMessage::ECommandReceived:
       
   804         {
       
   805             break;
       
   806         }
       
   807         case TMPXPlaybackMessage::EReachedEndOfPlaylist:
       
   808         {
       
   809             HandleCommandL( EAknSoftkeyBack );
       
   810             break;
       
   811         }
       
   812         case TMPXPlaybackMessage::ESongChanged:
       
   813         {
       
   814             break;
       
   815         }
       
   816     }
       
   817 }
       
   818 
       
   819 // -------------------------------------------------------------------------------------------------
       
   820 //   CMPXVideoBasePlaybackView::HandleVideoPlaybackMessage()
       
   821 // -------------------------------------------------------------------------------------------------
       
   822 //
       
   823 void CMPXVideoBasePlaybackView::HandleVideoPlaybackMessage( CMPXMessage* aMessage )
       
   824 {
       
   825     TMPXVideoPlaybackCommand message =
       
   826         ( *(aMessage->Value<TMPXVideoPlaybackCommand>(KMPXMediaVideoPlaybackCommand)) );
       
   827 
       
   828     MPX_DEBUG(
       
   829       _L("CMPXVideoBasePlaybackView::HandleVideoPlaybackMessage() message = %d"), message );
       
   830 
       
   831     switch ( message )
       
   832     {
       
   833         case EPbCmdPluginError:
       
   834         {
       
   835             TInt error( *aMessage->Value<TInt>( KMPXMediaVideoError ) );
       
   836 
       
   837             MPX_TRAPD( err, HandlePluginErrorL( error ) );
       
   838             break;
       
   839         }
       
   840         case EPbCmdTvOutEvent:
       
   841         {
       
   842             TMPXVideoPlaybackControlCommandIds cmdId = EMPXControlCmdTvOutDisconnected;
       
   843 
       
   844             TBool tvOutConnected( *aMessage->Value<TInt>( KMPXMediaVideoTvOutConnected ) );
       
   845             TBool playbackAllowed = ETrue;
       
   846 
       
   847             if ( tvOutConnected )
       
   848             {
       
   849                 cmdId = EMPXControlCmdTvOutConnected;
       
   850 
       
   851                 playbackAllowed = *aMessage->Value<TInt>( KMPXMediaVideoTvOutPlayAllowed );
       
   852             }
       
   853 
       
   854             if ( iContainer )
       
   855             {
       
   856                 MPX_TRAPD( err, iContainer->HandleEventL( cmdId, playbackAllowed ) );
       
   857             }
       
   858             break;
       
   859         }
       
   860     }
       
   861 }
       
   862 
       
   863 // -------------------------------------------------------------------------------------------------
       
   864 //   CMPXVideoBasePlaybackView::HandleClosePlaybackViewL()
       
   865 // -------------------------------------------------------------------------------------------------
       
   866 //
       
   867 void CMPXVideoBasePlaybackView::HandleClosePlaybackViewL()
       
   868 {
       
   869     MPX_DEBUG(
       
   870       _L("CMPXVideoBasePlaybackView::HandleClosePlaybackViewL()") );
       
   871 
       
   872     if ( IsMultiItemPlaylist() )
       
   873     {
       
   874         iPlaybackUtility->CommandL( EPbCmdNext );
       
   875     }
       
   876     else
       
   877     {
       
   878         ClosePlaybackViewL();
       
   879     }
       
   880 }
       
   881 
       
   882 // -------------------------------------------------------------------------------------------------
       
   883 //   CMPXVideoBasePlaybackView::HandlePluginErrorL()
       
   884 // -------------------------------------------------------------------------------------------------
       
   885 //
       
   886 void CMPXVideoBasePlaybackView::HandlePluginErrorL( TInt aError )
       
   887 {
       
   888     MPX_DEBUG(
       
   889       _L("CMPXVideoBasePlaybackView::HandlePluginErrorL() aError = %d"), aError );
       
   890 
       
   891     switch ( aError )
       
   892     {
       
   893         case KErrPathNotFound:
       
   894         case KErrNotFound:
       
   895         {
       
   896             DisplayErrorMessageL( R_MPX_CLIP_NOT_FOUND_IN_SERVER );
       
   897             HandleClosePlaybackViewL();
       
   898             break;
       
   899         }
       
   900         case KErrCancel:
       
   901         {
       
   902             HandleClosePlaybackViewL();
       
   903             break;
       
   904         }
       
   905         case KErrMMDRMNotAuthorized:
       
   906         case KErrCANoRights:
       
   907         case KErrCANoPermission:
       
   908         case KErrCAPendingRights:
       
   909         {
       
   910             HandleDrmErrorsL( aError );
       
   911             break;
       
   912         }
       
   913         case KMPXVideoCallOngoingError:
       
   914         {
       
   915             DisplayInfoMessageL( R_MPX_VIDEO_CALL_ONGOING );
       
   916             break;
       
   917         }
       
   918         case KMPXVideoTvOutPlaybackNotAllowed:
       
   919         {
       
   920             DisplayInfoMessageL( R_MPX_VIDEO_DRM_NO_TV_OUT );
       
   921             break;
       
   922         }
       
   923         case KMPXVideoTvOutPlaybackNotAllowedClose:
       
   924         {
       
   925             DisplayErrorMessageL( R_MPX_VIDEO_DRM_NO_TV_OUT );
       
   926             HandleClosePlaybackViewL();
       
   927             break;
       
   928         }
       
   929         default:
       
   930         {
       
   931             //
       
   932             //  TextResolver instance for error resolving.
       
   933             //
       
   934             CTextResolver* textresolver = CTextResolver::NewLC();
       
   935 
       
   936             //
       
   937             //  Resolve the error text
       
   938             //
       
   939             TPtrC text;
       
   940             text.Set( textresolver->ResolveErrorString( aError ) );
       
   941 
       
   942             CAknErrorNote* dlg = new (ELeave) CAknErrorNote( ETrue );
       
   943 
       
   944             dlg->ExecuteLD( text );
       
   945 
       
   946             CleanupStack::PopAndDestroy( textresolver );
       
   947 
       
   948             HandleClosePlaybackViewL();
       
   949         }
       
   950     }
       
   951 }
       
   952 
       
   953 // -------------------------------------------------------------------------------------------------
       
   954 //   Handle playback state changes
       
   955 // -------------------------------------------------------------------------------------------------
       
   956 //
       
   957 void CMPXVideoBasePlaybackView::DoHandleStateChangeL( TInt aNewState )
       
   958 {
       
   959     MPX_ENTER_EXIT(
       
   960         _L("CMPXVideoBasePlaybackView::DoHandleStateChangeL()"),
       
   961         _L("aNewState = %d, currentState = %d"), aNewState, iPlaybackState );
       
   962 
       
   963     if ( aNewState != iPlaybackState )
       
   964     {
       
   965         TBool stateChange( ETrue );
       
   966 
       
   967         TMPXPlaybackState oldState = iPlaybackState;
       
   968         iPlaybackState = (TMPXPlaybackState)aNewState;
       
   969 
       
   970         switch ( aNewState )
       
   971         {
       
   972             case EPbStateInitialising:
       
   973             {
       
   974                 //
       
   975                 //  Get playlist information
       
   976                 //  Source if available once the plugin is initializing
       
   977                 //
       
   978                 if ( iContainer )
       
   979                 {
       
   980                     //
       
   981                     //  If transitioning from Not Initialized to Initialising there is
       
   982                     //  no need to update the playback information that was gathered
       
   983                     //  when the container was created
       
   984                     //
       
   985                     if ( oldState != EPbStateNotInitialised )
       
   986                     {
       
   987                         iMediaRequested = EFalse;
       
   988                         iContainer->HandleCommandL( EMPXPbvCmdResetControls );
       
   989 
       
   990                         if ( iFileDetails )
       
   991                         {
       
   992                             if ( iFileDetailsDialog )
       
   993                             {
       
   994                                 iFileDetailsDialog->Close();
       
   995                             }
       
   996 
       
   997                             iFileDetails->ClearFileDetails();
       
   998                         }
       
   999                     }
       
  1000                 }
       
  1001                 break;
       
  1002             }
       
  1003             case EPbStateBuffering:
       
  1004             {
       
  1005                 TInt bufferingPercentage( 0 );
       
  1006 
       
  1007                 //
       
  1008                 //  If buffering percentage is 100, buffering is a transition state anc
       
  1009                 //  can be ignored
       
  1010                 //
       
  1011                 MPX_TRAPD( err, bufferingPercentage = RetrieveBufferingPercentageL() );
       
  1012 
       
  1013                 if ( bufferingPercentage == 100 )
       
  1014                 {
       
  1015                     stateChange = EFalse;
       
  1016                 }
       
  1017                 else
       
  1018                 {
       
  1019                     HandleBufferingStateL();
       
  1020                 }
       
  1021 
       
  1022                 break;
       
  1023             }
       
  1024             case EPbStatePluginSeeking:
       
  1025             {
       
  1026                 // no-op
       
  1027                 break;
       
  1028             }
       
  1029             case EPbStateStopped:
       
  1030             {
       
  1031                 HandleStoppedStateL();
       
  1032                 break;
       
  1033             }
       
  1034             case EPbStateInitialised:
       
  1035             {
       
  1036                 RequestMediaL();
       
  1037                 break;
       
  1038             }
       
  1039             default:
       
  1040             {
       
  1041                 break;
       
  1042             }
       
  1043         }
       
  1044 
       
  1045         if ( iContainer && stateChange )
       
  1046         {
       
  1047             iContainer->HandleEventL( EMPXControlCmdStateChanged, aNewState );
       
  1048         }
       
  1049     }
       
  1050 }
       
  1051 
       
  1052 
       
  1053 // -------------------------------------------------------------------------------------------------
       
  1054 // Handle playback error message.
       
  1055 // -------------------------------------------------------------------------------------------------
       
  1056 //
       
  1057 void CMPXVideoBasePlaybackView::DoHandleErrorPlaybackMessageL( TInt aError )
       
  1058 {
       
  1059     MPX_ENTER_EXIT( _L("CMPXVideoBasePlaybackView::DoHandleErrorPlaybackMessageL()"),
       
  1060                     _L("aError = %d"), aError );
       
  1061 
       
  1062     iContainer->HandleCommandL( EMPXPbvCmdResetControls );
       
  1063     HandlePluginErrorL(aError);
       
  1064 }
       
  1065 
       
  1066 // -------------------------------------------------------------------------------------------------
       
  1067 // CMPXVideoBasePlaybackView::HandlePlaybackCommandComplete()
       
  1068 // -------------------------------------------------------------------------------------------------
       
  1069 //
       
  1070 void CMPXVideoBasePlaybackView::HandlePlaybackCommandComplete( CMPXCommand* /*aCommandResult*/,
       
  1071                                                                TInt /*aError*/ )
       
  1072 {
       
  1073     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandlePlaybackCommandComplete()"));
       
  1074 }
       
  1075 
       
  1076 
       
  1077 // -------------------------------------------------------------------------------------------------
       
  1078 // CMPXVideoBasePlaybackView::ParseMetaDataL()
       
  1079 // -------------------------------------------------------------------------------------------------
       
  1080 //
       
  1081 void CMPXVideoBasePlaybackView::ParseMetaDataL( const CMPXMessage& aMedia )
       
  1082 {
       
  1083     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::ParseMetaDataL()"));
       
  1084 
       
  1085     //
       
  1086     //  Clip Name
       
  1087     //
       
  1088     if ( aMedia.IsSupported( KMPXMediaGeneralUri ) )
       
  1089     {
       
  1090         TPtrC uri( aMedia.ValueText( KMPXMediaGeneralUri ) );
       
  1091         iFileDetails->iClipName = uri.AllocL();
       
  1092     }
       
  1093 
       
  1094     //
       
  1095     //  Title
       
  1096     //
       
  1097     if ( aMedia.IsSupported( KMPXMediaGeneralTitle ) )
       
  1098     {
       
  1099         TPtrC title( aMedia.ValueText( KMPXMediaGeneralTitle ) );
       
  1100         iFileDetails->iTitle = title.AllocL();
       
  1101     }
       
  1102 
       
  1103     //
       
  1104     //  Artist
       
  1105     //
       
  1106     if ( aMedia.IsSupported( KMPXMediaVideoArtist ) )
       
  1107     {
       
  1108         TPtrC artist( aMedia.ValueText( KMPXMediaVideoArtist ) );
       
  1109         iFileDetails->iArtist = artist.AllocL();
       
  1110     }
       
  1111 
       
  1112     //
       
  1113     //  Mime Type
       
  1114     //
       
  1115     if ( aMedia.IsSupported( KMPXMediaGeneralMimeType ) )
       
  1116     {
       
  1117         TPtrC mimeType( aMedia.ValueText( KMPXMediaGeneralMimeType ) );
       
  1118         iFileDetails->iMimeType = mimeType.AllocL();
       
  1119     }
       
  1120 
       
  1121     //
       
  1122     //  Duration
       
  1123     //
       
  1124     if ( aMedia.IsSupported( KMPXMediaGeneralDuration ) )
       
  1125     {
       
  1126         iFileDetails->iDuration = aMedia.ValueTObjectL<TInt>( KMPXMediaGeneralDuration );
       
  1127     }
       
  1128 
       
  1129     //
       
  1130     //  Audio Enabled
       
  1131     //
       
  1132     if ( aMedia.IsSupported( KMPXMediaVideoAudioEnabled ) )
       
  1133     {
       
  1134         iFileDetails->iAudioEnabled = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoAudioEnabled );
       
  1135     }
       
  1136 
       
  1137     //
       
  1138     //  Video Enabled
       
  1139     //
       
  1140     if ( aMedia.IsSupported( KMPXMediaVideoVideoEnabled ) )
       
  1141     {
       
  1142         iFileDetails->iVideoEnabled = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoVideoEnabled );
       
  1143     }
       
  1144 
       
  1145     //
       
  1146     //  Partial Playback
       
  1147     //
       
  1148     if ( aMedia.IsSupported( KMPXMediaVideoPartialPlayback ) )
       
  1149     {
       
  1150         iFileDetails->iPartialPlayback =
       
  1151             aMedia.ValueTObjectL<TInt>( KMPXMediaVideoPartialPlayback );
       
  1152     }
       
  1153 
       
  1154     //
       
  1155     //  Playback Mode
       
  1156     //
       
  1157     if ( aMedia.IsSupported( KMPXMediaVideoPlaybackMode ) )
       
  1158     {
       
  1159         iFileDetails->iPlaybackMode =
       
  1160             (TMPXVideoMode)aMedia.ValueTObjectL<TInt>( KMPXMediaVideoPlaybackMode );
       
  1161     }
       
  1162 
       
  1163     //
       
  1164     //  Seekable
       
  1165     //
       
  1166     if ( aMedia.IsSupported( KMPXMediaVideoSeekable ) )
       
  1167     {
       
  1168         iFileDetails->iSeekable = aMedia.ValueTObjectL<TBool>( KMPXMediaVideoSeekable );
       
  1169     }
       
  1170 
       
  1171     //
       
  1172     //  Pausable
       
  1173     //
       
  1174     if ( aMedia.IsSupported( KMPXMediaVideoPausableStream ) )
       
  1175     {
       
  1176         iFileDetails->iPausableStream = aMedia.ValueTObjectL<TBool>( KMPXMediaVideoPausableStream );
       
  1177     }
       
  1178 
       
  1179     //
       
  1180     //  Video Height
       
  1181     //
       
  1182     if ( aMedia.IsSupported( KMPXMediaVideoHeight ) )
       
  1183     {
       
  1184         iFileDetails->iVideoHeight = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoHeight );
       
  1185     }
       
  1186 
       
  1187     //
       
  1188     //  Video Width
       
  1189     //
       
  1190     if ( aMedia.IsSupported( KMPXMediaVideoWidth ) )
       
  1191     {
       
  1192         iFileDetails->iVideoWidth = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoWidth );
       
  1193     }
       
  1194 
       
  1195     //
       
  1196     //  TV-Out Connected
       
  1197     //
       
  1198     if ( aMedia.IsSupported( KMPXMediaVideoTvOutConnected ) )
       
  1199     {
       
  1200         iFileDetails->iTvOutConnected = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoTvOutConnected );
       
  1201     }
       
  1202 
       
  1203     //
       
  1204     //  TV-Out Playback Allowed
       
  1205     //
       
  1206     if ( aMedia.IsSupported( KMPXMediaVideoTvOutPlayAllowed ) )
       
  1207     {
       
  1208         iFileDetails->iTvOutPlayAllowed =
       
  1209             aMedia.ValueTObjectL<TInt>( KMPXMediaVideoTvOutPlayAllowed );
       
  1210     }
       
  1211 
       
  1212     //
       
  1213     //  Video BitRate
       
  1214     //
       
  1215     if ( aMedia.IsSupported( KMPXMediaVideoBitRate ) )
       
  1216     {
       
  1217         iFileDetails->iBitRate = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoBitRate );
       
  1218     }
       
  1219 
       
  1220     //
       
  1221     //  ForCC Code
       
  1222     //
       
  1223     if ( aMedia.IsSupported( KMPXMediaFourCCCode ) )
       
  1224     {
       
  1225         iFileDetails->iFourCCCode = aMedia.ValueTObjectL<TUint32>( KMPXMediaFourCCCode );
       
  1226     }
       
  1227 
       
  1228     //
       
  1229     //  Drm Protected
       
  1230     //
       
  1231     if ( aMedia.IsSupported( KMPXMediaVideoDrmProtected ) )
       
  1232     {
       
  1233         iFileDetails->iDrmProtected = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoDrmProtected );
       
  1234     }
       
  1235 }
       
  1236 
       
  1237 // -------------------------------------------------------------------------------------------------
       
  1238 // Handle media properties.
       
  1239 // Notes: The client is responsible for delete the object of aProperties.
       
  1240 // -------------------------------------------------------------------------------------------------
       
  1241 //
       
  1242 void CMPXVideoBasePlaybackView::DoHandleMediaL( const CMPXMessage& aMedia, TInt aError )
       
  1243 {
       
  1244     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::DoHandleMediaL()"),
       
  1245                    _L("aError = %d"), aError );
       
  1246 
       
  1247     if ( aError == KErrNone )
       
  1248     {
       
  1249         if ( iFileDetails )
       
  1250         {
       
  1251             iFileDetails->ClearFileDetails();
       
  1252         }
       
  1253         else
       
  1254         {
       
  1255             iFileDetails = CMPXVideoPlaybackViewFileDetails::NewL();
       
  1256         }
       
  1257 
       
  1258         //
       
  1259         //  Read in the media data
       
  1260         //
       
  1261         ParseMetaDataL( aMedia );
       
  1262 
       
  1263         //
       
  1264         //  Create controls since file details are available
       
  1265         //
       
  1266         iContainer->AddFileDetailsL( iFileDetails );
       
  1267 
       
  1268         if ( iFileDetails->iVideoEnabled )
       
  1269         {
       
  1270             TRect displayRect = iContainer->Rect();
       
  1271 
       
  1272             TReal displayAspectRatio = (TReal32)displayRect.Width() / (TReal32)displayRect.Height();
       
  1273 
       
  1274             TInt newAspectRatio = iDisplayHandler->SetDefaultAspectRatioL( iFileDetails,
       
  1275                                                                            displayAspectRatio );
       
  1276 
       
  1277             //
       
  1278             //  Setup the display window and issue play command
       
  1279             //
       
  1280             iDisplayHandler->CreateDisplayWindowL( *(CCoeEnv::Static()->ScreenDevice()),
       
  1281                                                    iContainer->GetWindow() );
       
  1282 
       
  1283             iContainer->HandleEventL( EMPXControlCmdSetAspectRatio, newAspectRatio );
       
  1284         }
       
  1285 
       
  1286         CreateGeneralPlaybackCommandL( EPbCmdPlay );
       
  1287     }
       
  1288 }
       
  1289 
       
  1290 // -------------------------------------------------------------------------------------------------
       
  1291 //   CMPXVideoBasePlaybackView::UpdatePbPluginMedia()
       
  1292 // -------------------------------------------------------------------------------------------------
       
  1293 //
       
  1294 void CMPXVideoBasePlaybackView::UpdatePbPluginMediaL( TBool aSeek)
       
  1295 {
       
  1296     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::UpdatePbPluginMediaL() iSeekable %d"), aSeek);
       
  1297 
       
  1298     CMPXCommand* cmd = CMPXCommand::NewL();
       
  1299     CleanupStack::PushL( cmd );
       
  1300 
       
  1301     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1302 
       
  1303     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  1304 
       
  1305     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand, EPbCmdUpdateSeekable );
       
  1306 
       
  1307     cmd->SetTObjectValueL<TBool>( KMPXMediaGeneralExtVideoSeekable, aSeek );
       
  1308 
       
  1309     iPlaybackUtility->CommandL( *cmd );
       
  1310 
       
  1311     CleanupStack::PopAndDestroy( cmd );
       
  1312 }
       
  1313 
       
  1314 // -------------------------------------------------------------------------------------------------
       
  1315 // From MMPXPlaybackCallback
       
  1316 // Handle media event.
       
  1317 // Notes: The client is responsible for delete the object of aProperties.
       
  1318 // -------------------------------------------------------------------------------------------------
       
  1319 //
       
  1320 void CMPXVideoBasePlaybackView::HandleMediaL( const CMPXMedia& aMedia, TInt aError)
       
  1321 {
       
  1322     MPX_ENTER_EXIT(_L( "CMPXVideoBasePlaybackView::HandleMediaL()" ));
       
  1323 
       
  1324     if ( iCollectionMediaRequested )
       
  1325     {
       
  1326         TBool seek;
       
  1327         iCollectionMediaRequested = EFalse;
       
  1328 
       
  1329         if ( aMedia.IsSupported( KMPXMediaGeneralExtVideoSeekable ) )
       
  1330         {
       
  1331             seek = aMedia.ValueTObjectL<TBool>( KMPXMediaGeneralExtVideoSeekable );
       
  1332             UpdatePbPluginMediaL( seek );
       
  1333             MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleMediaL() called UpdatePbPluginMediaL iSeekable %d"), seek);
       
  1334         }
       
  1335 
       
  1336         if ( aMedia.IsSupported( KMPXMediaGeneralUri ) )
       
  1337         {
       
  1338             TPtrC uri( aMedia.ValueText( KMPXMediaGeneralUri ) );
       
  1339 
       
  1340             if ( iClipName )
       
  1341             {
       
  1342                 delete iClipName;
       
  1343                 iClipName = NULL;
       
  1344             }
       
  1345 
       
  1346             iClipName = uri.AllocL();
       
  1347         }
       
  1348 
       
  1349         // request for media from playbackplugin
       
  1350         RequestPlaybackMediaL();
       
  1351     }
       
  1352     else
       
  1353     {
       
  1354         if ( aMedia.IsSupported( KMPXMediaVideoError ) )
       
  1355         {
       
  1356             TInt error = aMedia.ValueTObjectL<TInt>( KMPXMediaVideoError );
       
  1357             // Reset the controls
       
  1358             iContainer->HandleCommandL( EMPXPbvCmdResetControls );
       
  1359             // Set the iMediaRequested flag to false
       
  1360             iMediaRequested = EFalse;
       
  1361             // Reset the playback state to stopped
       
  1362             iPlaybackState = EPbStateStopped;
       
  1363             // Handle the plugin error
       
  1364             HandlePluginErrorL( error );
       
  1365         }
       
  1366         else
       
  1367         {
       
  1368             DoHandleMediaL( aMedia, aError );
       
  1369         }
       
  1370     }
       
  1371 }
       
  1372 
       
  1373 // -------------------------------------------------------------------------------------------------
       
  1374 //   CMPXVideoBasePlaybackView::SetPropertyL()
       
  1375 // -------------------------------------------------------------------------------------------------
       
  1376 //
       
  1377 void CMPXVideoBasePlaybackView::SetPropertyL( TMPXPlaybackProperty aProperty, TInt aValue )
       
  1378 {
       
  1379     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::SetPropertyL"),
       
  1380                    _L("aProperty = %d, aValue = %d"), aProperty, aValue );
       
  1381 
       
  1382     iPlaybackUtility->SetL( aProperty, aValue );
       
  1383 }
       
  1384 
       
  1385 // -------------------------------------------------------------------------------------------------
       
  1386 //   CMPXVideoBasePlaybackView::HandlePropertyL()
       
  1387 // -------------------------------------------------------------------------------------------------
       
  1388 //
       
  1389 void CMPXVideoBasePlaybackView::HandlePropertyL( TMPXPlaybackProperty aProperty,
       
  1390                                                  TInt aValue,
       
  1391                                                  TInt aError )
       
  1392 {
       
  1393     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandlePropertyL - Error(%d)"), aError );
       
  1394 
       
  1395     if ( aError == KErrNone )
       
  1396     {
       
  1397         switch ( aProperty  )
       
  1398         {
       
  1399             case EPbPropertyPosition:
       
  1400             {
       
  1401                 MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandlePropertyL position(%d)"), aValue );
       
  1402 
       
  1403                 if ( iContainer )
       
  1404                 {
       
  1405                     iContainer->HandleEventL( EMPXControlCmdSetPosition, aValue );
       
  1406                 }
       
  1407 
       
  1408                 break;
       
  1409             }
       
  1410             case EPbPropertyDuration:
       
  1411             {
       
  1412                 MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandlePropertyL duration(%d)"), aValue );
       
  1413 
       
  1414                 if ( iContainer )
       
  1415                 {
       
  1416                     iContainer->HandleEventL( EMPXControlCmdSetDuration, aValue );
       
  1417                 }
       
  1418 
       
  1419                 break;
       
  1420             }
       
  1421             case EPbPropertyMaxVolume:
       
  1422             {
       
  1423                 MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandlePropertyL max volume(%d)"), aValue );
       
  1424 
       
  1425                 break;
       
  1426             }
       
  1427             case EPbPropertyVolume:
       
  1428             {
       
  1429                 MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandlePropertyL volume(%d)"), aValue );
       
  1430 
       
  1431                 if ( iContainer )
       
  1432                 {
       
  1433                     iContainer->HandleEventL( EMPXControlCmdSetVolume, aValue );
       
  1434                 }
       
  1435 
       
  1436                 break;
       
  1437             }
       
  1438             case EPbPropertyMute:
       
  1439             {
       
  1440                 MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandlePropertyL muted(%d)"), aValue );
       
  1441 
       
  1442                 if ( iContainer && aValue )
       
  1443                 {
       
  1444                     iContainer->HandleEventL( EMPXControlCmdSetVolume, 0 );
       
  1445                 }
       
  1446 
       
  1447                 break;
       
  1448             }
       
  1449         }
       
  1450     }
       
  1451 }
       
  1452 
       
  1453 // -------------------------------------------------------------------------------------------------
       
  1454 //   CMPXVideoBasePlaybackView::DisplayInfoMessageL
       
  1455 // -------------------------------------------------------------------------------------------------
       
  1456 //
       
  1457 void CMPXVideoBasePlaybackView::DisplayInfoMessageL( TInt aResourceId, TBool aWaitingDialog )
       
  1458 {
       
  1459     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::DisplayInfoMessageL()"),
       
  1460                    _L("resource = %08x"), aResourceId );
       
  1461 
       
  1462     HBufC* text = StringLoader::LoadLC( aResourceId );
       
  1463 
       
  1464     CAknInformationNote* dlg = new (ELeave) CAknInformationNote( aWaitingDialog );
       
  1465     dlg->ExecuteLD( *text );
       
  1466     CleanupStack::PopAndDestroy( text );
       
  1467 }
       
  1468 
       
  1469 // -------------------------------------------------------------------------------------------------
       
  1470 //   CMPXVideoBasePlaybackView::DisplayErrorMessageL
       
  1471 // -------------------------------------------------------------------------------------------------
       
  1472 //
       
  1473 void CMPXVideoBasePlaybackView::DisplayErrorMessageL( TInt aResourceId )
       
  1474 {
       
  1475     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::DisplayErrorMessageL()"),
       
  1476                    _L("resource = %08x"), aResourceId );
       
  1477 
       
  1478     HBufC* text = StringLoader::LoadLC( aResourceId );
       
  1479 
       
  1480     CAknErrorNote* eDlg = new (ELeave) CAknErrorNote( ETrue );
       
  1481     eDlg->ExecuteLD( *text );
       
  1482     CleanupStack::PopAndDestroy( text );
       
  1483 }
       
  1484 
       
  1485 // -------------------------------------------------------------------------------------------------
       
  1486 //   CMPXVideoBasePlaybackView::RetrieveFileNameAndModeL
       
  1487 // -------------------------------------------------------------------------------------------------
       
  1488 //
       
  1489 void CMPXVideoBasePlaybackView::RetrieveFileNameAndModeL( CMPXCommand* aCmd )
       
  1490 {
       
  1491     //
       
  1492     //  set attributes on the command
       
  1493     //
       
  1494     aCmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1495 
       
  1496     aCmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  1497 
       
  1498     aCmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand,
       
  1499                                                       EPbCmdInitView );
       
  1500 
       
  1501     iPlaybackUtility->CommandL( *aCmd );
       
  1502 }
       
  1503 
       
  1504 
       
  1505 // -------------------------------------------------------------------------------------------------
       
  1506 //   CMPXVideoBasePlaybackView::ActivateClosePlayerActiveObject
       
  1507 // -------------------------------------------------------------------------------------------------
       
  1508 //
       
  1509 void CMPXVideoBasePlaybackView::ActivateClosePlayerActiveObject()
       
  1510 {
       
  1511     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::ActivateClosePlayerActiveObject()"));
       
  1512 
       
  1513     if ( ! iCloseAO->IsActive() )
       
  1514     {
       
  1515         iCloseAO->Start( TCallBack( CMPXVideoBasePlaybackView::ClosePlayerL, this ) );
       
  1516     }
       
  1517 }
       
  1518 
       
  1519 // -----------------------------------------------------------------------------
       
  1520 //   CMPXVideoBasePlaybackView::ClosePlayerL
       
  1521 // -----------------------------------------------------------------------------
       
  1522 //
       
  1523 TInt CMPXVideoBasePlaybackView::ClosePlayerL( TAny* aPtr )
       
  1524 {
       
  1525     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::ClosePlayerL()"));
       
  1526 
       
  1527     static_cast<CMPXVideoBasePlaybackView*>(aPtr)->DoClosePlayerL();
       
  1528     return KErrNone;
       
  1529 }
       
  1530 
       
  1531 // -------------------------------------------------------------------------------------------------
       
  1532 //   CMPXVideoBasePlaybackView::DoClosePlayerL
       
  1533 // -------------------------------------------------------------------------------------------------
       
  1534 //
       
  1535 void CMPXVideoBasePlaybackView::DoClosePlayerL()
       
  1536 {
       
  1537     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::DoClosePlayerL()"));
       
  1538 
       
  1539     AppUi()->HandleCommandL( EAknSoftkeyBack );
       
  1540 }
       
  1541 
       
  1542 // -------------------------------------------------------------------------------------------------
       
  1543 //   CMPXVideoBasePlaybackView::IssuePlayCommandL
       
  1544 // -------------------------------------------------------------------------------------------------
       
  1545 //
       
  1546 void CMPXVideoBasePlaybackView::IssuePlayCommandL()
       
  1547 {
       
  1548     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::IssuePlayCommandL()"));
       
  1549     CreateGeneralPlaybackCommandL( EPbCmdPlay );
       
  1550 }
       
  1551 
       
  1552 // -------------------------------------------------------------------------------------------------
       
  1553 //   CMPXVideoBasePlaybackView::RetrievePdlInformationL
       
  1554 // -------------------------------------------------------------------------------------------------
       
  1555 //
       
  1556 void CMPXVideoBasePlaybackView::RetrievePdlInformationL()
       
  1557 {
       
  1558     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::RetrievePdlInformationL()"));
       
  1559 }
       
  1560 
       
  1561 // -------------------------------------------------------------------------------------------------
       
  1562 //   CMPXVideoBasePlaybackView::HandleBufferingStateL
       
  1563 // -------------------------------------------------------------------------------------------------
       
  1564 //
       
  1565 void CMPXVideoBasePlaybackView::HandleBufferingStateL()
       
  1566 {
       
  1567     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::HandleBufferingStateL()"));
       
  1568 
       
  1569 }
       
  1570 
       
  1571 // -------------------------------------------------------------------------------------------------
       
  1572 // CMPXVideoBasePlaybackView::CreateVideoSpecificCmdL()
       
  1573 // -------------------------------------------------------------------------------------------------
       
  1574 //
       
  1575 void CMPXVideoBasePlaybackView::CreateVideoSpecificCmdL( TMPXVideoPlaybackCommand aCmd )
       
  1576 {
       
  1577     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::CreateVideoSpecificCmdL(%d)"), aCmd );
       
  1578 
       
  1579     //
       
  1580     //  create command to pass to playback plugin
       
  1581     //
       
  1582     CMPXCommand* cmd = CMPXCommand::NewL();
       
  1583     CleanupStack::PushL( cmd );
       
  1584 
       
  1585     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1586 
       
  1587     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  1588 
       
  1589     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand, aCmd );
       
  1590 
       
  1591     iPlaybackUtility->CommandL( *cmd );
       
  1592 
       
  1593     CleanupStack::PopAndDestroy( cmd );
       
  1594 }
       
  1595 
       
  1596 // -------------------------------------------------------------------------------------------------
       
  1597 // CMPXVideoBasePlaybackView::SetAspectRatioL()
       
  1598 // -------------------------------------------------------------------------------------------------
       
  1599 //
       
  1600 void CMPXVideoBasePlaybackView::SetAspectRatioL( TMPXVideoPlaybackCommand aCmd )
       
  1601 {
       
  1602     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::SetAspectRatioL()"));
       
  1603 
       
  1604     TInt newAspectRatio = iDisplayHandler->SetAspectRatioL( aCmd );
       
  1605 
       
  1606     if ( iContainer )
       
  1607     {
       
  1608         iContainer->HandleEventL( EMPXControlCmdSetAspectRatio, newAspectRatio );
       
  1609     }
       
  1610 }
       
  1611 
       
  1612 // ---------------------------------------------------------------------------
       
  1613 // CMPXVideoBasePlaybackView::IsAppInFrontL()
       
  1614 // Returns true if app is foreground. Uses windowgroup id
       
  1615 // ---------------------------------------------------------------------------
       
  1616 //
       
  1617 TBool CMPXVideoBasePlaybackView::IsAppInFrontL()
       
  1618 {
       
  1619     TBool ret = EFalse;
       
  1620     RWsSession wsSession;
       
  1621 
       
  1622     User::LeaveIfError( wsSession.Connect() );
       
  1623 
       
  1624     if ( wsSession.Handle() )
       
  1625     {
       
  1626         CArrayFixFlat<TInt>* wgList =
       
  1627             new (ELeave) CArrayFixFlat<TInt>( wsSession.NumWindowGroups() );
       
  1628 
       
  1629         // check if our window is front or not
       
  1630         if ( wsSession.WindowGroupList( 0, wgList ) == KErrNone )
       
  1631         {
       
  1632             ret = ( iCoeEnv->RootWin().Identifier() == wgList->At(0) );
       
  1633         }
       
  1634         else
       
  1635         {
       
  1636             ret = EFalse;
       
  1637         }
       
  1638 
       
  1639         delete wgList;
       
  1640     }
       
  1641 
       
  1642     wsSession.Close();
       
  1643 
       
  1644     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::IsAppInFrontL (%d)" ), ret);
       
  1645 
       
  1646     return ret;
       
  1647 }
       
  1648 
       
  1649 // -------------------------------------------------------------------------------------------------
       
  1650 //   CMPXVideoBasePlaybackView::ClosePlaybackViewL()
       
  1651 // -------------------------------------------------------------------------------------------------
       
  1652 //
       
  1653 void CMPXVideoBasePlaybackView::ClosePlaybackViewL()
       
  1654 {
       
  1655     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::ClosePlaybackViewL()"));
       
  1656 
       
  1657     if ( iFileDetailsDialog )
       
  1658     {
       
  1659         iFileDetailsDialog->Close();
       
  1660     }
       
  1661 
       
  1662     //
       
  1663     //  The View Utility may have deactivated this view already.
       
  1664     //  Check if we are the active view
       
  1665     //
       
  1666     if ( iViewUtility->ActiveViewImplementationUid() == ViewImplementationId() )
       
  1667     {
       
  1668         if ( iViewUtility->ViewHistoryDepth() > 1 )
       
  1669         {
       
  1670             iViewUtility->ActivatePreviousViewL();
       
  1671 
       
  1672             //
       
  1673             //  Hide controls and window since view will be deactivated.
       
  1674             //  This prevents black boxes on the view switching
       
  1675             //
       
  1676             iContainer->HandleEventL( EMPXControlCmdHideControls );
       
  1677             iContainer->GetWindow().SetVisible( EFalse );
       
  1678         }
       
  1679         else
       
  1680         {
       
  1681             CloseEmbeddedPlaybackViewL();
       
  1682         }
       
  1683     }
       
  1684 }
       
  1685 
       
  1686 // -------------------------------------------------------------------------------------------------
       
  1687 //   CMPXVideoBasePlaybackView::HandleVolumeCmdL()
       
  1688 // -------------------------------------------------------------------------------------------------
       
  1689 //
       
  1690 void CMPXVideoBasePlaybackView::HandleVolumeCmdL( TMPXPlaybackCommand aCmd )
       
  1691 {
       
  1692     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleVolumeCmdL()"));
       
  1693 
       
  1694     //
       
  1695     // In case user try to change the volume via media key, rocker key or etc
       
  1696     // We need to show the controls though the volume level doesn't get changed
       
  1697     // For examples : - try to change the volume with a clip without audio track
       
  1698     //                - try to reduce the volume with volume level 0
       
  1699     //                - try to increase the volume with max volume level
       
  1700     //
       
  1701     iContainer->HandleEventL( EMPXControlCmdShowControls );
       
  1702 
       
  1703     switch( aCmd )
       
  1704     {
       
  1705         case EPbCmdDecreaseVolume:
       
  1706         {
       
  1707             CreateVideoSpecificCmdL( EPbCmdHandleDecreaseVolume );
       
  1708             break;
       
  1709         }
       
  1710         case EPbCmdIncreaseVolume:
       
  1711         {
       
  1712             CreateVideoSpecificCmdL( EPbCmdHandleIncreaseVolume );
       
  1713             break;
       
  1714         }
       
  1715         default:
       
  1716         {
       
  1717             iPlaybackUtility->CommandL( aCmd );
       
  1718             break;
       
  1719         }
       
  1720     }
       
  1721 }
       
  1722 
       
  1723 // -------------------------------------------------------------------------------------------------
       
  1724 //   CMPXVideoBasePlaybackView::HandleShortPressBackwardL()
       
  1725 // -------------------------------------------------------------------------------------------------
       
  1726 //
       
  1727 void CMPXVideoBasePlaybackView::HandleShortPressBackwardL()
       
  1728 {
       
  1729     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleShortPressBackwardL()"));
       
  1730 
       
  1731     SetPropertyL( EPbPropertyPosition, 0);
       
  1732 }
       
  1733 
       
  1734 TInt CMPXVideoBasePlaybackView::AddDllPath( TDes& aFileName )
       
  1735 {
       
  1736     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::AddDllPath()"),
       
  1737                    _L("aFileName = %S"), &aFileName);
       
  1738 
       
  1739     //
       
  1740     //  Find drive for dll to search same drive for rsc
       
  1741     //
       
  1742     TFileName dllName;
       
  1743     Dll::FileName( dllName );
       
  1744 
       
  1745     TPtrC driveAndPath = TParsePtrC( dllName ).DriveAndPath();
       
  1746 
       
  1747     TParse parse;
       
  1748 
       
  1749     TInt error = parse.Set( aFileName, &driveAndPath, NULL );
       
  1750 
       
  1751     if ( error == KErrNone )
       
  1752     {
       
  1753         aFileName.Zero();
       
  1754         aFileName.Append( parse.FullName() );
       
  1755     }
       
  1756 
       
  1757     return error;
       
  1758 }
       
  1759 
       
  1760 void CMPXVideoBasePlaybackView::ShowFileDetailsDialogL()
       
  1761 {
       
  1762     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::ShowFileDetailsDialogL()"));
       
  1763 
       
  1764     iFileDetailsDialog = CMPFileDetailsDialog::NewL();
       
  1765 
       
  1766     CMPFileDetails* fileDetailsDialogParams = new (ELeave) CMPFileDetails();
       
  1767     CleanupStack::PushL( fileDetailsDialogParams );
       
  1768 
       
  1769     if ( iFileDetails->iClipName )
       
  1770     {
       
  1771         fileDetailsDialogParams->iFileName = iFileDetails->iClipName->AllocL();
       
  1772     }
       
  1773 
       
  1774     if ( iFileDetails->iTitle )
       
  1775     {
       
  1776         fileDetailsDialogParams->iTitle = iFileDetails->iTitle->AllocL();
       
  1777     }
       
  1778 
       
  1779     if ( iFileDetails->iArtist )
       
  1780     {
       
  1781         fileDetailsDialogParams->iArtist = iFileDetails->iArtist->AllocL();
       
  1782     }
       
  1783 
       
  1784     if ( iFileDetails->iMimeType )
       
  1785     {
       
  1786         fileDetailsDialogParams->iFormat = iFileDetails->iMimeType->AllocL();
       
  1787     }
       
  1788 
       
  1789     fileDetailsDialogParams->iResolutionHeight = iFileDetails->iVideoHeight;
       
  1790     fileDetailsDialogParams->iResolutionWidth = iFileDetails->iVideoWidth;
       
  1791     fileDetailsDialogParams->iDurationInSeconds = iFileDetails->iDuration / KPbMilliMultiplier;
       
  1792     fileDetailsDialogParams->iBitrate = iFileDetails->iBitRate;
       
  1793 
       
  1794     if ( iFileDetails->iDrmProtected )
       
  1795     {
       
  1796         fileDetailsDialogParams->iDrmProtected = iFileDetails->iDrmProtected;
       
  1797         fileDetailsDialogParams->iFilePath = iFileDetails->iClipName->AllocL();
       
  1798 
       
  1799         TInt openError = KErrNone;
       
  1800 
       
  1801         //
       
  1802         // based on SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API flag,
       
  1803         // fileDetailsDialogParams->iDetailsFileHandle uses either RFile64 or RFile handle,
       
  1804         // therefore, we need to handle it in the same manner here
       
  1805         //
       
  1806 
       
  1807 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  1808 
       
  1809         RFile64 tempFileHandle;
       
  1810         CleanupClosePushL( tempFileHandle );
       
  1811         openError = OpenDrmFileHandle64L( tempFileHandle );
       
  1812 
       
  1813 #else // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  1814 
       
  1815         RFile tempFileHandle;
       
  1816         CleanupClosePushL( tempFileHandle );
       
  1817         openError = OpenDrmFileHandleL( tempFileHandle );
       
  1818 
       
  1819 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  1820 
       
  1821         if ( ! openError )
       
  1822         {
       
  1823             fileDetailsDialogParams->iDetailsFileHandle.Duplicate( tempFileHandle );
       
  1824         }
       
  1825 
       
  1826         CleanupStack::PopAndDestroy();  // tempFileHandle
       
  1827     }
       
  1828 
       
  1829     TRAP_IGNORE( iFileDetailsDialog->ExecuteLD( fileDetailsDialogParams ) );
       
  1830 
       
  1831     CleanupStack::PopAndDestroy(); // fileDetailsDialogParams;
       
  1832     iFileDetailsDialog = NULL;
       
  1833 }
       
  1834 
       
  1835 // -------------------------------------------------------------------------------------------------
       
  1836 //   CMPXVideoBasePlaybackView::HandleDrmErrorsL()
       
  1837 // -------------------------------------------------------------------------------------------------
       
  1838 //
       
  1839 void CMPXVideoBasePlaybackView::HandleDrmErrorsL( TInt aError )
       
  1840 {
       
  1841     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleDrmErrorsL()"));
       
  1842 
       
  1843     if ( IsMultiItemPlaylist() )
       
  1844     {
       
  1845         DisplayErrorMessageL( R_MPX_DRM_RIGHTS_MISSING  );
       
  1846     }
       
  1847     else
       
  1848     {
       
  1849         TInt openError = KErrNotFound;
       
  1850         RFile fileHandle;
       
  1851         CleanupClosePushL( fileHandle );
       
  1852 
       
  1853         MPX_TRAPD( err, openError = OpenDrmFileHandleL( fileHandle ) );
       
  1854 
       
  1855         if ( err == KErrNone && openError == KErrNone )
       
  1856         {
       
  1857             DRM::CDrmUiHandling* drmUiHandling = DRM::CDrmUiHandling::NewL( iCoeEnv );
       
  1858             CleanupStack::PushL( drmUiHandling );
       
  1859 
       
  1860             drmUiHandling->GetErrorHandler().HandleErrorL( fileHandle,
       
  1861                                                            ContentAccess::EPlay,
       
  1862                                                            aError,
       
  1863                                                            NULL );
       
  1864 
       
  1865             CleanupStack::PopAndDestroy( drmUiHandling );
       
  1866         }
       
  1867 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  1868         else if ( err == KErrNone && openError == KErrTooBig )
       
  1869         {
       
  1870             RFile64 fileHandle64;
       
  1871             CleanupClosePushL( fileHandle64 );
       
  1872 
       
  1873             MPX_TRAPD( err, openError = OpenDrmFileHandle64L( fileHandle64 ) );
       
  1874 
       
  1875             if ( err == KErrNone && openError == KErrNone )
       
  1876             {
       
  1877                 DRM::CDrmUiHandling* drmUiHandling = DRM::CDrmUiHandling::NewL( iCoeEnv );
       
  1878                 CleanupStack::PushL( drmUiHandling );
       
  1879 
       
  1880                 drmUiHandling->GetErrorHandler().HandleErrorL( fileHandle64,
       
  1881                                                                ContentAccess::EPlay,
       
  1882                                                                aError,
       
  1883                                                                NULL );
       
  1884                 CleanupStack::PopAndDestroy( drmUiHandling );
       
  1885             }
       
  1886             else
       
  1887             {
       
  1888                 DisplayErrorMessageL( R_MPX_DRM_RIGHTS_MISSING  );
       
  1889             }
       
  1890 
       
  1891             CleanupStack::PopAndDestroy();  // fileHandle64
       
  1892         }
       
  1893 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  1894         else
       
  1895         {
       
  1896             DisplayErrorMessageL( R_MPX_DRM_RIGHTS_MISSING  );
       
  1897         }
       
  1898 
       
  1899         CleanupStack::PopAndDestroy();  // fileHandle
       
  1900     }
       
  1901 
       
  1902     HandleClosePlaybackViewL();
       
  1903 }
       
  1904 
       
  1905 // -------------------------------------------------------------------------------------------------
       
  1906 //   CMPXVideoBasePlaybackView::IsMultiItemPlaylist()
       
  1907 // -------------------------------------------------------------------------------------------------
       
  1908 //
       
  1909 TBool CMPXVideoBasePlaybackView::IsMultiItemPlaylist()
       
  1910 {
       
  1911     TInt numItems = 1;
       
  1912     MMPXSource* s = iPlaybackUtility->Source();
       
  1913 
       
  1914     if ( s )
       
  1915     {
       
  1916         CMPXCollectionPlaylist* playlist = NULL;
       
  1917 
       
  1918         MPX_TRAPD( err, playlist = s->PlaylistL() );
       
  1919 
       
  1920         if ( err == KErrNone && playlist )
       
  1921         {
       
  1922             numItems = playlist->Count();
       
  1923             delete playlist;
       
  1924         }
       
  1925     }
       
  1926 
       
  1927     TBool retVal = ( numItems > 1 );
       
  1928 
       
  1929     MPX_DEBUG(_L("CMPXVideoBasePlaybackView::IsMultiItemPlaylist(%d)"), retVal);
       
  1930 
       
  1931     return retVal;
       
  1932 }
       
  1933 
       
  1934 // -------------------------------------------------------------------------------------------------
       
  1935 //   CMPXVideoBasePlaybackView::OpenDrmFileHandleL()
       
  1936 // -------------------------------------------------------------------------------------------------
       
  1937 //
       
  1938 TInt CMPXVideoBasePlaybackView::OpenDrmFileHandleL( RFile& aFile )
       
  1939 {
       
  1940     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::OpenDrmFileHandleL()"));
       
  1941 
       
  1942     TInt openError = KErrNotFound;
       
  1943     RFs& fs = iCoeEnv->FsSession();
       
  1944 
       
  1945     if ( iPlaylistView )
       
  1946     {
       
  1947         //
       
  1948         //  Use iClipName from the MediaL() call
       
  1949         //
       
  1950         openError = aFile.Open( fs, iClipName->Des(), EFileRead | EFileShareReadersOrWriters );
       
  1951     }
       
  1952     else
       
  1953     {
       
  1954         MMPXSource* s = iPlaybackUtility->Source();
       
  1955 
       
  1956         if ( s )
       
  1957         {
       
  1958             RFile* tempFile = s->FileL();
       
  1959 
       
  1960             if ( tempFile && tempFile->SubSessionHandle() )
       
  1961             {
       
  1962                 //
       
  1963                 //  File Handle from the framework is valid, use it
       
  1964                 //
       
  1965                 openError = aFile.Duplicate( *tempFile );
       
  1966             }
       
  1967             else
       
  1968             {
       
  1969                 //
       
  1970                 //  File Handle not valid, get URI and open file
       
  1971                 //
       
  1972                 HBufC* tempFileName = s->UriL();
       
  1973 
       
  1974                 openError = aFile.Open( fs,
       
  1975                                         tempFileName->Des(),
       
  1976                                         EFileRead | EFileShareReadersOrWriters );
       
  1977 
       
  1978                 delete tempFileName;
       
  1979             }
       
  1980         }
       
  1981     }
       
  1982 
       
  1983     return openError;
       
  1984 }
       
  1985 
       
  1986 // -------------------------------------------------------------------------------------------------
       
  1987 // CMPXVideoBasePlaybackView::LaunchDRMDetailsL()
       
  1988 // -------------------------------------------------------------------------------------------------
       
  1989 //
       
  1990 void CMPXVideoBasePlaybackView::LaunchDRMDetailsL()
       
  1991 {
       
  1992     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::LaunchDRMDetailsL()"));
       
  1993 
       
  1994     TInt openError = KErrNotFound;
       
  1995     RFile fileHandle;
       
  1996     CleanupClosePushL( fileHandle );
       
  1997 
       
  1998     MPX_TRAPD( err, openError = OpenDrmFileHandleL( fileHandle ) );
       
  1999 
       
  2000     if ( err == KErrNone )
       
  2001     {
       
  2002         DRM::CDrmUiHandling* drmUiHandling = DRM::CDrmUiHandling::NewL( iCoeEnv );
       
  2003         CleanupStack::PushL( drmUiHandling );
       
  2004 
       
  2005         if ( openError == KErrNone )
       
  2006         {
       
  2007             TRAP_IGNORE( drmUiHandling->ShowDetailsViewL(fileHandle) );
       
  2008         }
       
  2009 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  2010         else if ( openError == KErrTooBig )
       
  2011         {
       
  2012             RFile64 fileHandle64;
       
  2013             CleanupClosePushL( fileHandle64 );
       
  2014             MPX_TRAPD( err, openError = OpenDrmFileHandle64L( fileHandle64 ) );
       
  2015 
       
  2016             if ( err == KErrNone && openError == KErrNone )
       
  2017             {
       
  2018                 TRAP_IGNORE( drmUiHandling->ShowDetailsViewL(fileHandle64) );
       
  2019             }
       
  2020 
       
  2021             CleanupStack::PopAndDestroy(); // fileHandle64
       
  2022         }
       
  2023 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  2024 
       
  2025         CleanupStack::PopAndDestroy( drmUiHandling );
       
  2026     }
       
  2027 
       
  2028     CleanupStack::PopAndDestroy();  // fileHandle
       
  2029 }
       
  2030 
       
  2031 // -------------------------------------------------------------------------------------------------
       
  2032 //   CMPXVideoBasePlaybackView::RetrieveBufferingPercentageL()
       
  2033 // -------------------------------------------------------------------------------------------------
       
  2034 //
       
  2035 TInt
       
  2036 CMPXVideoBasePlaybackView::RetrieveBufferingPercentageL()
       
  2037 {
       
  2038     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::RetrieveBufferingPercentageL()"));
       
  2039 
       
  2040     //
       
  2041     //  create command to pass to playback plugin
       
  2042     //
       
  2043     CMPXCommand* cmd = CMPXCommand::NewL();
       
  2044     CleanupStack::PushL( cmd );
       
  2045 
       
  2046     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  2047     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  2048     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand,
       
  2049                                                      EPbCmdRetrieveBufferingPercentage );
       
  2050 
       
  2051     iPlaybackUtility->CommandL( *cmd );
       
  2052 
       
  2053     TInt buffPercentage = cmd->ValueTObjectL<TInt>( KMPXMediaVideoBufferingPercentage );
       
  2054 
       
  2055     CleanupStack::PopAndDestroy( cmd );
       
  2056 
       
  2057     return buffPercentage;
       
  2058 }
       
  2059 
       
  2060 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  2061 
       
  2062 // -------------------------------------------------------------------------------------------------
       
  2063 //   CMPXVideoBasePlaybackView::OpenDrmFileHandle64L()
       
  2064 // -------------------------------------------------------------------------------------------------
       
  2065 //
       
  2066 TInt CMPXVideoBasePlaybackView::OpenDrmFileHandle64L( RFile64& aFile )
       
  2067 {
       
  2068     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::OpenDrmFileHandle64L()"));
       
  2069 
       
  2070     TInt openError = KErrNotFound;
       
  2071     RFs& fs = iCoeEnv->FsSession();
       
  2072 
       
  2073     if ( iPlaylistView )
       
  2074     {
       
  2075         //
       
  2076         //  Use iClipName from the MediaL() call
       
  2077         //
       
  2078         openError = aFile.Open( fs, iClipName->Des(), EFileRead | EFileShareReadersOrWriters );
       
  2079     }
       
  2080     else
       
  2081     {
       
  2082         MMPXSource* s = iPlaybackUtility->Source();
       
  2083 
       
  2084         if ( s )
       
  2085         {
       
  2086 
       
  2087             RFile64* tempFile = s->File64L();
       
  2088 
       
  2089             if ( tempFile && tempFile->SubSessionHandle() )
       
  2090             {
       
  2091                 //
       
  2092                 //  File Handle from the framework is valid, use it
       
  2093                 //
       
  2094                 openError = aFile.Duplicate( *tempFile );
       
  2095             }
       
  2096             else
       
  2097             {
       
  2098                 //
       
  2099                 //  File Handle not valid, get URI and open file
       
  2100                 //
       
  2101                 HBufC* tempFileName = s->UriL();
       
  2102 
       
  2103                 openError = aFile.Open( fs,
       
  2104                                         tempFileName->Des(),
       
  2105                                         EFileRead | EFileShareReadersOrWriters );
       
  2106 
       
  2107                 delete tempFileName;
       
  2108             }
       
  2109         }
       
  2110     }
       
  2111 
       
  2112     return openError;
       
  2113 }
       
  2114 
       
  2115 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  2116 
       
  2117 // EOF