videoplayback/videoplaybackcontrols/src/mpxvideoplaybackcontrolscontroller.cpp
branchRCL_3
changeset 6 7d91903f795f
parent 0 96612d01cf9f
child 9 5294c000a26d
equal deleted inserted replaced
2:dec420019252 6:7d91903f795f
    13 *
    13 *
    14 * Description:  Implementation of MPXVideoPlaybackControlsController
    14 * Description:  Implementation of MPXVideoPlaybackControlsController
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 24 %
    18 // Version : %version: 27 %
    19 
    19 
    20 
    20 
    21 // INCLUDE FILES
    21 // INCLUDE FILES
    22 #include <fbs.h>
    22 #include <fbs.h>
    23 #include <coecntrl.h>
    23 #include <coecntrl.h>
    63 using namespace AknLayoutScalable_Apps;
    63 using namespace AknLayoutScalable_Apps;
    64 using namespace AknLayoutScalable_Avkon;
    64 using namespace AknLayoutScalable_Avkon;
    65 
    65 
    66 const TInt KMPXControlsTimeOut = 4000000;
    66 const TInt KMPXControlsTimeOut = 4000000;
    67 
    67 
       
    68 const TInt KMP4LayoutSet = 6;
    68 // ================= MEMBER FUNCTIONS ==============================================================
    69 // ================= MEMBER FUNCTIONS ==============================================================
    69 
    70 
    70 // -------------------------------------------------------------------------------------------------
    71 // -------------------------------------------------------------------------------------------------
    71 // CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController
    72 // CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController
    72 // C++ default constructor can NOT contain any code, that might leave.
    73 // C++ default constructor can NOT contain any code, that might leave.
    74 //
    75 //
    75 CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController(
    76 CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController(
    76     CMPXVideoPlaybackContainer* aContainer, TRect aRect )
    77     CMPXVideoPlaybackContainer* aContainer, TRect aRect )
    77     : iControls( EMPXControlsCount ),
    78     : iControls( EMPXControlsCount ),
    78       iRect( aRect ),
    79       iRect( aRect ),
    79       iContainer( aContainer )
    80       iContainer( aContainer ),
       
    81       iSurfaceCreated(EFalse)
    80 {
    82 {
    81 }
    83 }
    82 
    84 
    83 // -------------------------------------------------------------------------------------------------
    85 // -------------------------------------------------------------------------------------------------
    84 // CMPXVideoPlaybackControlsController::ConstructL()
    86 // CMPXVideoPlaybackControlsController::ConstructL()
   109     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::ConstructL() rsc file %S"), &resourceFile);
   111     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::ConstructL() rsc file %S"), &resourceFile);
   110 
   112 
   111     iVideoResourceOffset = coeEnv->AddResourceFileL( resourceFile );
   113     iVideoResourceOffset = coeEnv->AddResourceFileL( resourceFile );
   112 
   114 
   113     iFileDetails = aDetails;
   115     iFileDetails = aDetails;
       
   116     iTvOutConnected = iFileDetails->iTvOutConnected;
   114 
   117 
   115     iFileDetails->iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
   118     iFileDetails->iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
   116 
   119 
   117     if ( iFileDetails->iRNFormat )
   120     if ( iFileDetails->iRNFormat )
   118     {
   121     {
   314             break;
   317             break;
   315         }
   318         }
   316         case EMPXControlCmdTvOutConnected:
   319         case EMPXControlCmdTvOutConnected:
   317         {
   320         {
   318             MPX_DEBUG(_L("    [EMPXControlCmdTvOutConnected]"));
   321             MPX_DEBUG(_L("    [EMPXControlCmdTvOutConnected]"));
       
   322             iTvOutConnected = ETrue;
   319             HandleTvOutEventL( ETrue, aEvent, aValue );
   323             HandleTvOutEventL( ETrue, aEvent, aValue );
   320             break;
   324             break;
   321         }
   325         }
   322         case EMPXControlCmdTvOutDisconnected:
   326         case EMPXControlCmdTvOutDisconnected:
   323         {
   327         {
   324             MPX_DEBUG(_L("    [EMPXControlCmdTvOutDisConnected]"));
   328             MPX_DEBUG(_L("    [EMPXControlCmdTvOutDisConnected]"));
       
   329             iTvOutConnected = EFalse;
   325             HandleTvOutEventL( EFalse, aEvent, aValue );
   330             HandleTvOutEventL( EFalse, aEvent, aValue );
   326             break;
   331             break;
   327         }
   332         }
   328         case EMPXControlCmdHandleBackgroundEvent:
   333         case EMPXControlCmdHandleBackgroundEvent:
   329         {
   334         {
   374         case EMPXControlCmdSurfaceCreated:
   379         case EMPXControlCmdSurfaceCreated:
   375 		{
   380 		{
   376 			//
   381 			//
   377 			//  When surface is created, remove the Real One Bitmap
   382 			//  When surface is created, remove the Real One Bitmap
   378 			//
   383 			//
       
   384 			iSurfaceCreated = ETrue;
   379 			SetRealOneBitmapVisibility( EFalse );
   385 			SetRealOneBitmapVisibility( EFalse );
   380 			break;
   386 			break;
   381 		}
   387 		}
   382     }
   388     }
   383 }
   389 }
   673             break;
   679             break;
   674         }
   680         }
   675         case EMPXProgressBar:
   681         case EMPXProgressBar:
   676         {
   682         {
   677             TAknLayoutRect progressPaneRect;
   683             TAknLayoutRect progressPaneRect;
   678             progressPaneRect.LayoutRect( iRect, mp4_progress_pane(0).LayoutLine() );
   684             progressPaneRect.LayoutRect( iRect, mp4_progress_pane( KMP4LayoutSet ).LayoutLine() );
   679 
   685 
   680             TRect touchPaneRect( progressPaneRect.Rect().iTl.iX,
   686             TRect touchPaneRect( progressPaneRect.Rect().iTl.iX,
   681                                  progressPaneRect.Rect().iTl.iY,
   687                                  progressPaneRect.Rect().iTl.iY,
   682                                  progressPaneRect.Rect().iBr.iX,
   688                                  progressPaneRect.Rect().iBr.iX,
   683                                  iRect.Height() );
   689                                  iRect.Height() );
   712         case EMPXBufferingLabel:
   718         case EMPXBufferingLabel:
   713         {
   719         {
   714             CreateTextLabelWithSpecificLayoutL( R_MPX_LOADING,
   720             CreateTextLabelWithSpecificLayoutL( R_MPX_LOADING,
   715                                                 aControlIndex,
   721                                                 aControlIndex,
   716                                                 properties,
   722                                                 properties,
   717                                                 main_mp4_pane_t3(0) );
   723                                                 main_mp4_pane_t3( KMP4LayoutSet ) );
   718             break;
   724             break;
   719         }
   725         }
   720         case EMPXTitleLabel:
   726         case EMPXTitleLabel:
   721         {
   727         {
   722             CreateTitleControlL( aControlIndex, properties );
   728             CreateTitleControlL( aControlIndex, properties );
   798 
   804 
   799             CleanupStack::PushL( dlPausedBitmap );
   805             CleanupStack::PushL( dlPausedBitmap );
   800 
   806 
   801             AknLayoutUtils::LayoutImage( dlPausedBitmap,
   807             AknLayoutUtils::LayoutImage( dlPausedBitmap,
   802                                          iRect,
   808                                          iRect,
   803                                          AknLayoutScalable_Apps::main_mp4_pane_g6(0) );
   809                                          AknLayoutScalable_Apps::main_mp4_pane_g6( KMP4LayoutSet ) );
   804 
   810 
       
   811             TRect ctrlRect = dlPausedBitmap->Rect();
       
   812 
       
   813             // To make it aligned with AspectRatioIcon when touch is supported.
       
   814             if ( AknLayoutUtils::PenEnabled() )
       
   815             {
       
   816                 ctrlRect.iBr.iY += 10;
       
   817                 ctrlRect.iTl.iY += 10;
       
   818             }
   805             CMPXVideoPlaybackControl* control =
   819             CMPXVideoPlaybackControl* control =
   806                 CMPXVideoPlaybackControlPdl::NewL( this,
   820                 CMPXVideoPlaybackControlPdl::NewL( this,
   807                                                    dlPausedBitmap,
   821                                                    dlPausedBitmap,
   808                                                    dlPausedBitmap->Rect(),
   822                                                    ctrlRect,
   809                                                    aControlIndex,
   823                                                    aControlIndex,
   810                                                    properties );
   824                                                    properties );
   811 
   825 
   812             CleanupStack::PushL( control );
   826             CleanupStack::PushL( control );
   813 
   827 
   820         case EMPXAspectRatioIcon:
   834         case EMPXAspectRatioIcon:
   821         {
   835         {
   822 
   836 
   823             TAknLayoutRect aspectRatioPaneRect;
   837             TAknLayoutRect aspectRatioPaneRect;
   824             aspectRatioPaneRect.LayoutRect( iRect,
   838             aspectRatioPaneRect.LayoutRect( iRect,
   825                                             main_mp4_pane_g5(0).LayoutLine() );
   839                                             main_mp4_pane_g5( KMP4LayoutSet ).LayoutLine() );
   826 
   840 
   827             //
   841             //
   828             // Set the touchable area for aspect ratio
   842             // Set the touchable area for aspect ratio
   829             //
   843             //
   830             TRect touchableArea = TRect( aspectRatioPaneRect.Rect().iTl.iX - 25,
   844             TRect touchableArea = TRect( aspectRatioPaneRect.Rect().iTl.iX - 25,
   853             break;
   867             break;
   854         }
   868         }
   855         case EMPXBrandingAnimation:
   869         case EMPXBrandingAnimation:
   856         {
   870         {
   857             TAknLayoutRect brandingPaneRect;
   871             TAknLayoutRect brandingPaneRect;
   858             brandingPaneRect.LayoutRect( iRect, main_mp4_pane_g1(0).LayoutLine() );
   872             brandingPaneRect.LayoutRect( iRect, main_mp4_pane_g3( KMP4LayoutSet ).LayoutLine() );
   859 
   873 
       
   874             // Decrease the size of BrandingAnimation to make it look better.
       
   875             TRect brandingLogoRect(
       
   876                     brandingPaneRect.Rect().iTl.iX+20,
       
   877                     brandingPaneRect.Rect().iTl.iY+50,
       
   878                     brandingPaneRect.Rect().iBr.iX-20,
       
   879                     brandingPaneRect.Rect().iBr.iY-50 );
   860             CMPXVideoPlaybackBrandingAnimation* brandingAnimation =
   880             CMPXVideoPlaybackBrandingAnimation* brandingAnimation =
   861                 CMPXVideoPlaybackBrandingAnimation::NewL( this,
   881                 CMPXVideoPlaybackBrandingAnimation::NewL( this,
   862                                                           brandingPaneRect.Rect(),
   882                                                           brandingLogoRect,
   863                                                           iFileDetails->iRNFormat );
   883                                                           iFileDetails->iRNFormat );
   864 
   884 
   865             CleanupStack::PushL( brandingAnimation );
   885             CleanupStack::PushL( brandingAnimation );
   866 
   886 
   867             CMPXVideoPlaybackControl* control =
   887             CMPXVideoPlaybackControl* control =
   868                 CMPXVideoPlaybackControl::NewL( this,
   888                 CMPXVideoPlaybackControl::NewL( this,
   869                                                 brandingAnimation,
   889                                                 brandingAnimation,
   870                                                 brandingPaneRect.Rect(),
   890                                                 brandingLogoRect,
   871                                                 aControlIndex,
   891                                                 aControlIndex,
   872                                                 properties );
   892                                                 properties );
   873 
   893 
   874             CleanupStack::PushL( control );
   894             CleanupStack::PushL( control );
   875 
   895 
   888 
   908 
   889             CleanupStack::PushL( pausedBitmap );
   909             CleanupStack::PushL( pausedBitmap );
   890 
   910 
   891             AknLayoutUtils::LayoutImage( pausedBitmap,
   911             AknLayoutUtils::LayoutImage( pausedBitmap,
   892                                          iRect,
   912                                          iRect,
   893                                          AknLayoutScalable_Apps::main_mp4_pane_g4(0) );
   913                                          AknLayoutScalable_Apps::main_mp4_pane_g4( KMP4LayoutSet ) );
   894 
   914 
   895             CMPXVideoPlaybackControl* control =
   915             CMPXVideoPlaybackControl* control =
   896                 CMPXVideoPlaybackControl::NewL( this,
   916                 CMPXVideoPlaybackControl::NewL( this,
   897                                                 pausedBitmap,
   917                                                 pausedBitmap,
   898                                                 pausedBitmap->Rect(),
   918                                                 pausedBitmap->Rect(),
  1029     TAknWindowComponentLayout softkeyPane;
  1049     TAknWindowComponentLayout softkeyPane;
  1030     TRect skRect;
  1050     TRect skRect;
  1031 
  1051 
  1032     if ( aTop )
  1052     if ( aTop )
  1033     {
  1053     {
  1034         SKLayout = main_mp4_pane_t1(0);
  1054         SKLayout = main_mp4_pane_t2( KMP4LayoutSet );
  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     }
  1055     }
  1040     else
  1056     else
  1041     {
  1057     {
  1042         SKLayout = main_mp4_pane_t2(0);
  1058         SKLayout = main_mp4_pane_t1( KMP4LayoutSet );
  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     }
  1059     }
  1048 
  1060 
  1049     AknLayoutUtils::LayoutLabel( label,
  1061     AknLayoutUtils::LayoutLabel( label,
  1050                                  iRect,
  1062                                  iRect,
  1051                                  SKLayout.LayoutLine() );
  1063                                  SKLayout.LayoutLine() );
  1052 
  1064 
  1053     if ( AknLayoutUtils::PenEnabled() )
  1065     if ( AknLayoutUtils::PenEnabled() )
  1054     {
  1066     {
  1055         label->SetAlignment( EHCenterVCenter );
  1067         if ( aTop )
       
  1068         {
       
  1069             label->SetAlignment( EHRightVCenter );
       
  1070         }
       
  1071         else
       
  1072         {
       
  1073             label->SetAlignment( EHLeftVCenter );
       
  1074         }
  1056     }
  1075     }
  1057     else
  1076     else
  1058     {
  1077     {
  1059         if ( aTop )
  1078         if ( aTop )
  1060         {
  1079         {
  1063         else
  1082         else
  1064         {
  1083         {
  1065             label->SetAlignment( EHRightVBottom );
  1084             label->SetAlignment( EHRightVBottom );
  1066         }
  1085         }
  1067     }
  1086     }
       
  1087     
       
  1088     skRect = label->Rect();
       
  1089 
       
  1090     // Enlarge the button region to make it easy to be touched.
       
  1091     skRect.iTl.iY -= 6;
       
  1092     skRect.iBr.iY += 6;
  1068 
  1093 
  1069     CMPXVideoPlaybackControl* control = CMPXVideoPlaybackControl::NewL( this,
  1094     CMPXVideoPlaybackControl* control = CMPXVideoPlaybackControl::NewL( this,
  1070                                                                         label,
  1095                                                                         label,
  1071                                                                         skRect,
  1096                                                                         skRect,
  1072                                                                         aControlIndex,
  1097                                                                         aControlIndex,
  1898         delete iMediaDetailsViewerControl;
  1923         delete iMediaDetailsViewerControl;
  1899         iMediaDetailsViewerControl = NULL;
  1924         iMediaDetailsViewerControl = NULL;
  1900     }
  1925     }
  1901 }
  1926 }
  1902 
  1927 
       
  1928 TBool CMPXVideoPlaybackControlsController::SetBackgroundBlack()
       
  1929 {
       
  1930     TBool backgroundBlack = iSurfaceCreated && !iTvOutConnected;
       
  1931 
       
  1932     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::SetBackgroundBlack(%d)"), backgroundBlack);
       
  1933     return backgroundBlack;
       
  1934 }
       
  1935 
  1903 
  1936 
  1904 // End of File
  1937 // End of File