videoplayback/videoplaybackcontrols/src/mpxvideoplaybackcontrolscontroller.cpp
changeset 0 96612d01cf9f
child 6 7d91903f795f
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 MPXVideoPlaybackControlsController
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 24 %
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <fbs.h>
       
    23 #include <coecntrl.h>
       
    24 #include <gulicon.h>
       
    25 #include <bautils.h>
       
    26 #include <eiklabel.h>
       
    27 #include <eikimage.h>
       
    28 #include <AknUtils.h>
       
    29 #include <barsread.h>
       
    30 #include <AknIconUtils.h>
       
    31 #include <StringLoader.h>
       
    32 #include <AknsDrawUtils.h>
       
    33 #include <AknsSkinInstance.h>
       
    34 #include <AknBitmapAnimation.h>
       
    35 #include <AknsBasicBackgroundControlContext.h>
       
    36 #include <f32file.h>
       
    37 
       
    38 #include <aknlayoutscalable_apps.cdl.h>
       
    39 #include <data_caging_path_literals.hrh>
       
    40 
       
    41 #include <mpxvideoplaybackcontrols.rsg>
       
    42 #include <mpxvideoplaybackcontrols.mbg>
       
    43 
       
    44 #ifdef RD_TACTILE_FEEDBACK
       
    45 #include <touchfeedback.h>
       
    46 #endif //RD_TACTILE_FEEDBACK
       
    47 
       
    48 #include "mpxvideoplaybackcontrol.h"
       
    49 #include "mpxvideoplaybackcontrolpdl.h"
       
    50 #include "mpxvideoplaybackbuttonbar.h"
       
    51 #include "mpxvideoplaybackvolumebar.h"
       
    52 #include "mpxvideoplaybackprogressbar.h"
       
    53 #include "mpxvideoplaybackcontainer.h"
       
    54 #include "mpxvideoplaybackcontrolpolicy.h"
       
    55 #include "mpxvideoplaybackviewfiledetails.h"
       
    56 #include "mpxvideoplaybackcontrolscontroller.h"
       
    57 #include "mpxvideoplaybackcontrolconfiguration.h"
       
    58 #include "mpxvideoplaybackaspectratioicon.h"
       
    59 #include "mpxvideoplaybackbrandinganimation.h"
       
    60 #include "mpxvideoplaybackmediadetailsviewer.h"
       
    61 #include "mpxcommonvideoplaybackview.hrh"
       
    62 
       
    63 using namespace AknLayoutScalable_Apps;
       
    64 using namespace AknLayoutScalable_Avkon;
       
    65 
       
    66 const TInt KMPXControlsTimeOut = 4000000;
       
    67 
       
    68 // ================= MEMBER FUNCTIONS ==============================================================
       
    69 
       
    70 // -------------------------------------------------------------------------------------------------
       
    71 // CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController
       
    72 // C++ default constructor can NOT contain any code, that might leave.
       
    73 // -------------------------------------------------------------------------------------------------
       
    74 //
       
    75 CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController(
       
    76     CMPXVideoPlaybackContainer* aContainer, TRect aRect )
       
    77     : iControls( EMPXControlsCount ),
       
    78       iRect( aRect ),
       
    79       iContainer( aContainer )
       
    80 {
       
    81 }
       
    82 
       
    83 // -------------------------------------------------------------------------------------------------
       
    84 // CMPXVideoPlaybackControlsController::ConstructL()
       
    85 // Symbian 2nd phase constructor can leave.
       
    86 // -------------------------------------------------------------------------------------------------
       
    87 //
       
    88 void CMPXVideoPlaybackControlsController::ConstructL( CMPXVideoPlaybackViewFileDetails* aDetails )
       
    89 {
       
    90     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::ConstructL()"));
       
    91 
       
    92     User::LeaveIfError( iFs.Connect() );
       
    93 
       
    94     _LIT( KMPXVideoPlaybackRscPath, "mpxvideoplaybackcontrols.rsc" );
       
    95 
       
    96     TParse parse;
       
    97     parse.Set( KMPXVideoPlaybackRscPath, &KDC_APP_RESOURCE_DIR, NULL );
       
    98     TFileName resourceFile = parse.FullName();
       
    99 
       
   100     //
       
   101     //  Find the resource file.  It must be on the same drive as the DLL is installed
       
   102     //
       
   103     User::LeaveIfError( AddDllPath( resourceFile ) );
       
   104 
       
   105     BaflUtils::NearestLanguageFile( iFs, resourceFile );
       
   106 
       
   107     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   108 
       
   109     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::ConstructL() rsc file %S"), &resourceFile);
       
   110 
       
   111     iVideoResourceOffset = coeEnv->AddResourceFileL( resourceFile );
       
   112 
       
   113     iFileDetails = aDetails;
       
   114 
       
   115     iFileDetails->iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
       
   116 
       
   117     if ( iFileDetails->iRNFormat )
       
   118     {
       
   119     	CreateRealOneBitmapL();
       
   120     }
       
   121 
       
   122     iControlsPolicy = CMPXVideoPlaybackControlPolicy::NewL();
       
   123     iControlsConfig = CMPXVideoPlaybackControlConfiguration::NewL( this );
       
   124 
       
   125     iControlsTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   126 
       
   127     CreateControlsL();
       
   128 
       
   129 #ifdef RD_TACTILE_FEEDBACK
       
   130     iFeedback = MTouchFeedback::Instance();
       
   131 #endif //RD_TACTILE_FEEDBACK
       
   132 }
       
   133 
       
   134 // -------------------------------------------------------------------------------------------------
       
   135 // CMPXVideoPlaybackControlsController::NewL()
       
   136 // Two-phased constructor.
       
   137 // -------------------------------------------------------------------------------------------------
       
   138 //
       
   139 EXPORT_C CMPXVideoPlaybackControlsController* CMPXVideoPlaybackControlsController::NewL(
       
   140         CMPXVideoPlaybackContainer* aContainer,
       
   141         TRect aRect,
       
   142         CMPXVideoPlaybackViewFileDetails* aDetails )
       
   143 {
       
   144     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::NewL()"));
       
   145 
       
   146     CMPXVideoPlaybackControlsController* self =
       
   147         new (ELeave) CMPXVideoPlaybackControlsController( aContainer, aRect );
       
   148 
       
   149     CleanupStack::PushL(self);
       
   150     self->ConstructL( aDetails );
       
   151     CleanupStack::Pop();
       
   152 
       
   153     return self;
       
   154 }
       
   155 
       
   156 // -------------------------------------------------------------------------------------------------
       
   157 // CMPXVideoPlaybackControlsController::~CMPXVideoPlaybackControlsController
       
   158 // Destructor.
       
   159 // -------------------------------------------------------------------------------------------------
       
   160 //
       
   161 EXPORT_C CMPXVideoPlaybackControlsController::~CMPXVideoPlaybackControlsController()
       
   162 {
       
   163     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::~CMPXVideoPlaybackControlsController"));
       
   164 
       
   165     iFs.Close();
       
   166 
       
   167 
       
   168 #ifdef RD_TACTILE_FEEDBACK
       
   169     if (iFeedback)
       
   170     {
       
   171         iFeedback->RemoveFeedbackForControl( iContainer );
       
   172     }
       
   173 #endif //RD_TACTILE_FEEDBACK
       
   174 
       
   175     if ( iControlsPolicy )
       
   176     {
       
   177         delete iControlsPolicy;
       
   178         iControlsPolicy = NULL;
       
   179     }
       
   180 
       
   181     if ( iControlsConfig )
       
   182     {
       
   183         delete iControlsConfig;
       
   184         iControlsConfig = NULL;
       
   185     }
       
   186 
       
   187     if ( iControlsTimer )
       
   188     {
       
   189         iControlsTimer->Cancel();
       
   190         delete iControlsTimer;
       
   191         iControlsTimer = NULL;
       
   192     }
       
   193 
       
   194     iControls.ResetAndDestroy();
       
   195 
       
   196     if ( iRealOneBitmap )
       
   197     {
       
   198         delete iRealOneBitmap;
       
   199         iRealOneBitmap = NULL ;
       
   200     }
       
   201 
       
   202     if ( iVideoResourceOffset )
       
   203     {
       
   204         (CCoeEnv::Static())->DeleteResourceFile( iVideoResourceOffset );
       
   205     }
       
   206 
       
   207     if ( iMediaDetailsViewerControl )
       
   208     {
       
   209         delete iMediaDetailsViewerControl;
       
   210         iMediaDetailsViewerControl = NULL;
       
   211     }
       
   212 }
       
   213 
       
   214 // -------------------------------------------------------------------------------------------------
       
   215 // CMPXVideoPlaybackControlsController::AddFileDetailsL()
       
   216 // -------------------------------------------------------------------------------------------------
       
   217 //
       
   218 EXPORT_C void CMPXVideoPlaybackControlsController::AddFileDetailsL(
       
   219     CMPXVideoPlaybackViewFileDetails* aDetails )
       
   220 {
       
   221     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::AddFileDetailsL()"));
       
   222 
       
   223     iFileDetails = aDetails;
       
   224 
       
   225     iFileDetails->iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
       
   226 
       
   227     iControlsConfig->UpdateControlsWithFileDetailsL();
       
   228 
       
   229     ControlsListUpdatedL();
       
   230 
       
   231     //
       
   232     //  Show controls initially if this doens't have playable video track
       
   233     //
       
   234     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
   235     {
       
   236         iControls[i]->UpdateControlsWithFileDetailsL( iFileDetails );
       
   237     }
       
   238 }
       
   239 
       
   240 // -------------------------------------------------------------------------------------------------
       
   241 // CMPXVideoPlaybackControlsController::HandleEventL
       
   242 // -------------------------------------------------------------------------------------------------
       
   243 //
       
   244 EXPORT_C void CMPXVideoPlaybackControlsController::HandleEventL(
       
   245     TMPXVideoPlaybackControlCommandIds aEvent, TInt aValue )
       
   246 {
       
   247     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::HandleEventL(%d)"), aEvent);
       
   248 
       
   249     switch ( aEvent )
       
   250     {
       
   251         case EMPXControlCmdSetPosition:
       
   252         {
       
   253             MPX_DEBUG(_L("    [EMPXControlCmdSetPosition [%d]]"), aValue );
       
   254 
       
   255             PositionChangedL( (TReal)aValue / (TReal)KPbMilliMultiplier);
       
   256             break;
       
   257         }
       
   258         case EMPXControlCmdSetDuration:
       
   259         {
       
   260             MPX_DEBUG(_L("    [EMPXControlCmdSetDuration [%d]]"), aValue );
       
   261 
       
   262             DurationChangedL( (TReal)aValue / (TReal)KPbMilliMultiplier );
       
   263             break;
       
   264         }
       
   265         case EMPXControlCmdStateChanged:
       
   266         {
       
   267             MPX_DEBUG(_L("    [EMPXControlCmdStateChanged]"));
       
   268 
       
   269             HandleStateChange( (TMPXPlaybackState)aValue );
       
   270             break;
       
   271         }
       
   272         case EMPXControlCmdToggleVisibility:
       
   273         {
       
   274             MPX_DEBUG(_L("    [EMPXControlCmdToggleVisibility]"));
       
   275 
       
   276             ToggleVisibility();
       
   277             break;
       
   278         }
       
   279         case EMPXControlCmdSetVolume:
       
   280         {
       
   281             MPX_DEBUG(_L("    [EMPXControlCmdSetVolume [%d]]"), aValue );
       
   282             VolumeChanged( aValue );
       
   283             break;
       
   284         }
       
   285         case EMPXControlCmdSetAspectRatio:
       
   286         {
       
   287             MPX_DEBUG(_L("    [EMPXControlCmdSetAspectRatio %d]"), aValue);
       
   288             AspectRatioChanged( aValue );
       
   289             break;
       
   290         }
       
   291         case EMPXControlCmdSetDownloadSize:
       
   292         {
       
   293             MPX_DEBUG(_L("    [EMPXControlCmdSetDownloadSize [%d]]"), aValue );
       
   294             SetDownloadSize( aValue );
       
   295             break;
       
   296         }
       
   297         case EMPXControlCmdDownloadUpdated:
       
   298         {
       
   299             MPX_DEBUG(_L("    [EMPXControlCmdDownloadUpdated [%d]]"), aValue );
       
   300             UpdateDownloadPosition( aValue );
       
   301             break;
       
   302         }
       
   303         case EMPXControlCmdDownloadComplete:
       
   304         {
       
   305             MPX_DEBUG(_L("    [EMPXControlCmdDownloadComplete [%d]]"), aValue);
       
   306             UpdateDownloadPosition( aValue );
       
   307             break;
       
   308         }
       
   309         case EMPXControlCmdSetDownloadPaused:
       
   310         case EMPXControlCmdClearDownloadPaused:
       
   311         {
       
   312             iControlsConfig->UpdateControlListL( aEvent );
       
   313             ControlsListUpdatedL();
       
   314             break;
       
   315         }
       
   316         case EMPXControlCmdTvOutConnected:
       
   317         {
       
   318             MPX_DEBUG(_L("    [EMPXControlCmdTvOutConnected]"));
       
   319             HandleTvOutEventL( ETrue, aEvent, aValue );
       
   320             break;
       
   321         }
       
   322         case EMPXControlCmdTvOutDisconnected:
       
   323         {
       
   324             MPX_DEBUG(_L("    [EMPXControlCmdTvOutDisConnected]"));
       
   325             HandleTvOutEventL( EFalse, aEvent, aValue );
       
   326             break;
       
   327         }
       
   328         case EMPXControlCmdHandleBackgroundEvent:
       
   329         {
       
   330             MPX_DEBUG(_L("    [EMPXControlCmdHandleBackgroundEvent]"));
       
   331 
       
   332             ResetDisappearingTimers( EMPXTimerReset );
       
   333 
       
   334             for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
   335             {
       
   336                 iControls[i]->ResetControl();
       
   337             }
       
   338 
       
   339             break;
       
   340         }
       
   341         case EMPXControlCmdHandleErrors:
       
   342         {
       
   343             MPX_DEBUG(_L("    [EMPXControlCmdHandleErrors]"));
       
   344             HandleErrors();
       
   345             break;
       
   346         }
       
   347         case EMPXControlCmdShowControls:
       
   348         {
       
   349             MPX_DEBUG(_L("    [EMPXControlCmdShowControls]"));
       
   350             ShowControls();
       
   351             break;
       
   352         }
       
   353         case EMPXControlCmdHideControls:
       
   354         {
       
   355             MPX_DEBUG(_L("    [EMPXControlCmdHideControls]"));
       
   356             HideAllControls();
       
   357             break;
       
   358         }
       
   359         case EMPXControlCmdSoftKeyPressed:
       
   360         {
       
   361             HandleSoftKeyPressedL( aValue );
       
   362             break;
       
   363         }
       
   364         case EMPXControlCmdShowFileDetailsViewer:
       
   365         {
       
   366             ShowMediaDetailsViewerL();
       
   367             break;
       
   368         }
       
   369         case EMPXControlCmdCloseFileDetailsViewer:
       
   370         {
       
   371             ShowControls();
       
   372             break;
       
   373         }
       
   374         case EMPXControlCmdSurfaceCreated:
       
   375 		{
       
   376 			//
       
   377 			//  When surface is created, remove the Real One Bitmap
       
   378 			//
       
   379 			SetRealOneBitmapVisibility( EFalse );
       
   380 			break;
       
   381 		}
       
   382     }
       
   383 }
       
   384 
       
   385 // -------------------------------------------------------------------------------------------------
       
   386 // CMPXVideoPlaybackControlsController::HandleStateChange
       
   387 // -------------------------------------------------------------------------------------------------
       
   388 //
       
   389 void CMPXVideoPlaybackControlsController::HandleStateChange( TMPXPlaybackState aNewState )
       
   390 {
       
   391     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::HandleStateChange()"),
       
   392                    _L("new state = %d"), aNewState );
       
   393 
       
   394     //
       
   395     // Somehow EPbStatePlaying, EPbStatePaused gets called twice continously
       
   396     //
       
   397     if ( aNewState != iState )
       
   398     {
       
   399     	TBool hideControls( EFalse );
       
   400     	
       
   401         iState = aNewState;
       
   402 
       
   403         switch ( aNewState )
       
   404         {
       
   405             case EPbStateInitialised:
       
   406             {
       
   407                 //
       
   408                 //  remove branding control when the state is transitioned to Initialized
       
   409                 //
       
   410                 if ( iFileDetails->iPlaybackMode == EMPXVideoStreaming ||
       
   411                      iFileDetails->iPlaybackMode == EMPXVideoLiveStreaming )
       
   412                 {
       
   413                     iControlsConfig->UpdateControlListL( EMPXControlCmdPluginInitialized );
       
   414                     ControlsListUpdatedL();
       
   415                 }
       
   416 
       
   417                 break;
       
   418             }
       
   419             case EPbStatePlaying:
       
   420             {
       
   421                 if ( iFileDetails->iVideoEnabled && ! IsTvOutConnected() )
       
   422                 {
       
   423                     //
       
   424                     //  Hide controls when transitioning to Playing State
       
   425                     //
       
   426                     hideControls = ETrue;
       
   427                 }
       
   428 
       
   429                 //
       
   430                 //  Intentionally fall through
       
   431                 //
       
   432             }
       
   433             case EPbStateBuffering:
       
   434             case EPbStateNotInitialised:
       
   435             case EPbStateInitialising:
       
   436             case EPbStatePaused:
       
   437             case EPbStatePluginSeeking:
       
   438             {
       
   439                 UpdateStateOnButtonBar();
       
   440 
       
   441                 //
       
   442                 //  Show all the controls
       
   443                 //
       
   444                 if ( hideControls )
       
   445                 {
       
   446                     HideAllControls();
       
   447                 }
       
   448                 else
       
   449                 {
       
   450                 	UpdateControlsVisibility();
       
   451                 }
       
   452 
       
   453                 break;
       
   454             }
       
   455         }
       
   456     }
       
   457 }
       
   458 
       
   459 // -------------------------------------------------------------------------------------------------
       
   460 // CMPXVideoPlaybackControlsController::CreateControlsL()
       
   461 // -------------------------------------------------------------------------------------------------
       
   462 //
       
   463 void CMPXVideoPlaybackControlsController::CreateControlsL()
       
   464 {
       
   465     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::CreateControlsL()"));
       
   466 
       
   467     //
       
   468     //  Clean up old controls list and controls
       
   469     //
       
   470     iControls.ResetAndDestroy();
       
   471 
       
   472     RArray<TMPXVideoPlaybackControls>& controlList = iControlsConfig->ControlList();
       
   473 
       
   474     //
       
   475     //  Iterate thru the controls list from view-config
       
   476     //  and create controls that match items in the list
       
   477     //
       
   478     for ( TInt i = 0 ; i < controlList.Count() ; i++ )
       
   479     {
       
   480         AppendControlL( controlList[i] );
       
   481     }
       
   482 
       
   483     UpdateControlsVisibility();
       
   484 }
       
   485 
       
   486 // -------------------------------------------------------------------------------------------------
       
   487 // CMPXVideoPlaybackControlsController::CreateRealOneBitmapL()
       
   488 // -------------------------------------------------------------------------------------------------
       
   489 //
       
   490 void CMPXVideoPlaybackControlsController::CreateRealOneBitmapL()
       
   491 {
       
   492     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::CreateRealOneBitmapL()"));
       
   493 
       
   494 
       
   495     TFileName iconsPath;
       
   496     LocateBitmapFileL( iconsPath );
       
   497 
       
   498     iRealOneBitmap = CreateBitmapL( iconsPath,
       
   499                                     EMbmMpxvideoplaybackcontrolsQgn_graf_realplayer_splash_01,
       
   500                                     main_mp4_pane_g1(0).LayoutLine() );
       
   501 }
       
   502 
       
   503 // -------------------------------------------------------------------------------------------------
       
   504 // CMPXVideoPlaybackControlsController::GetBitmap()
       
   505 // -------------------------------------------------------------------------------------------------
       
   506 //
       
   507 EXPORT_C CEikImage*
       
   508 CMPXVideoPlaybackControlsController::GetBitmap( TMPXVideoPlaybackControls aBitmap )
       
   509 {
       
   510     CEikImage* bitmap = NULL;
       
   511 
       
   512     switch( aBitmap )
       
   513     {
       
   514         case EMPXRealLogoBitmap:
       
   515         {
       
   516             bitmap = iRealOneBitmap;
       
   517             break;
       
   518         }
       
   519     }
       
   520 
       
   521     return bitmap;
       
   522 }
       
   523 
       
   524 // -------------------------------------------------------------------------------------------------
       
   525 // CMPXVideoPlaybackControlsController::ControlsListUpdatedL()
       
   526 // -------------------------------------------------------------------------------------------------
       
   527 //
       
   528 void CMPXVideoPlaybackControlsController::ControlsListUpdatedL()
       
   529 {
       
   530     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::ControlsListUpdatedL()"));
       
   531 
       
   532     RArray<TMPXVideoPlaybackControls>& updatedList = iControlsConfig->ControlList();
       
   533 
       
   534     //
       
   535     //  Create a copy of the control list
       
   536     //
       
   537     TMPXVideoPlaybackControls* data = (TMPXVideoPlaybackControls*)
       
   538         User::AllocL( updatedList.Count() * sizeof( TMPXVideoPlaybackControls ) );
       
   539 
       
   540     Mem::Copy( data, &(updatedList[0]), updatedList.Count()* sizeof(TMPXVideoPlaybackControls));
       
   541 
       
   542     RArray<TMPXVideoPlaybackControls> myList( sizeof(TMPXVideoPlaybackControls),
       
   543                                               data,
       
   544                                               updatedList.Count() );
       
   545 
       
   546     CleanupClosePushL( myList );
       
   547 
       
   548     TInt controlCount = iControls.Count();
       
   549 
       
   550     TInt i = 0 ;
       
   551     TInt index = KErrNotFound;
       
   552 
       
   553 
       
   554     for ( TInt iCnt = 0 ; iCnt < controlCount ; iCnt++ )
       
   555     {
       
   556         index = myList.Find( iControls[i]->ControlIndex() );
       
   557 
       
   558         if ( index == KErrNotFound )
       
   559         {
       
   560             //
       
   561             //  Delete control since it doesn't exist in new list
       
   562             //
       
   563             delete iControls[i];
       
   564             iControls.Delete( i );
       
   565         }
       
   566         else
       
   567         {
       
   568             //
       
   569             //  Control exists in new list.
       
   570             //  Remove it from the new list.
       
   571             //
       
   572             myList.Remove( index );
       
   573             i++;
       
   574         }
       
   575     }
       
   576 
       
   577     //
       
   578     //  The updated list will contain added controls only
       
   579     //
       
   580     for ( TInt j = 0 ; j < myList.Count() ; j++ )
       
   581     {
       
   582         AppendControlL( myList[j] );
       
   583     }
       
   584 
       
   585     UpdateControlsVisibility();
       
   586 
       
   587     CleanupStack::PopAndDestroy();
       
   588 }
       
   589 
       
   590 // -------------------------------------------------------------------------------------------------
       
   591 // CMPXVideoPlaybackControlsController::AppendControlL()
       
   592 // -------------------------------------------------------------------------------------------------
       
   593 //
       
   594 void CMPXVideoPlaybackControlsController::AppendControlL( TMPXVideoPlaybackControls aControlIndex )
       
   595 {
       
   596     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::AppendControlL()"),
       
   597                    _L("control index = %d"), aControlIndex );
       
   598 
       
   599     TUint properties = 0;
       
   600 
       
   601     iControlsPolicy->SetControlProperties( aControlIndex, properties, iFileDetails );
       
   602 
       
   603     TFileName iconsPath;
       
   604     LocateBitmapFileL( iconsPath );
       
   605 
       
   606     switch ( aControlIndex )
       
   607     {
       
   608         case EMPXSoftkeyBack:
       
   609         {
       
   610             CreateFakeSoftKeyL( R_MPX_VIDEO_PLAYBACK_CONTROLS_FAKE_SK_BACK,
       
   611                                 ETrue,
       
   612                                 aControlIndex,
       
   613                                 properties );
       
   614             break;
       
   615         }
       
   616         case EMPXButtonBar:
       
   617         {
       
   618             TAknLayoutRect buttonBarPaneRect;
       
   619             buttonBarPaneRect.LayoutRect(
       
   620                 iRect,
       
   621                 AknLayoutScalable_Avkon::area_side_right_pane( 0 ).LayoutLine() );
       
   622 
       
   623             TAknLayoutRect buttonBarRect;
       
   624             buttonBarRect.LayoutRect( buttonBarPaneRect.Rect(),
       
   625                                       grid_sctrl_middle_pane( 0 ).LayoutLine() );
       
   626 
       
   627             CMPXVideoPlaybackButtonBar* buttonBar =
       
   628                 CMPXVideoPlaybackButtonBar::NewL( this, buttonBarRect.Rect() );
       
   629 
       
   630             CleanupStack::PushL( buttonBar );
       
   631 
       
   632             CMPXVideoPlaybackControl* control =
       
   633                 CMPXVideoPlaybackControl::NewL( this,
       
   634                                                 buttonBar,
       
   635                                                 buttonBarRect.Rect(),
       
   636                                                 aControlIndex,
       
   637                                                 properties );
       
   638 
       
   639             CleanupStack::PushL( control );
       
   640 
       
   641             iControls.AppendL( control );
       
   642 
       
   643             CleanupStack::Pop( 2 ); // buttonBar, control
       
   644 
       
   645             break;
       
   646         }
       
   647         case EMPXVolumeBar:
       
   648         {
       
   649             TAknLayoutRect volumeLayoutRect;
       
   650             volumeLayoutRect.LayoutRect( iRect, popup_slider_window_cp01().LayoutLine() );
       
   651 
       
   652             TRect temp = volumeLayoutRect.Rect();
       
   653             TRect rect = temp;
       
   654             rect.iTl.iY = temp.iTl.iY + temp.Height() / 10;
       
   655             rect.iBr.iY = temp.iTl.iY + temp.Height() / 10 * 9;
       
   656 
       
   657             CMPXVideoPlaybackVolumeBar* volBar = CMPXVideoPlaybackVolumeBar::NewL( this, rect );
       
   658 
       
   659             CleanupStack::PushL( volBar );
       
   660 
       
   661             CMPXVideoPlaybackControl* control = CMPXVideoPlaybackControl::NewL( this,
       
   662                                                                                 volBar,
       
   663                                                                                 rect,
       
   664                                                                                 aControlIndex,
       
   665                                                                                 properties );
       
   666 
       
   667             CleanupStack::PushL( control );
       
   668 
       
   669             iControls.AppendL( control );
       
   670 
       
   671             CleanupStack::Pop( 2 ); // volBar, control
       
   672 
       
   673             break;
       
   674         }
       
   675         case EMPXProgressBar:
       
   676         {
       
   677             TAknLayoutRect progressPaneRect;
       
   678             progressPaneRect.LayoutRect( iRect, mp4_progress_pane(0).LayoutLine() );
       
   679 
       
   680             TRect touchPaneRect( progressPaneRect.Rect().iTl.iX,
       
   681                                  progressPaneRect.Rect().iTl.iY,
       
   682                                  progressPaneRect.Rect().iBr.iX,
       
   683                                  iRect.Height() );
       
   684 
       
   685             CMPXVideoPlaybackProgressBar* progBar =
       
   686                 CMPXVideoPlaybackProgressBar::NewL( this, touchPaneRect );
       
   687 
       
   688             CleanupStack::PushL( progBar );
       
   689 
       
   690             CMPXVideoPlaybackControl* control = CMPXVideoPlaybackControl::NewL( this,
       
   691                                                                                 progBar,
       
   692                                                                                 touchPaneRect,
       
   693                                                                                 aControlIndex,
       
   694                                                                                 properties );
       
   695 
       
   696             CleanupStack::PushL( control );
       
   697 
       
   698             iControls.AppendL( control );
       
   699 
       
   700             CleanupStack::Pop( 2 ); // progBar, control
       
   701 
       
   702             break;
       
   703         }
       
   704         case EMPXSoftkeyDetails:
       
   705         {
       
   706             CreateFakeSoftKeyL( R_MPX_VIDEO_PLAYBACK_CONTROLS_FAKE_SK_DETAILS,
       
   707                                 EFalse,
       
   708                                 aControlIndex,
       
   709                                 properties );
       
   710             break;
       
   711         }
       
   712         case EMPXBufferingLabel:
       
   713         {
       
   714             CreateTextLabelWithSpecificLayoutL( R_MPX_LOADING,
       
   715                                                 aControlIndex,
       
   716                                                 properties,
       
   717                                                 main_mp4_pane_t3(0) );
       
   718             break;
       
   719         }
       
   720         case EMPXTitleLabel:
       
   721         {
       
   722             CreateTitleControlL( aControlIndex, properties );
       
   723 
       
   724             break;
       
   725         }
       
   726         case EMPXArtistLabel:
       
   727         {
       
   728             if ( iFileDetails->iArtist && iFileDetails->iArtist->Length() )
       
   729             {
       
   730                 CEikLabel* label = CreateTextLabelL( *(iFileDetails->iArtist) );
       
   731 
       
   732                 CleanupStack::PushL( label );
       
   733 
       
   734                 AknLayoutUtils::LayoutLabel( label,
       
   735                                              iRect,
       
   736                                              main_mp3_pane_t3().LayoutLine());
       
   737 
       
   738                 label->OverrideColorL( EColorLabelText, KRgbWhite );
       
   739                 label->OverrideColorL( EColorLabelTextEmphasis, KRgbWhite );
       
   740 
       
   741                 CMPXVideoPlaybackControl* control =
       
   742                     CMPXVideoPlaybackControl::NewL( this,
       
   743                                                     label,
       
   744                                                     label->Rect(),
       
   745                                                     aControlIndex,
       
   746                                                     properties );
       
   747 
       
   748                 CleanupStack::PushL( control );
       
   749 
       
   750                 iControls.AppendL( control );
       
   751 
       
   752                 CleanupStack::Pop( 2 ); // label, control
       
   753             }
       
   754             break;
       
   755         }
       
   756         case EMPXRealAudioBitmap:
       
   757         {
       
   758             CreateAudioOnlyBitmapL( iconsPath,
       
   759                                     EMbmMpxvideoplaybackcontrolsQgn_menu_rp,
       
   760                                     EMbmMpxvideoplaybackcontrolsQgn_menu_rp_mask,
       
   761                                     aControlIndex,
       
   762                                     main_mp3_pane_g3(0).LayoutLine(),
       
   763                                     properties );
       
   764 
       
   765             break;
       
   766         }
       
   767         case EMPXSoundBitmap:
       
   768         {
       
   769             CreateAudioOnlyBitmapL( iconsPath,
       
   770                                     EMbmMpxvideoplaybackcontrolsQgn_indi_onimage_audio,
       
   771                                     EMbmMpxvideoplaybackcontrolsQgn_indi_onimage_audio_mask,
       
   772                                     aControlIndex,
       
   773                                     main_mp3_pane_g4(0).LayoutLine(),
       
   774                                     properties );
       
   775 
       
   776             break;
       
   777         }
       
   778         case EMPXNoVideoBitmap:
       
   779         {
       
   780             CreateAudioOnlyBitmapL( iconsPath,
       
   781                                     EMbmMpxvideoplaybackcontrolsQgn_prop_video_corrupted,
       
   782                                     EMbmMpxvideoplaybackcontrolsQgn_prop_video_corrupted_mask,
       
   783                                     aControlIndex,
       
   784                                     main_mp3_pane_g4(0).LayoutLine(),
       
   785                                     properties );
       
   786 
       
   787             break;
       
   788         }
       
   789         case EMPXDownloadPausedIcon:
       
   790         {
       
   791             //
       
   792             //  Not added to the control list since it will always be visible
       
   793             //
       
   794             CEikImage* dlPausedBitmap =
       
   795                 CreateImageL( iconsPath,
       
   796                               EMbmMpxvideoplaybackcontrolsQgn_indi_mp_ongoing_interrupt,
       
   797                               EMbmMpxvideoplaybackcontrolsQgn_indi_mp_ongoing_interrupt_mask );
       
   798 
       
   799             CleanupStack::PushL( dlPausedBitmap );
       
   800 
       
   801             AknLayoutUtils::LayoutImage( dlPausedBitmap,
       
   802                                          iRect,
       
   803                                          AknLayoutScalable_Apps::main_mp4_pane_g6(0) );
       
   804 
       
   805             CMPXVideoPlaybackControl* control =
       
   806                 CMPXVideoPlaybackControlPdl::NewL( this,
       
   807                                                    dlPausedBitmap,
       
   808                                                    dlPausedBitmap->Rect(),
       
   809                                                    aControlIndex,
       
   810                                                    properties );
       
   811 
       
   812             CleanupStack::PushL( control );
       
   813 
       
   814             iControls.AppendL( control );
       
   815 
       
   816             CleanupStack::Pop( 2 ); // dlPausedBitmap, control
       
   817 
       
   818             break;
       
   819         }
       
   820         case EMPXAspectRatioIcon:
       
   821         {
       
   822 
       
   823             TAknLayoutRect aspectRatioPaneRect;
       
   824             aspectRatioPaneRect.LayoutRect( iRect,
       
   825                                             main_mp4_pane_g5(0).LayoutLine() );
       
   826 
       
   827             //
       
   828             // Set the touchable area for aspect ratio
       
   829             //
       
   830             TRect touchableArea = TRect( aspectRatioPaneRect.Rect().iTl.iX - 25,
       
   831                                          aspectRatioPaneRect.Rect().iTl.iY - 10,
       
   832                                          aspectRatioPaneRect.Rect().iBr.iX + 15,
       
   833                                          aspectRatioPaneRect.Rect().iBr.iY + 30 );
       
   834 
       
   835             CMPXVideoPlaybackAspectRatioIcon* aspectRatioIcon =
       
   836                 CMPXVideoPlaybackAspectRatioIcon::NewL( this, touchableArea );
       
   837 
       
   838             CleanupStack::PushL( aspectRatioIcon );
       
   839 
       
   840             CMPXVideoPlaybackControl* control =
       
   841                 CMPXVideoPlaybackControl::NewL( this,
       
   842                                                 aspectRatioIcon,
       
   843                                                 touchableArea,
       
   844                                                 aControlIndex,
       
   845                                                 properties );
       
   846 
       
   847             CleanupStack::PushL( control );
       
   848 
       
   849             iControls.AppendL( control );
       
   850 
       
   851             CleanupStack::Pop( 2 ); // aspectRatioIcon, control
       
   852 
       
   853             break;
       
   854         }
       
   855         case EMPXBrandingAnimation:
       
   856         {
       
   857             TAknLayoutRect brandingPaneRect;
       
   858             brandingPaneRect.LayoutRect( iRect, main_mp4_pane_g1(0).LayoutLine() );
       
   859 
       
   860             CMPXVideoPlaybackBrandingAnimation* brandingAnimation =
       
   861                 CMPXVideoPlaybackBrandingAnimation::NewL( this,
       
   862                                                           brandingPaneRect.Rect(),
       
   863                                                           iFileDetails->iRNFormat );
       
   864 
       
   865             CleanupStack::PushL( brandingAnimation );
       
   866 
       
   867             CMPXVideoPlaybackControl* control =
       
   868                 CMPXVideoPlaybackControl::NewL( this,
       
   869                                                 brandingAnimation,
       
   870                                                 brandingPaneRect.Rect(),
       
   871                                                 aControlIndex,
       
   872                                                 properties );
       
   873 
       
   874             CleanupStack::PushL( control );
       
   875 
       
   876             iControls.AppendL( control );
       
   877 
       
   878             CleanupStack::Pop( 2 ); // brandingAnimation, control
       
   879 
       
   880             break;
       
   881         }
       
   882         case EMPXVideoPausedIcon:
       
   883         {
       
   884             CEikImage* pausedBitmap =
       
   885                 CreateImageL( iconsPath,
       
   886                               EMbmMpxvideoplaybackcontrolsQgn_prop_image_tb_pause,
       
   887                               EMbmMpxvideoplaybackcontrolsQgn_prop_image_tb_pause_mask );
       
   888 
       
   889             CleanupStack::PushL( pausedBitmap );
       
   890 
       
   891             AknLayoutUtils::LayoutImage( pausedBitmap,
       
   892                                          iRect,
       
   893                                          AknLayoutScalable_Apps::main_mp4_pane_g4(0) );
       
   894 
       
   895             CMPXVideoPlaybackControl* control =
       
   896                 CMPXVideoPlaybackControl::NewL( this,
       
   897                                                 pausedBitmap,
       
   898                                                 pausedBitmap->Rect(),
       
   899                                                 aControlIndex,
       
   900                                                 properties );
       
   901 
       
   902             CleanupStack::PushL( control );
       
   903             iControls.AppendL( control );
       
   904             CleanupStack::Pop( 2 ); // pausedBitmap, control
       
   905             break;
       
   906         }
       
   907     }
       
   908 }
       
   909 
       
   910 // -------------------------------------------------------------------------------------------------
       
   911 //   CMPXVideoPlaybackControlsController::CreateTitleControlL()
       
   912 // -------------------------------------------------------------------------------------------------
       
   913 //
       
   914 void CMPXVideoPlaybackControlsController::CreateTitleControlL(
       
   915         TMPXVideoPlaybackControls aControlIndex,
       
   916         TUint aProperties )
       
   917 {
       
   918     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::CreateTitleControlL()"));
       
   919 
       
   920     HBufC* displayedTitle;
       
   921 
       
   922     //
       
   923     //  If Title exists, use the title.  If title doesn't exitst, use the filename
       
   924     //  excecpt when streaming functionality is hidden
       
   925     //
       
   926     if ( iFileDetails->iTitle )
       
   927 
       
   928     {
       
   929         displayedTitle = HBufC::NewL( iFileDetails->iTitle->Length() );
       
   930         TPtr tempTitle( displayedTitle->Des() );
       
   931         tempTitle.Append( iFileDetails->iTitle->Des() );
       
   932     }
       
   933     else
       
   934     {
       
   935         //
       
   936         //  If title doesn't exitst, use the filename
       
   937         //  excecpt when streaming functionality is hidden
       
   938         //
       
   939         //                 ! ( iFileDetails->iMode == EStreaming &&
       
   940         //                     iFileDetails->iHideStreamingFunctionality ) )
       
   941         //
       
   942         TParse parse;
       
   943         parse.Set( iFileDetails->iClipName->Des(), NULL, NULL);
       
   944         displayedTitle = parse.Name().AllocL();
       
   945     }
       
   946 
       
   947     TAknTextComponentLayout layout = main_mp3_pane_t6();
       
   948 
       
   949     if ( iFileDetails->iArtist )
       
   950     {
       
   951         layout = main_mp3_pane_t2();
       
   952     }
       
   953 
       
   954     CEikLabel* label = CreateTextLabelL( *displayedTitle );
       
   955 
       
   956     CleanupStack::PushL( label );
       
   957 
       
   958     delete displayedTitle;
       
   959 
       
   960     AknLayoutUtils::LayoutLabel( label,
       
   961                                  iRect,
       
   962                                  layout.LayoutLine());
       
   963 
       
   964     label->OverrideColorL( EColorLabelText, KRgbWhite );
       
   965     label->OverrideColorL( EColorLabelTextEmphasis, KRgbWhite );
       
   966 
       
   967     CMPXVideoPlaybackControl* control = CMPXVideoPlaybackControl::NewL( this,
       
   968                                                                         label,
       
   969                                                                         label->Rect(),
       
   970                                                                         aControlIndex,
       
   971                                                                         aProperties );
       
   972 
       
   973     iControls.AppendL( control );
       
   974 
       
   975     CleanupStack::Pop( label );
       
   976 }
       
   977 
       
   978 // -------------------------------------------------------------------------------------------------
       
   979 //   CMPXVideoPlaybackControlsController::CreateAudioOnlyBitmapL()
       
   980 // -------------------------------------------------------------------------------------------------
       
   981 //
       
   982 void CMPXVideoPlaybackControlsController::CreateAudioOnlyBitmapL(
       
   983         TFileName& aIconsPath,
       
   984         TInt aBitmapIndex,
       
   985         TInt aBitmapMaskIndex,
       
   986         TMPXVideoPlaybackControls aControlIndex,
       
   987         const TAknWindowLineLayout& aLayout,
       
   988         TUint aProperties )
       
   989 {
       
   990     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::CreateAudioOnlyBitmapL()"));
       
   991 
       
   992     CEikImage* audioOnlyBitmap = CreateImageL( aIconsPath, aBitmapIndex, aBitmapMaskIndex );
       
   993 
       
   994     CleanupStack::PushL( audioOnlyBitmap );
       
   995 
       
   996     AknLayoutUtils::LayoutImage( audioOnlyBitmap, iRect, aLayout );
       
   997 
       
   998     CMPXVideoPlaybackControl* control =
       
   999         CMPXVideoPlaybackControl::NewL( this,
       
  1000                                         audioOnlyBitmap,
       
  1001                                         audioOnlyBitmap->Rect(),
       
  1002                                         aControlIndex,
       
  1003                                         aProperties );
       
  1004 
       
  1005     iControls.AppendL( control );
       
  1006 
       
  1007     CleanupStack::Pop( audioOnlyBitmap );
       
  1008 }
       
  1009 
       
  1010 // -------------------------------------------------------------------------------------------------
       
  1011 // CMPXVideoPlaybackControlsController::CreateFakeSoftKeyL()
       
  1012 // -------------------------------------------------------------------------------------------------
       
  1013 //
       
  1014 void CMPXVideoPlaybackControlsController::CreateFakeSoftKeyL(
       
  1015     TInt aResource,
       
  1016     TBool aTop,
       
  1017     TMPXVideoPlaybackControls aControlIndex,
       
  1018     TUint aProperties )
       
  1019 {
       
  1020     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::CreateFakeSoftKeyL"));
       
  1021 
       
  1022     HBufC* text = StringLoader::LoadLC( aResource );
       
  1023     CEikLabel* label = CreateTextLabelL( text->Des() );
       
  1024     CleanupStack::PopAndDestroy( text );
       
  1025 
       
  1026     CleanupStack::PushL( label );
       
  1027 
       
  1028     TAknTextComponentLayout SKLayout;
       
  1029     TAknWindowComponentLayout softkeyPane;
       
  1030     TRect skRect;
       
  1031 
       
  1032     if ( aTop )
       
  1033     {
       
  1034         SKLayout = main_mp4_pane_t1(0);
       
  1035         skRect.iTl.iX = iRect.iBr.iX-iRect.iBr.iX/5;
       
  1036         skRect.iTl.iY = iRect.iTl.iY;
       
  1037         skRect.iBr.iX = iRect.iBr.iX;
       
  1038         skRect.iBr.iY = iRect.iBr.iY/5;
       
  1039     }
       
  1040     else
       
  1041     {
       
  1042         SKLayout = main_mp4_pane_t2(0);
       
  1043         skRect.iTl.iX = iRect.iBr.iX-iRect.iBr.iX/5;
       
  1044         skRect.iTl.iY = iRect.iBr.iY-iRect.iBr.iY/5;
       
  1045         skRect.iBr.iX = iRect.iBr.iX;
       
  1046         skRect.iBr.iY = iRect.iBr.iY;
       
  1047     }
       
  1048 
       
  1049     AknLayoutUtils::LayoutLabel( label,
       
  1050                                  iRect,
       
  1051                                  SKLayout.LayoutLine() );
       
  1052 
       
  1053     if ( AknLayoutUtils::PenEnabled() )
       
  1054     {
       
  1055         label->SetAlignment( EHCenterVCenter );
       
  1056     }
       
  1057     else
       
  1058     {
       
  1059         if ( aTop )
       
  1060         {
       
  1061             //Default alignment is EHRightVTop
       
  1062         }
       
  1063         else
       
  1064         {
       
  1065             label->SetAlignment( EHRightVBottom );
       
  1066         }
       
  1067     }
       
  1068 
       
  1069     CMPXVideoPlaybackControl* control = CMPXVideoPlaybackControl::NewL( this,
       
  1070                                                                         label,
       
  1071                                                                         skRect,
       
  1072                                                                         aControlIndex,
       
  1073                                                                         aProperties );
       
  1074 
       
  1075     iControls.AppendL( control );
       
  1076 
       
  1077     CleanupStack::Pop( label );
       
  1078 }
       
  1079 
       
  1080 // -------------------------------------------------------------------------------------------------
       
  1081 // CMPXVideoPlaybackControlsController::CreateTextLabelWithSpecificLayoutL()
       
  1082 // -------------------------------------------------------------------------------------------------
       
  1083 //
       
  1084 void CMPXVideoPlaybackControlsController::CreateTextLabelWithSpecificLayoutL(
       
  1085     TInt aResource,
       
  1086     TMPXVideoPlaybackControls aControlIndex,
       
  1087     TUint aProperties,
       
  1088     TAknTextComponentLayout aLayout )
       
  1089 {
       
  1090     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::CreateTextLabelWithSpecificLayoutL()"));
       
  1091 
       
  1092     HBufC* text = StringLoader::LoadLC( aResource );
       
  1093     CEikLabel* label = CreateTextLabelL( text->Des() );
       
  1094     CleanupStack::PopAndDestroy( text );
       
  1095 
       
  1096     CleanupStack::PushL( label );
       
  1097 
       
  1098     AknLayoutUtils::LayoutLabel( label,
       
  1099                                  iRect,
       
  1100                                  aLayout.LayoutLine());
       
  1101 
       
  1102     CMPXVideoPlaybackControl* control = CMPXVideoPlaybackControl::NewL( this,
       
  1103                                                                         label,
       
  1104                                                                         label->Rect(),
       
  1105                                                                         aControlIndex,
       
  1106                                                                         aProperties );
       
  1107 
       
  1108     iControls.AppendL( control );
       
  1109 
       
  1110     CleanupStack::Pop( label );
       
  1111 }
       
  1112 
       
  1113 // -------------------------------------------------------------------------------------------------
       
  1114 // CMPXVideoPlaybackControlsController::CreateTextLabelL()
       
  1115 // -------------------------------------------------------------------------------------------------
       
  1116 //
       
  1117 CEikLabel* CMPXVideoPlaybackControlsController::CreateTextLabelL( const TDesC& aText )
       
  1118 {
       
  1119     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::CreateTextLabelL()"));
       
  1120 
       
  1121     CEikLabel* label = new (ELeave) CEikLabel;
       
  1122     label->SetContainerWindowL( *iContainer );
       
  1123     label->SetTextL( aText );
       
  1124     label->MakeVisible( EFalse );
       
  1125 
       
  1126     return label;
       
  1127 }
       
  1128 
       
  1129 // -------------------------------------------------------------------------------------------------
       
  1130 // CMPXVideoPlaybackControlsController::ToggleVisibility()
       
  1131 // -------------------------------------------------------------------------------------------------
       
  1132 //
       
  1133 void CMPXVideoPlaybackControlsController::ToggleVisibility()
       
  1134 {
       
  1135     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::ToggleVisibility()"));
       
  1136 
       
  1137     //
       
  1138     //  Toggle visibility only if:
       
  1139     //  (a) MediaDetailsViewer is not visble
       
  1140     //  (b) TV-Out is not connected and
       
  1141     //  (c) we are in playing or paused state
       
  1142     //
       
  1143     if ( ! IsMediaDetailsViewerVisible() &&
       
  1144          ! IsTvOutConnected() &&
       
  1145          ( iState == EPbStatePlaying || iState == EPbStatePaused ) )
       
  1146     {
       
  1147         //
       
  1148         //  Controls will remain visible for audio only clips
       
  1149         //
       
  1150         if ( iFileDetails->iVideoEnabled )
       
  1151         {
       
  1152 #ifdef RD_TACTILE_FEEDBACK
       
  1153             if ( iFeedback )
       
  1154             {
       
  1155                 MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::ToggleVisibility() tactile"));
       
  1156                 iFeedback->InstantFeedback( ETouchFeedbackBasic );
       
  1157             }
       
  1158 #endif //RD_TACTILE_FEEDBACK
       
  1159 
       
  1160             if ( IsVisible() )
       
  1161             {
       
  1162                 HideAllControls();
       
  1163             }
       
  1164             else
       
  1165             {
       
  1166                 ShowControls();
       
  1167             }
       
  1168         }
       
  1169     }
       
  1170 }
       
  1171 
       
  1172 // -------------------------------------------------------------------------------------------------
       
  1173 // CMPXVideoPlaybackControlsController::ResetDisappearingTimers()
       
  1174 // -------------------------------------------------------------------------------------------------
       
  1175 //
       
  1176 void CMPXVideoPlaybackControlsController::ResetDisappearingTimers( TMPXTimerAction aTimerAction )
       
  1177 {
       
  1178     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::ResetDisappearingTimers()"));
       
  1179 
       
  1180     if ( iControlsTimer->IsActive() )
       
  1181     {
       
  1182         iControlsTimer->Cancel();
       
  1183     }
       
  1184 
       
  1185     if ( aTimerAction == EMPXTimerReset && iState == EPbStatePlaying )
       
  1186     {
       
  1187         //
       
  1188         //  Do not start the time for Audio only clips or TV-Out is connected
       
  1189         //
       
  1190         if ( iFileDetails->iVideoEnabled && ! IsTvOutConnected() )
       
  1191         {
       
  1192             MPX_DEBUG(_L("    Starting Controls Timer"));
       
  1193 
       
  1194             iControlsTimer->Start(
       
  1195                 KMPXControlsTimeOut,
       
  1196                 0,
       
  1197                 TCallBack( CMPXVideoPlaybackControlsController::HandleControlsTimeout, this ) );
       
  1198         }
       
  1199     }
       
  1200 }
       
  1201 
       
  1202 // -------------------------------------------------------------------------------------------------
       
  1203 //   CMPXVideoPlaybackControlsController::HandleControlsTimeout
       
  1204 // -------------------------------------------------------------------------------------------------
       
  1205 //
       
  1206 TInt CMPXVideoPlaybackControlsController::HandleControlsTimeout( TAny* aPtr )
       
  1207 {
       
  1208     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::HandleControlsTimeout()"));
       
  1209 
       
  1210     static_cast<CMPXVideoPlaybackControlsController*>(aPtr)->HideAllControls();
       
  1211 
       
  1212     return KErrNone;
       
  1213 }
       
  1214 
       
  1215 // -------------------------------------------------------------------------------------------------
       
  1216 //   CMPXVideoPlaybackControlsController::HideAllControls()
       
  1217 // -------------------------------------------------------------------------------------------------
       
  1218 //
       
  1219 void CMPXVideoPlaybackControlsController::HideAllControls()
       
  1220 {
       
  1221     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::HideAllControls()"));
       
  1222 
       
  1223     ResetDisappearingTimers( EMPXTimerCancel );
       
  1224 
       
  1225     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1226     {
       
  1227         iControls[i]->MakeVisible( EFalse );
       
  1228     }
       
  1229 }
       
  1230 
       
  1231 // -------------------------------------------------------------------------------------------------
       
  1232 //   CMPXVideoPlaybackControlsController::ShowControls()
       
  1233 // -------------------------------------------------------------------------------------------------
       
  1234 //
       
  1235 void CMPXVideoPlaybackControlsController::ShowControls()
       
  1236 {
       
  1237     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::ShowControls() iState = %d"), iState);
       
  1238 
       
  1239     CloseMediaDetailsViewer();
       
  1240 
       
  1241     ResetDisappearingTimers( EMPXTimerReset );
       
  1242 
       
  1243     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1244     {
       
  1245         iControls[i]->SetVisibility( iState );
       
  1246     }
       
  1247 }
       
  1248 
       
  1249 // -------------------------------------------------------------------------------------------------
       
  1250 //   CMPXVideoPlaybackControlsController::IsVisible()
       
  1251 // -------------------------------------------------------------------------------------------------
       
  1252 //
       
  1253 TBool CMPXVideoPlaybackControlsController::IsVisible()
       
  1254 {
       
  1255     TBool visible = EFalse;
       
  1256 
       
  1257     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1258     {
       
  1259         if ( iControls[i]->ControlIndex() == EMPXSoftkeyBack )
       
  1260         {
       
  1261             if ( iControls[i]->IsVisible() )
       
  1262             {
       
  1263                 visible = ETrue;
       
  1264             }
       
  1265 
       
  1266             break;
       
  1267         }
       
  1268     }
       
  1269 
       
  1270     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::IsVisible() [%d]"), visible);
       
  1271 
       
  1272     return visible;
       
  1273 }
       
  1274 
       
  1275 // -------------------------------------------------------------------------------------------------
       
  1276 //   CMPXVideoPlaybackControlsController::UpdateControlsVisibility()
       
  1277 // -------------------------------------------------------------------------------------------------
       
  1278 //
       
  1279 void CMPXVideoPlaybackControlsController::UpdateControlsVisibility()
       
  1280 {
       
  1281     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::UpdateControlsVisibility()"));
       
  1282 
       
  1283     HideAllControls();
       
  1284     ShowControls();
       
  1285 }
       
  1286 
       
  1287 // -------------------------------------------------------------------------------------------------
       
  1288 //   CMPXVideoPlaybackControlsController::HandleCommandL()
       
  1289 // -------------------------------------------------------------------------------------------------
       
  1290 //
       
  1291 void CMPXVideoPlaybackControlsController::HandleCommandL( TInt aCommand, TInt aValue )
       
  1292 {
       
  1293     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::HandleCommandL(%d)"), aCommand);
       
  1294 
       
  1295     iContainer->HandleCommandL( aCommand, aValue );
       
  1296 }
       
  1297 
       
  1298 // -------------------------------------------------------------------------------------------------
       
  1299 //   CMPXVideoPlaybackControlsController::VolumeChanged()
       
  1300 // -------------------------------------------------------------------------------------------------
       
  1301 //
       
  1302 void CMPXVideoPlaybackControlsController::VolumeChanged( TInt aVolume )
       
  1303 {
       
  1304     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::VolumeChanged() [%d]"), aVolume);
       
  1305 
       
  1306     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1307     {
       
  1308         if ( iControls[i]->VolumeChanged( aVolume ) )
       
  1309         {
       
  1310             break;
       
  1311         }
       
  1312     }
       
  1313 
       
  1314     ShowControls();
       
  1315 }
       
  1316 
       
  1317 // -------------------------------------------------------------------------------------------------
       
  1318 //   CMPXVideoPlaybackControlsController::DurationChangedL()
       
  1319 // -------------------------------------------------------------------------------------------------
       
  1320 //
       
  1321 void CMPXVideoPlaybackControlsController::DurationChangedL( TInt aDuration )
       
  1322 {
       
  1323     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::DurationChangedL() [%d]"), aDuration);
       
  1324 
       
  1325     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1326     {
       
  1327         if ( iControls[i]->DurationChangedL( aDuration ) )
       
  1328         {
       
  1329             break;
       
  1330         }
       
  1331     }
       
  1332 }
       
  1333 
       
  1334 // -------------------------------------------------------------------------------------------------
       
  1335 //   CMPXVideoPlaybackControlsController::PositionChangedL()
       
  1336 // -------------------------------------------------------------------------------------------------
       
  1337 //
       
  1338 void CMPXVideoPlaybackControlsController::PositionChangedL( TInt aPosition )
       
  1339 {
       
  1340     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::PositionChangedL() [%d]"), aPosition);
       
  1341 
       
  1342     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1343     {
       
  1344         if ( iControls[i]->PositionChangedL( aPosition ) )
       
  1345         {
       
  1346             break;
       
  1347         }
       
  1348     }
       
  1349 }
       
  1350 
       
  1351 // -------------------------------------------------------------------------------------------------
       
  1352 //   CMPXVideoPlaybackControlsController::AspectRatioChanged()
       
  1353 // -------------------------------------------------------------------------------------------------
       
  1354 //
       
  1355 void CMPXVideoPlaybackControlsController::AspectRatioChanged( TInt aAspectRatio )
       
  1356 {
       
  1357     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::AspectRatioChanged() [%d]"), aAspectRatio);
       
  1358 
       
  1359     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1360     {
       
  1361         if ( iControls[i]->AspectRatioChanged( aAspectRatio ) )
       
  1362         {
       
  1363             break;
       
  1364         }
       
  1365     }
       
  1366 }
       
  1367 
       
  1368 // -------------------------------------------------------------------------------------------------
       
  1369 //   CMPXVideoPlaybackControlsController::UpdateStateOnButtonBar()
       
  1370 // -------------------------------------------------------------------------------------------------
       
  1371 //
       
  1372 void CMPXVideoPlaybackControlsController::UpdateStateOnButtonBar()
       
  1373 {
       
  1374     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::UpdateStateOnButtonBar() [%d]"), iState);
       
  1375 
       
  1376     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1377     {
       
  1378         if ( iControls[i]->UpdateStateOnButtonBar( iState ) )
       
  1379         {
       
  1380             break;
       
  1381         }
       
  1382     }
       
  1383 }
       
  1384 
       
  1385 // ------------------------------------------------------------------------------------------------
       
  1386 // CMPXVideoPlaybackControlsController::CreateBitmap()
       
  1387 // ------------------------------------------------------------------------------------------------
       
  1388 //
       
  1389 CEikImage*
       
  1390 CMPXVideoPlaybackControlsController::CreateBitmapL( TFileName& aIconsPath,
       
  1391                                                     TInt aBitmapIndex,
       
  1392                                                     const TAknWindowLineLayout& aLayout )
       
  1393 {
       
  1394     CEikImage* eikImage = new (ELeave) CEikImage();
       
  1395 
       
  1396     CleanupStack::PushL( eikImage );
       
  1397 
       
  1398     CFbsBitmap* imageBitmap = AknIconUtils::CreateIconL( aIconsPath, aBitmapIndex );
       
  1399 
       
  1400     CleanupStack::PushL( imageBitmap );
       
  1401 
       
  1402     eikImage->SetBitmap( imageBitmap );
       
  1403     eikImage->SetContainerWindowL( *iContainer );
       
  1404     eikImage->MakeVisible( EFalse );
       
  1405 
       
  1406     AknLayoutUtils::LayoutImage( eikImage, iRect, aLayout );
       
  1407 
       
  1408     CleanupStack::Pop( 2 ); // eikImage & imageBitmap
       
  1409 
       
  1410     return eikImage;
       
  1411 }
       
  1412 
       
  1413 // ------------------------------------------------------------------------------------------------
       
  1414 // CMPXVideoPlaybackControlsController::CreateImageL()
       
  1415 // ------------------------------------------------------------------------------------------------
       
  1416 //
       
  1417 CEikImage*
       
  1418 CMPXVideoPlaybackControlsController::CreateImageL( TFileName& aIconsPath,
       
  1419                                                    TInt aBitmapIndex,
       
  1420                                                    TInt aBitmapMaskIndex )
       
  1421 {
       
  1422     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::CreateImageL()"));
       
  1423 
       
  1424     CFbsBitmap* bitmap = NULL;
       
  1425     CFbsBitmap* mask = NULL;
       
  1426     CEikImage* image = new (ELeave) CEikImage();
       
  1427 
       
  1428     AknIconUtils::CreateIconLC( bitmap, mask, aIconsPath, aBitmapIndex, aBitmapMaskIndex );
       
  1429 
       
  1430     image->SetPicture( bitmap, mask );             //  Ownership transferred
       
  1431     CleanupStack::Pop( 2 );                        // bitmap, mask
       
  1432     image->SetContainerWindowL( *iContainer );
       
  1433     image->MakeVisible( EFalse );
       
  1434 
       
  1435     return image;
       
  1436 }
       
  1437 
       
  1438 // ------------------------------------------------------------------------------------------------
       
  1439 //   CMPXVideoPlaybackControlsController::StopBrandingAnimation()
       
  1440 // ------------------------------------------------------------------------------------------------
       
  1441 //
       
  1442 void CMPXVideoPlaybackControlsController::StopBrandingAnimation()
       
  1443 {
       
  1444     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::StopBrandingAnimation()"));
       
  1445 
       
  1446     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1447     {
       
  1448         if ( iControls[i]->StopBrandingAnimationTimer() )
       
  1449         {
       
  1450             break;
       
  1451         }
       
  1452     }
       
  1453 }
       
  1454 
       
  1455 // -------------------------------------------------------------------------------------------------
       
  1456 // CMPXVideoPlaybackControlsController::IsRealFormatL()
       
  1457 // -------------------------------------------------------------------------------------------------
       
  1458 //
       
  1459 TBool CMPXVideoPlaybackControlsController::IsRealFormatL( const TDesC& aDes )
       
  1460 {
       
  1461     TBool realFormat = EFalse;
       
  1462 
       
  1463     if ( aDes != KNullDesC && aDes.Length() )
       
  1464     {
       
  1465         if ( iFileDetails->iPlaybackMode == EMPXVideoStreaming ||
       
  1466              iFileDetails->iPlaybackMode == EMPXVideoLiveStreaming )
       
  1467         {
       
  1468             realFormat = RealFormatForStreamingL( aDes );
       
  1469         }
       
  1470         else
       
  1471         {
       
  1472             realFormat = RealFormatForLocalL();
       
  1473         }
       
  1474     }
       
  1475 
       
  1476     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::IsRealFormatL() [%d]"), realFormat);
       
  1477 
       
  1478     return realFormat;
       
  1479 }
       
  1480 
       
  1481 // -------------------------------------------------------------------------------------------------
       
  1482 // CMPXVideoPlaybackControlsController::RealFormatForStreamingL()
       
  1483 // -------------------------------------------------------------------------------------------------
       
  1484 //
       
  1485 TBool CMPXVideoPlaybackControlsController::RealFormatForStreamingL( const TDesC& aDes )
       
  1486 {
       
  1487     TBool realFormat = EFalse;
       
  1488     TParse filePath;
       
  1489 
       
  1490     _LIT(KMPXRMEXT, ".R" );
       
  1491 
       
  1492     TInt err = filePath.Set( aDes, NULL, NULL );
       
  1493 
       
  1494     //
       
  1495     // It is valid to have a "\" character in a url, but parsing fails,
       
  1496     // switch these characters to "/" for the local string and try parsing again.
       
  1497     //
       
  1498     if ( err == KErrBadName )
       
  1499     {
       
  1500         TInt backsashPos = aDes.LocateF('\\');
       
  1501 
       
  1502         if( backsashPos != KErrNotFound )
       
  1503         {
       
  1504             HBufC* fileName = aDes.AllocL();
       
  1505 
       
  1506             TInt count( fileName->Des().Length() );
       
  1507 
       
  1508             for ( TInt j = backsashPos ; j < count; ++j )
       
  1509             {
       
  1510                 if ( fileName->Des()[j]== '\\' )
       
  1511                 {
       
  1512                     fileName->Des()[j]='/';
       
  1513                 }
       
  1514             }
       
  1515             err = filePath.Set( fileName->Des(), NULL, NULL );
       
  1516 
       
  1517             delete fileName;
       
  1518         }
       
  1519     }
       
  1520 
       
  1521     if ( err == KErrNone )
       
  1522     {
       
  1523         //
       
  1524         // The requirement to support arguments with the extension in streaming links
       
  1525         // for-ex: /video.3gp?start=10&end=40 will have to supported
       
  1526         // as well. So just by doing p.Ext() would retrieve all the string
       
  1527         // after "." so by doing a Left(2) would retrieve only
       
  1528         // .3g or .rm and so on. This would help better
       
  1529         // interpret the extension and decide the branding accordingly
       
  1530         //
       
  1531         filePath.Set( filePath.NameAndExt(), NULL, NULL );
       
  1532         TPtrC extension = filePath.Ext().Left( 2 );
       
  1533 
       
  1534         TBuf<2> buf;
       
  1535         buf.Format( extension );
       
  1536         buf.UpperCase();
       
  1537 
       
  1538         // RealMedia Branding
       
  1539         if ( ! buf.Compare( KMPXRMEXT ) )
       
  1540         {
       
  1541             realFormat = ETrue;
       
  1542         }
       
  1543     }
       
  1544 
       
  1545     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::RealFormatForStreamingL()[%d]"), realFormat);
       
  1546 
       
  1547     return realFormat;
       
  1548 }
       
  1549 
       
  1550 // -------------------------------------------------------------------------------------------------
       
  1551 // CMPXVideoPlaybackControlsController::RealFormatForLocalL()
       
  1552 // -------------------------------------------------------------------------------------------------
       
  1553 //
       
  1554 TBool CMPXVideoPlaybackControlsController::RealFormatForLocalL()
       
  1555 {
       
  1556     TBool realFormat = EFalse;
       
  1557 
       
  1558     _LIT(KMPXReal, "real" );
       
  1559     _LIT(KMPXRN, "rn" );
       
  1560 
       
  1561     if (iFileDetails->iMimeType)
       
  1562     {
       
  1563         iFileDetails->iMimeType->Des().LowerCase();
       
  1564 
       
  1565         if ( iFileDetails->iMimeType->Find( KMPXReal ) >= 0 ||
       
  1566              iFileDetails->iMimeType->Find( KMPXRN ) >= 0 )
       
  1567         {
       
  1568             realFormat = ETrue;
       
  1569         }
       
  1570     }
       
  1571 
       
  1572     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::RealFormatForLocalL() [%d]"), realFormat);
       
  1573 
       
  1574     return realFormat;
       
  1575 }
       
  1576 
       
  1577 // -------------------------------------------------------------------------------------------------
       
  1578 // CMPXVideoPlaybackControlsController::LocateBitmapFileL()
       
  1579 // -------------------------------------------------------------------------------------------------
       
  1580 //
       
  1581 void CMPXVideoPlaybackControlsController::LocateBitmapFileL( TFileName& aFileName )
       
  1582 {
       
  1583     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::LocateBitmapFileL()"));
       
  1584 
       
  1585     if ( ! iBitmapFileName.Length() )
       
  1586     {
       
  1587         TParse parse;
       
  1588 
       
  1589         //
       
  1590         //  This is done to ensure upgraded file is used first.
       
  1591         //  The drives from Y: to A: will be searched, then Z: last
       
  1592         //
       
  1593         TFindFile find( iFs );
       
  1594 
       
  1595         //
       
  1596         //  Search for the MBM file
       
  1597         //
       
  1598         HBufC* mbmFileName = StringLoader::LoadLC( R_MPX_VIDEO_PLAYBACK_CONTROLS_ICONS_MBM_FILE );
       
  1599         parse.Set( mbmFileName->Des(), &KDC_APP_BITMAP_DIR, NULL );
       
  1600         TPtrC mbmPath = parse.FullName();
       
  1601 
       
  1602         MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::LocateBitmapFileL() file %S"), &mbmPath);
       
  1603 
       
  1604         TInt error = find.FindByDir( mbmPath, KNullDesC );
       
  1605 
       
  1606         if ( error == KErrNone )
       
  1607         {
       
  1608             parse.Set( find.File(), NULL, NULL );
       
  1609         }
       
  1610         else
       
  1611         {
       
  1612             //
       
  1613             //  MBM file not found, search for the MIF file
       
  1614             //
       
  1615             HBufC* mifFileName = StringLoader::LoadLC( R_MPX_VIDEO_PLAYBACK_CONTROLS_ICONS_MIF_FILE );
       
  1616             parse.Set( mifFileName->Des(), &KDC_APP_BITMAP_DIR, NULL );
       
  1617             TPtrC mifPath = parse.FullName();
       
  1618             CleanupStack::PopAndDestroy( mifFileName );
       
  1619 
       
  1620             MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::LocateBitmapFileL() file %S"), &mifPath);
       
  1621 
       
  1622             //
       
  1623             //  If the MBM and the MIF file cannot be found, leave
       
  1624             //
       
  1625             User::LeaveIfError( find.FindByDir( mifPath, KNullDesC ) );
       
  1626 
       
  1627             parse.Set( find.File(), NULL, NULL );
       
  1628         }
       
  1629 
       
  1630         //
       
  1631         //  File Path must be to the MBM file
       
  1632         //
       
  1633         aFileName.Append( parse.Drive() );
       
  1634         aFileName.Append( KDC_APP_BITMAP_DIR );
       
  1635         aFileName.Append( mbmFileName->Des() );
       
  1636 
       
  1637         CleanupStack::PopAndDestroy( mbmFileName );
       
  1638 
       
  1639         //
       
  1640         //  Save this bitmap file name
       
  1641         //
       
  1642         iBitmapFileName = aFileName;
       
  1643 
       
  1644     }
       
  1645     else
       
  1646     {
       
  1647         aFileName.Append( iBitmapFileName );
       
  1648     }
       
  1649 
       
  1650     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::LocateBitmapFileL(%S)"),&aFileName);
       
  1651 }
       
  1652 
       
  1653 // -------------------------------------------------------------------------------------------------
       
  1654 //   CMPXVideoPlaybackControlsController::SetDownloadSize()
       
  1655 // -------------------------------------------------------------------------------------------------
       
  1656 //
       
  1657 void CMPXVideoPlaybackControlsController::SetDownloadSize( TInt aSize )
       
  1658 {
       
  1659     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::SetDownloadSize() [%d]"), aSize);
       
  1660 
       
  1661     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1662     {
       
  1663         if ( iControls[i]->SetDownloadSize( aSize ) )
       
  1664         {
       
  1665             break;
       
  1666         }
       
  1667     }
       
  1668 }
       
  1669 
       
  1670 // -------------------------------------------------------------------------------------------------
       
  1671 //   CMPXVideoPlaybackControlsController::UpdateDownloadPosition()
       
  1672 // -------------------------------------------------------------------------------------------------
       
  1673 //
       
  1674 void CMPXVideoPlaybackControlsController::UpdateDownloadPosition( TInt aSize )
       
  1675 {
       
  1676     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::UpdateDownloadPosition() [%d]"), aSize);
       
  1677 
       
  1678     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1679     {
       
  1680         if ( iControls[i]->UpdateDownloadPosition( aSize ) )
       
  1681         {
       
  1682             break;
       
  1683         }
       
  1684     }
       
  1685 }
       
  1686 
       
  1687 // -------------------------------------------------------------------------------------------------
       
  1688 //   CMPXVideoPlaybackControlsController::SetRealOneBitmapVisibility()
       
  1689 // -------------------------------------------------------------------------------------------------
       
  1690 //
       
  1691 void CMPXVideoPlaybackControlsController::SetRealOneBitmapVisibility( TBool aVisible )
       
  1692 {
       
  1693     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::SetRealOneBitmapVisibility(%d)"), aVisible);
       
  1694 
       
  1695     if ( iRealOneBitmap )
       
  1696     {
       
  1697     	iRealOneBitmap->MakeVisible( aVisible );
       
  1698     }
       
  1699 }
       
  1700 
       
  1701 // -------------------------------------------------------------------------------------------------
       
  1702 // CMPXVideoPlaybackControlsController::HandleErrors
       
  1703 // -------------------------------------------------------------------------------------------------
       
  1704 //
       
  1705 void CMPXVideoPlaybackControlsController::HandleErrors()
       
  1706 {
       
  1707     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::HandleErrors()"),
       
  1708                    _L("iState = %d"), iState );
       
  1709 
       
  1710     switch ( iState )
       
  1711     {
       
  1712         case EPbStateNotInitialised :
       
  1713         case EPbStateInitialising :
       
  1714         {
       
  1715             if ( iFileDetails->iPlaybackMode == EMPXVideoStreaming )
       
  1716             {
       
  1717                 StopBrandingAnimation();
       
  1718             }
       
  1719 
       
  1720             break;
       
  1721         }
       
  1722         default :
       
  1723         {
       
  1724             break;
       
  1725         }
       
  1726     }
       
  1727 }
       
  1728 
       
  1729 // -------------------------------------------------------------------------------------------------
       
  1730 //   CMPXVideoPlaybackControlsController::IsSoftKeyVisible()
       
  1731 // -------------------------------------------------------------------------------------------------
       
  1732 //
       
  1733 TBool CMPXVideoPlaybackControlsController::IsSoftKeyVisible( TInt aValue )
       
  1734 {
       
  1735     TBool visible = EFalse;
       
  1736     TInt softKeys;
       
  1737 
       
  1738     if ( aValue == EStdKeyDevice0 )
       
  1739     {
       
  1740         softKeys = EMPXSoftkeyDetails;
       
  1741     }
       
  1742     else//EStdKeyDevice1
       
  1743     {
       
  1744         softKeys = EMPXSoftkeyBack;
       
  1745     }
       
  1746 
       
  1747     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1748     {
       
  1749         if ( iControls[i]->ControlIndex() == softKeys )
       
  1750         {
       
  1751             if ( iControls[i]->IsVisible() )
       
  1752             {
       
  1753                 visible = ETrue;
       
  1754             }
       
  1755 
       
  1756             break;
       
  1757         }
       
  1758     }
       
  1759 
       
  1760     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::IsSoftKeyVisible() [%d]"), visible);
       
  1761 
       
  1762     return visible;
       
  1763 }
       
  1764 
       
  1765 // -------------------------------------------------------------------------------------------------
       
  1766 //   CMPXVideoPlaybackControlsController::HandleTvOutEventL
       
  1767 // -------------------------------------------------------------------------------------------------
       
  1768 //
       
  1769 void CMPXVideoPlaybackControlsController::HandleTvOutEventL(
       
  1770         TBool aConnected, TMPXVideoPlaybackControlCommandIds aEvent, TInt aValue )
       
  1771 {
       
  1772     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::HandleTvOutEventL()"));
       
  1773 
       
  1774     iFileDetails->iTvOutConnected = aConnected;
       
  1775 
       
  1776     if ( iFileDetails->iTvOutConnected )
       
  1777     {
       
  1778         iFileDetails->iTvOutPlayAllowed = aValue;
       
  1779     }
       
  1780     else
       
  1781     {
       
  1782         iFileDetails->iTvOutPlayAllowed = ETrue;
       
  1783     }
       
  1784 
       
  1785     iControlsConfig->UpdateControlListL( aEvent );
       
  1786     ControlsListUpdatedL();
       
  1787 }
       
  1788 
       
  1789 // -------------------------------------------------------------------------------------------------
       
  1790 //   CMPXVideoPlaybackControlsController::HandleSoftKeyPressedL( TInt aValue )
       
  1791 // -------------------------------------------------------------------------------------------------
       
  1792 //
       
  1793 void CMPXVideoPlaybackControlsController::HandleSoftKeyPressedL( TInt aValue )
       
  1794 {
       
  1795     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::HandleSoftKeyPressedL() [%d]"), aValue);
       
  1796 
       
  1797     if ( IsSoftKeyVisible( aValue ) )
       
  1798     {
       
  1799         if ( aValue == EStdKeyDevice0 )
       
  1800         {
       
  1801             iContainer->HandleCommandL( EMPXPbvCmdShowFileDetails );
       
  1802         }
       
  1803         else//EStdKeyDevice1
       
  1804         {
       
  1805             iContainer->HandleCommandL( EAknSoftkeyBack );
       
  1806         }
       
  1807     }
       
  1808     else
       
  1809     {
       
  1810         ShowControls();
       
  1811     }
       
  1812 }
       
  1813 
       
  1814 // -------------------------------------------------------------------------------------------------
       
  1815 //   CMPXVideoPlaybackControlsController::AddDllPath
       
  1816 // -------------------------------------------------------------------------------------------------
       
  1817 //
       
  1818 TInt CMPXVideoPlaybackControlsController::AddDllPath( TDes& aFileName )
       
  1819 {
       
  1820     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::AddDllPath()"),
       
  1821                    _L("aFileName = %S"), &aFileName);
       
  1822 
       
  1823     //
       
  1824     //  Find drive for dll to search same drive for rsc
       
  1825     //
       
  1826     TFileName dllName;
       
  1827     Dll::FileName( dllName );
       
  1828 
       
  1829     TPtrC driveAndPath = TParsePtrC( dllName ).DriveAndPath();
       
  1830 
       
  1831     TParse parse;
       
  1832 
       
  1833     TInt error = parse.Set( aFileName, &driveAndPath, NULL );
       
  1834 
       
  1835     if ( error == KErrNone )
       
  1836     {
       
  1837         aFileName.Zero();
       
  1838         aFileName.Append( parse.FullName() );
       
  1839     }
       
  1840 
       
  1841     return error;
       
  1842 }
       
  1843 
       
  1844 // -------------------------------------------------------------------------------------------------
       
  1845 //   CMPXVideoPlaybackControlsController::ShowMediaDetailsViewerL
       
  1846 // -------------------------------------------------------------------------------------------------
       
  1847 //
       
  1848 void CMPXVideoPlaybackControlsController::ShowMediaDetailsViewerL()
       
  1849 {
       
  1850     if ( ! iMediaDetailsViewerControl )
       
  1851     {
       
  1852         TUint properties = 0;
       
  1853 
       
  1854         CMPXVideoPlaybackMediaDetailsViewer* detailsViewer =
       
  1855                                                 CMPXVideoPlaybackMediaDetailsViewer::NewL( this );
       
  1856 
       
  1857         CleanupStack::PushL( detailsViewer );
       
  1858 
       
  1859         iMediaDetailsViewerControl = CMPXVideoPlaybackControl::NewL( this,
       
  1860                                                                      detailsViewer,
       
  1861                                                                      detailsViewer->ViewerRect(),
       
  1862                                                                      EMPXMediaDetailsViewer,
       
  1863                                                                      properties );
       
  1864 
       
  1865         CleanupStack::Pop(); // detailsViewer
       
  1866     }
       
  1867 
       
  1868     HideAllControls();
       
  1869     iMediaDetailsViewerControl->MakeVisible(ETrue);
       
  1870 
       
  1871 }
       
  1872 
       
  1873 // -------------------------------------------------------------------------------------------------
       
  1874 //   CMPXVideoPlaybackControlsController::IsMediaDetailsViewerVisible
       
  1875 // -------------------------------------------------------------------------------------------------
       
  1876 //
       
  1877 TBool CMPXVideoPlaybackControlsController::IsMediaDetailsViewerVisible()
       
  1878 {
       
  1879     TBool result = EFalse;
       
  1880 
       
  1881     if ( iMediaDetailsViewerControl )
       
  1882     {
       
  1883         result = iMediaDetailsViewerControl->IsVisible();
       
  1884     }
       
  1885 
       
  1886     return result;
       
  1887 }
       
  1888 
       
  1889 // -------------------------------------------------------------------------------------------------
       
  1890 //   CMPXVideoPlaybackControlsController::CloseMediaDetailsViewer
       
  1891 // -------------------------------------------------------------------------------------------------
       
  1892 //
       
  1893 void CMPXVideoPlaybackControlsController::CloseMediaDetailsViewer()
       
  1894 {
       
  1895     if ( iMediaDetailsViewerControl )
       
  1896     {
       
  1897         iMediaDetailsViewerControl->MakeVisible(EFalse);
       
  1898         delete iMediaDetailsViewerControl;
       
  1899         iMediaDetailsViewerControl = NULL;
       
  1900     }
       
  1901 }
       
  1902 
       
  1903 
       
  1904 // End of File