videoplayback/videoplaybackcontrols/src/mpxvideoplaybackcontrolscontroller.cpp
branchRCL_3
changeset 9 5294c000a26d
parent 6 7d91903f795f
child 10 112a725ff2c2
equal deleted inserted replaced
8:ce5ada96ab30 9:5294c000a26d
    13 *
    13 *
    14 * Description:  Implementation of MPXVideoPlaybackControlsController
    14 * Description:  Implementation of MPXVideoPlaybackControlsController
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 27 %
    18 
       
    19 // Version : %version: e003sa33#30 %
    19 
    20 
    20 
    21 
    21 // INCLUDE FILES
    22 // INCLUDE FILES
    22 #include <fbs.h>
    23 #include <fbs.h>
    23 #include <coecntrl.h>
    24 #include <coecntrl.h>
    64 using namespace AknLayoutScalable_Avkon;
    65 using namespace AknLayoutScalable_Avkon;
    65 
    66 
    66 const TInt KMPXControlsTimeOut = 4000000;
    67 const TInt KMPXControlsTimeOut = 4000000;
    67 
    68 
    68 const TInt KMP4LayoutSet = 6;
    69 const TInt KMP4LayoutSet = 6;
       
    70 
    69 // ================= MEMBER FUNCTIONS ==============================================================
    71 // ================= MEMBER FUNCTIONS ==============================================================
    70 
    72 
    71 // -------------------------------------------------------------------------------------------------
    73 // -------------------------------------------------------------------------------------------------
    72 // CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController
    74 // CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController
    73 // C++ default constructor can NOT contain any code, that might leave.
    75 // C++ default constructor can NOT contain any code, that might leave.
    75 //
    77 //
    76 CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController(
    78 CMPXVideoPlaybackControlsController::CMPXVideoPlaybackControlsController(
    77     CMPXVideoPlaybackContainer* aContainer, TRect aRect )
    79     CMPXVideoPlaybackContainer* aContainer, TRect aRect )
    78     : iControls( EMPXControlsCount ),
    80     : iControls( EMPXControlsCount ),
    79       iRect( aRect ),
    81       iRect( aRect ),
    80       iContainer( aContainer ),
    82       iSurfaceCreated( EFalse ),
    81       iSurfaceCreated(EFalse)
    83       iContainer( aContainer )
    82 {
    84 {
    83 }
    85 }
    84 
    86 
    85 // -------------------------------------------------------------------------------------------------
    87 // -------------------------------------------------------------------------------------------------
    86 // CMPXVideoPlaybackControlsController::ConstructL()
    88 // CMPXVideoPlaybackControlsController::ConstructL()
   113     iVideoResourceOffset = coeEnv->AddResourceFileL( resourceFile );
   115     iVideoResourceOffset = coeEnv->AddResourceFileL( resourceFile );
   114 
   116 
   115     iFileDetails = aDetails;
   117     iFileDetails = aDetails;
   116     iTvOutConnected = iFileDetails->iTvOutConnected;
   118     iTvOutConnected = iFileDetails->iTvOutConnected;
   117 
   119 
   118     iFileDetails->iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
   120     iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
   119 
       
   120     if ( iFileDetails->iRNFormat )
       
   121     {
       
   122     	CreateRealOneBitmapL();
       
   123     }
       
   124 
   121 
   125     iControlsPolicy = CMPXVideoPlaybackControlPolicy::NewL();
   122     iControlsPolicy = CMPXVideoPlaybackControlPolicy::NewL();
   126     iControlsConfig = CMPXVideoPlaybackControlConfiguration::NewL( this );
   123     iControlsConfig = CMPXVideoPlaybackControlConfiguration::NewL( this );
   127 
   124 
   128     iControlsTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   125     iControlsTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   165 {
   162 {
   166     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::~CMPXVideoPlaybackControlsController"));
   163     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::~CMPXVideoPlaybackControlsController"));
   167 
   164 
   168     iFs.Close();
   165     iFs.Close();
   169 
   166 
   170 
       
   171 #ifdef RD_TACTILE_FEEDBACK
   167 #ifdef RD_TACTILE_FEEDBACK
   172     if (iFeedback)
   168     if ( iFeedback )
   173     {
   169     {
   174         iFeedback->RemoveFeedbackForControl( iContainer );
   170         iFeedback->RemoveFeedbackForControl( iContainer );
   175     }
   171     }
   176 #endif //RD_TACTILE_FEEDBACK
   172 #endif //RD_TACTILE_FEEDBACK
   177 
   173 
   222     CMPXVideoPlaybackViewFileDetails* aDetails )
   218     CMPXVideoPlaybackViewFileDetails* aDetails )
   223 {
   219 {
   224     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::AddFileDetailsL()"));
   220     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::AddFileDetailsL()"));
   225 
   221 
   226     iFileDetails = aDetails;
   222     iFileDetails = aDetails;
   227 
       
   228     iFileDetails->iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
       
   229 
   223 
   230     iControlsConfig->UpdateControlsWithFileDetailsL();
   224     iControlsConfig->UpdateControlsWithFileDetailsL();
   231 
   225 
   232     ControlsListUpdatedL();
   226     ControlsListUpdatedL();
   233 
   227 
   375         {
   369         {
   376             ShowControls();
   370             ShowControls();
   377             break;
   371             break;
   378         }
   372         }
   379         case EMPXControlCmdSurfaceCreated:
   373         case EMPXControlCmdSurfaceCreated:
   380 		{
   374         {
   381 			//
   375             iSurfaceCreated = ETrue;
   382 			//  When surface is created, remove the Real One Bitmap
   376             SetRealOneBitmapVisibility( EFalse );
   383 			//
   377             break;
   384 			iSurfaceCreated = ETrue;
   378         }
   385 			SetRealOneBitmapVisibility( EFalse );
   379         case EMPXControlCmdSurfaceRemoved:
   386 			break;
   380         {
   387 		}
   381             iSurfaceCreated = EFalse;
       
   382             break;
       
   383         }
   388     }
   384     }
   389 }
   385 }
   390 
   386 
   391 // -------------------------------------------------------------------------------------------------
   387 // -------------------------------------------------------------------------------------------------
   392 // CMPXVideoPlaybackControlsController::HandleStateChange
   388 // CMPXVideoPlaybackControlsController::HandleStateChange
   400     //
   396     //
   401     // Somehow EPbStatePlaying, EPbStatePaused gets called twice continously
   397     // Somehow EPbStatePlaying, EPbStatePaused gets called twice continously
   402     //
   398     //
   403     if ( aNewState != iState )
   399     if ( aNewState != iState )
   404     {
   400     {
   405     	TBool hideControls( EFalse );
   401         TBool hideControls( EFalse );
   406     	
   402 
   407         iState = aNewState;
   403         iState = aNewState;
   408 
   404 
   409         switch ( aNewState )
   405         switch ( aNewState )
   410         {
   406         {
   411             case EPbStateInitialised:
   407             case EPbStateInitialised:
   414                 //  remove branding control when the state is transitioned to Initialized
   410                 //  remove branding control when the state is transitioned to Initialized
   415                 //
   411                 //
   416                 if ( iFileDetails->iPlaybackMode == EMPXVideoStreaming ||
   412                 if ( iFileDetails->iPlaybackMode == EMPXVideoStreaming ||
   417                      iFileDetails->iPlaybackMode == EMPXVideoLiveStreaming )
   413                      iFileDetails->iPlaybackMode == EMPXVideoLiveStreaming )
   418                 {
   414                 {
   419                     iControlsConfig->UpdateControlListL( EMPXControlCmdPluginInitialized );
   415                     TRAP_IGNORE(
   420                     ControlsListUpdatedL();
   416                         iControlsConfig->UpdateControlListL( EMPXControlCmdPluginInitialized );
       
   417                         ControlsListUpdatedL();
       
   418                         );
   421                 }
   419                 }
   422 
   420 
   423                 break;
   421                 break;
   424             }
   422             }
   425             case EPbStatePlaying:
   423             case EPbStatePlaying:
   451                 {
   449                 {
   452                     HideAllControls();
   450                     HideAllControls();
   453                 }
   451                 }
   454                 else
   452                 else
   455                 {
   453                 {
   456                 	UpdateControlsVisibility();
   454                     UpdateControlsVisibility();
   457                 }
   455                 }
   458 
   456 
   459                 break;
   457                 break;
   460             }
   458             }
   461         }
   459         }
   494 // -------------------------------------------------------------------------------------------------
   492 // -------------------------------------------------------------------------------------------------
   495 //
   493 //
   496 void CMPXVideoPlaybackControlsController::CreateRealOneBitmapL()
   494 void CMPXVideoPlaybackControlsController::CreateRealOneBitmapL()
   497 {
   495 {
   498     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::CreateRealOneBitmapL()"));
   496     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::CreateRealOneBitmapL()"));
   499 
       
   500 
   497 
   501     TFileName iconsPath;
   498     TFileName iconsPath;
   502     LocateBitmapFileL( iconsPath );
   499     LocateBitmapFileL( iconsPath );
   503 
   500 
   504     iRealOneBitmap = CreateBitmapL( iconsPath,
   501     iRealOneBitmap = CreateBitmapL( iconsPath,
   878                     brandingPaneRect.Rect().iBr.iX-20,
   875                     brandingPaneRect.Rect().iBr.iX-20,
   879                     brandingPaneRect.Rect().iBr.iY-50 );
   876                     brandingPaneRect.Rect().iBr.iY-50 );
   880             CMPXVideoPlaybackBrandingAnimation* brandingAnimation =
   877             CMPXVideoPlaybackBrandingAnimation* brandingAnimation =
   881                 CMPXVideoPlaybackBrandingAnimation::NewL( this,
   878                 CMPXVideoPlaybackBrandingAnimation::NewL( this,
   882                                                           brandingLogoRect,
   879                                                           brandingLogoRect,
   883                                                           iFileDetails->iRNFormat );
   880                                                           iRNFormat );
   884 
   881 
   885             CleanupStack::PushL( brandingAnimation );
   882             CleanupStack::PushL( brandingAnimation );
   886 
   883 
   887             CMPXVideoPlaybackControl* control =
   884             CMPXVideoPlaybackControl* control =
   888                 CMPXVideoPlaybackControl::NewL( this,
   885                 CMPXVideoPlaybackControl::NewL( this,
  1082         else
  1079         else
  1083         {
  1080         {
  1084             label->SetAlignment( EHRightVBottom );
  1081             label->SetAlignment( EHRightVBottom );
  1085         }
  1082         }
  1086     }
  1083     }
  1087     
  1084 
  1088     skRect = label->Rect();
  1085     skRect = label->Rect();
  1089 
  1086 
  1090     // Enlarge the button region to make it easy to be touched.
  1087     // Enlarge the button region to make it easy to be touched.
  1091     skRect.iTl.iY -= 6;
  1088     skRect.iTl.iY -= 6;
  1092     skRect.iBr.iY += 6;
  1089     skRect.iBr.iY += 6;
  1581     TBool realFormat = EFalse;
  1578     TBool realFormat = EFalse;
  1582 
  1579 
  1583     _LIT(KMPXReal, "real" );
  1580     _LIT(KMPXReal, "real" );
  1584     _LIT(KMPXRN, "rn" );
  1581     _LIT(KMPXRN, "rn" );
  1585 
  1582 
  1586     if (iFileDetails->iMimeType)
  1583     if ( iFileDetails->iMimeType )
  1587     {
  1584     {
  1588         iFileDetails->iMimeType->Des().LowerCase();
  1585         iFileDetails->iMimeType->Des().LowerCase();
  1589 
  1586 
  1590         if ( iFileDetails->iMimeType->Find( KMPXReal ) >= 0 ||
  1587         if ( iFileDetails->iMimeType->Find( KMPXReal ) >= 0 ||
  1591              iFileDetails->iMimeType->Find( KMPXRN ) >= 0 )
  1588              iFileDetails->iMimeType->Find( KMPXRN ) >= 0 )
  1592         {
  1589         {
       
  1590             //
       
  1591             // RN clip and local mode, add RN logo bitmap to show while initializing
       
  1592             //
       
  1593             CreateRealOneBitmapL();
       
  1594             SetRealOneBitmapVisibility( ETrue );
  1593             realFormat = ETrue;
  1595             realFormat = ETrue;
  1594         }
  1596         }
  1595     }
  1597     }
  1596 
  1598 
  1597     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::RealFormatForLocalL() [%d]"), realFormat);
  1599     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::RealFormatForLocalL() [%d]"), realFormat);
  1717 {
  1719 {
  1718     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::SetRealOneBitmapVisibility(%d)"), aVisible);
  1720     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::SetRealOneBitmapVisibility(%d)"), aVisible);
  1719 
  1721 
  1720     if ( iRealOneBitmap )
  1722     if ( iRealOneBitmap )
  1721     {
  1723     {
  1722     	iRealOneBitmap->MakeVisible( aVisible );
  1724         iRealOneBitmap->MakeVisible( aVisible );
  1723     }
  1725     }
  1724 }
  1726 }
  1725 
  1727 
  1726 // -------------------------------------------------------------------------------------------------
  1728 // -------------------------------------------------------------------------------------------------
  1727 // CMPXVideoPlaybackControlsController::HandleErrors
  1729 // CMPXVideoPlaybackControlsController::HandleErrors
  1740             if ( iFileDetails->iPlaybackMode == EMPXVideoStreaming )
  1742             if ( iFileDetails->iPlaybackMode == EMPXVideoStreaming )
  1741             {
  1743             {
  1742                 StopBrandingAnimation();
  1744                 StopBrandingAnimation();
  1743             }
  1745             }
  1744 
  1746 
  1745             break;
       
  1746         }
       
  1747         default :
       
  1748         {
       
  1749             break;
  1747             break;
  1750         }
  1748         }
  1751     }
  1749     }
  1752 }
  1750 }
  1753 
  1751 
  1923         delete iMediaDetailsViewerControl;
  1921         delete iMediaDetailsViewerControl;
  1924         iMediaDetailsViewerControl = NULL;
  1922         iMediaDetailsViewerControl = NULL;
  1925     }
  1923     }
  1926 }
  1924 }
  1927 
  1925 
       
  1926 // -------------------------------------------------------------------------------------------------
       
  1927 //   CMPXVideoPlaybackControlsController::SetBackgroundBlack
       
  1928 // -------------------------------------------------------------------------------------------------
       
  1929 //
  1928 TBool CMPXVideoPlaybackControlsController::SetBackgroundBlack()
  1930 TBool CMPXVideoPlaybackControlsController::SetBackgroundBlack()
  1929 {
  1931 {
  1930     TBool backgroundBlack = iSurfaceCreated && !iTvOutConnected;
  1932     TBool backgroundBlack = iSurfaceCreated && ! iTvOutConnected;
  1931 
  1933 
  1932     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::SetBackgroundBlack(%d)"), backgroundBlack);
  1934     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::SetBackgroundBlack(%d)"), backgroundBlack);
  1933     return backgroundBlack;
  1935     return backgroundBlack;
  1934 }
  1936 }
  1935 
  1937 
       
  1938 // -------------------------------------------------------------------------------------------------
       
  1939 //   CMPXVideoPlaybackControlsController::IsSameAspectRatio
       
  1940 // -------------------------------------------------------------------------------------------------
       
  1941 //
       
  1942 TBool CMPXVideoPlaybackControlsController::IsSameAspectRatio()
       
  1943 {
       
  1944 	MPX_ENTER_EXIT( _L( "CMPXVideoPlaybackControlsController::IsSameAspectRatio()" ) );
       
  1945 	
       
  1946     TBool retVal = EFalse;
       
  1947 
       
  1948     if ( iFileDetails->iVideoEnabled &&
       
  1949     	 iFileDetails->iVideoHeight > 0 &&
       
  1950   	     iFileDetails->iVideoWidth > 0 )
       
  1951     {
       
  1952         TRect displayRect = iContainer->Rect();
       
  1953         TReal displayAspectRatio = ( TReal32 )displayRect.Width() / ( TReal32 )displayRect.Height();
       
  1954         TReal videoAspectRatio = ( TReal32 )iFileDetails->iVideoWidth / 
       
  1955         		                 ( TReal32 )iFileDetails->iVideoHeight;
       
  1956 
       
  1957         if ( displayAspectRatio == videoAspectRatio )
       
  1958         {
       
  1959             retVal = ETrue;
       
  1960         }
       
  1961     }
       
  1962 
       
  1963     MPX_DEBUG( _L( "CMPXVideoPlaybackControlsController::IsSameAspectRatio(%d)" ), retVal );
       
  1964     
       
  1965     return retVal;
       
  1966 }
  1936 
  1967 
  1937 // End of File
  1968 // End of File