videoplayback/videoplaybackcontrols/src/mpxvideoplaybackcontrolscontroller.cpp
branchRCL_3
changeset 21 315810614048
parent 16 67eb01668b0e
equal deleted inserted replaced
20:2d690156cf8f 21:315810614048
    14 * Description:  Implementation of MPXVideoPlaybackControlsController
    14 * Description:  Implementation of MPXVideoPlaybackControlsController
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // Version : %version: 42 %
    19 // Version : %version: 45 %
    20 
    20 
    21 
    21 
    22 // INCLUDE FILES
    22 // INCLUDE FILES
    23 #include <fbs.h>
    23 #include <fbs.h>
    24 #include <coecntrl.h>
    24 #include <coecntrl.h>
   115 
   115 
   116     iVideoResourceOffset = coeEnv->AddResourceFileL( resourceFile );
   116     iVideoResourceOffset = coeEnv->AddResourceFileL( resourceFile );
   117 
   117 
   118     iFileDetails = aDetails;
   118     iFileDetails = aDetails;
   119     iTvOutConnected = iFileDetails->iTvOutConnected;
   119     iTvOutConnected = iFileDetails->iTvOutConnected;
   120     iShowControls  = ETrue;
       
   121 
   120 
   122     iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
   121     iRNFormat = IsRealFormatL( iFileDetails->iClipName->Des() );
       
   122 
       
   123     if ( IsRealOneBitmapVisible() )
       
   124     {
       
   125         iShowControls  = EFalse;
       
   126     }
       
   127     else
       
   128     {
       
   129         iShowControls  = ETrue;
       
   130     }
   123 
   131 
   124     iControlsPolicy = CMPXVideoPlaybackControlPolicy::NewL();
   132     iControlsPolicy = CMPXVideoPlaybackControlPolicy::NewL();
   125     iControlsConfig = CMPXVideoPlaybackControlConfiguration::NewL( this );
   133     iControlsConfig = CMPXVideoPlaybackControlConfiguration::NewL( this );
   126 
   134 
   127     iControlsTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   135     iControlsTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   226 
   234 
   227     iControlsConfig->UpdateControlsWithFileDetailsL();
   235     iControlsConfig->UpdateControlsWithFileDetailsL();
   228 
   236 
   229     ControlsListUpdatedL();
   237     ControlsListUpdatedL();
   230 
   238 
   231     //
       
   232     //  Show controls initially if this doens't have playable video track
       
   233     //
       
   234     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
   239     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
   235     {
   240     {
   236         iControls[i]->UpdateControlsWithFileDetailsL( iFileDetails );
   241         iControls[i]->UpdateControlsWithFileDetailsL( iFileDetails );
   237     }
   242     }
   238 }
   243 }
   313             ControlsListUpdatedL();
   318             ControlsListUpdatedL();
   314             break;
   319             break;
   315         }
   320         }
   316         case EMPXControlCmdTvOutConnected:
   321         case EMPXControlCmdTvOutConnected:
   317         {
   322         {
   318             MPX_DEBUG(_L("    [EMPXControlCmdTvOutConnected]"));
       
   319             iTvOutConnected = ETrue;
   323             iTvOutConnected = ETrue;
   320             HandleTvOutEventL( ETrue, aEvent );
   324 
       
   325             //
       
   326             //  Do not show the aspect ratio icon when TV Out is connected
       
   327             //
       
   328             HandleTvOutEventL( ETrue, aEvent, EFalse );
   321             break;
   329             break;
   322         }
   330         }
   323         case EMPXControlCmdTvOutDisconnected:
   331         case EMPXControlCmdTvOutDisconnected:
   324         {
   332         {
   325             MPX_DEBUG(_L("    [EMPXControlCmdTvOutDisConnected]"));
       
   326             iTvOutConnected = EFalse;
   333             iTvOutConnected = EFalse;
   327             HandleTvOutEventL( EFalse, aEvent );
   334 
       
   335             //
       
   336             //  Pass in the show aspect ratio flag from the event
       
   337             //
       
   338             HandleTvOutEventL( EFalse, aEvent, aValue );
   328             break;
   339             break;
   329         }
   340         }
   330         case EMPXControlCmdHandleBackgroundEvent:
   341         case EMPXControlCmdHandleBackgroundEvent:
   331         {
   342         {
   332             MPX_DEBUG(_L("    [EMPXControlCmdHandleBackgroundEvent]"));
   343             MPX_DEBUG(_L("    [EMPXControlCmdHandleBackgroundEvent]"));
   333 
   344 
   334             TBool keylock( EFalse );
   345             TBool keylock( EFalse );
   335             RProperty::Get( KPSUidAvkonDomain, KAknKeyguardStatus, keylock );
   346             RProperty::Get( KPSUidAvkonDomain, KAknKeyguardStatus, keylock );
   336 
   347 
   337             // Don't show controls when key is locked 
   348             //
       
   349             //  Don't show controls when key is locked
       
   350             //
   338             if ( keylock )
   351             if ( keylock )
   339             {
   352             {
   340                 iShowControls = EFalse;
   353                 iShowControls = EFalse;
   341             }
   354             }
   342 
   355 
   350             break;
   363             break;
   351         }
   364         }
   352         case EMPXControlCmdHandleForegroundEvent:
   365         case EMPXControlCmdHandleForegroundEvent:
   353         {
   366         {
   354             MPX_DEBUG(_L("    [EMPXControlCmdHandleForegroundEvent]"));
   367             MPX_DEBUG(_L("    [EMPXControlCmdHandleForegroundEvent]"));
   355             iShowControls = ETrue;
   368 
   356             UpdateControlsVisibility();
   369             if ( ! IsRealOneBitmapVisible() )
       
   370             {
       
   371                 iShowControls = ETrue;
       
   372                 UpdateControlsVisibility();
       
   373             }
       
   374 
   357             break;
   375             break;
   358         }
   376         }
   359         case EMPXControlCmdHandleErrors:
   377         case EMPXControlCmdHandleErrors:
   360         {
   378         {
   361             MPX_DEBUG(_L("    [EMPXControlCmdHandleErrors]"));
   379             MPX_DEBUG(_L("    [EMPXControlCmdHandleErrors]"));
   396         }
   414         }
   397         case EMPXControlCmdLoadingStarted:
   415         case EMPXControlCmdLoadingStarted:
   398         {
   416         {
   399             HandleLoadingStarted();
   417             HandleLoadingStarted();
   400             break;
   418             break;
       
   419         }
       
   420         case EMPXControlCmdCreateAspectRatioIcon:
       
   421         case EMPXControlCmdDeleteAspectRatioIcon:
       
   422         {
       
   423             //
       
   424             //  Ignore the Aspect Ration commands for non touch devices and
       
   425             //  when the TV-Out is connected.
       
   426             //
       
   427             if ( AknLayoutUtils::PenEnabled() && ! iTvOutConnected )
       
   428             {
       
   429                 iControlsConfig->UpdateControlListL( aEvent );
       
   430 
       
   431                 //
       
   432                 //  Set the update visibility flag based on the visibility of the controls
       
   433                 //
       
   434                 ControlsListUpdatedL( IsVisible() );
       
   435             }
   401         }
   436         }
   402     }
   437     }
   403 }
   438 }
   404 
   439 
   405 // -------------------------------------------------------------------------------------------------
   440 // -------------------------------------------------------------------------------------------------
   544 
   579 
   545 // -------------------------------------------------------------------------------------------------
   580 // -------------------------------------------------------------------------------------------------
   546 // CMPXVideoPlaybackControlsController::ControlsListUpdatedL()
   581 // CMPXVideoPlaybackControlsController::ControlsListUpdatedL()
   547 // -------------------------------------------------------------------------------------------------
   582 // -------------------------------------------------------------------------------------------------
   548 //
   583 //
   549 void CMPXVideoPlaybackControlsController::ControlsListUpdatedL()
   584 void CMPXVideoPlaybackControlsController::ControlsListUpdatedL( TBool aUpdateVisibility )
   550 {
   585 {
   551     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::ControlsListUpdatedL()"));
   586     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::ControlsListUpdatedL()"),
       
   587                    _L("aUpdateVisibility = %d"), aUpdateVisibility );
   552 
   588 
   553     RArray<TMPXVideoPlaybackControls>& updatedList = iControlsConfig->ControlList();
   589     RArray<TMPXVideoPlaybackControls>& updatedList = iControlsConfig->ControlList();
   554 
   590 
   555     //
   591     //
   556     //  Create a copy of the control list
   592     //  Create a copy of the control list
   601     for ( TInt j = 0 ; j < myList.Count() ; j++ )
   637     for ( TInt j = 0 ; j < myList.Count() ; j++ )
   602     {
   638     {
   603         AppendControlL( myList[j] );
   639         AppendControlL( myList[j] );
   604     }
   640     }
   605 
   641 
   606     UpdateControlsVisibility();
   642     if ( aUpdateVisibility )
       
   643     {
       
   644         UpdateControlsVisibility();
       
   645     }
   607 
   646 
   608     CleanupStack::PopAndDestroy();
   647     CleanupStack::PopAndDestroy();
   609 }
   648 }
   610 
   649 
   611 // -------------------------------------------------------------------------------------------------
   650 // -------------------------------------------------------------------------------------------------
   822                                          iRect,
   861                                          iRect,
   823                                          AknLayoutScalable_Apps::main_mp4_pane_g6( KMP4LayoutSet ) );
   862                                          AknLayoutScalable_Apps::main_mp4_pane_g6( KMP4LayoutSet ) );
   824 
   863 
   825             TRect ctrlRect = dlPausedBitmap->Rect();
   864             TRect ctrlRect = dlPausedBitmap->Rect();
   826 
   865 
   827             // To make it aligned with AspectRatioIcon when touch is supported.
   866             //
       
   867             //  To make it aligned with AspectRatioIcon when touch is supported.
       
   868             //
   828             if ( AknLayoutUtils::PenEnabled() )
   869             if ( AknLayoutUtils::PenEnabled() )
   829             {
   870             {
   830                 ctrlRect.iBr.iY += 10;
   871                 ctrlRect.iBr.iY += 10;
   831                 ctrlRect.iTl.iY += 10;
   872                 ctrlRect.iTl.iY += 10;
   832             }
   873             }
       
   874 
   833             CMPXVideoPlaybackControl* control =
   875             CMPXVideoPlaybackControl* control =
   834                 CMPXVideoPlaybackControlPdl::NewL( this,
   876                 CMPXVideoPlaybackControlPdl::NewL( this,
   835                                                    dlPausedBitmap,
   877                                                    dlPausedBitmap,
   836                                                    ctrlRect,
   878                                                    ctrlRect,
   837                                                    aControlIndex,
   879                                                    aControlIndex,
   869                 CMPXVideoPlaybackControl::NewL( this,
   911                 CMPXVideoPlaybackControl::NewL( this,
   870                                                 aspectRatioIcon,
   912                                                 aspectRatioIcon,
   871                                                 touchableArea,
   913                                                 touchableArea,
   872                                                 aControlIndex,
   914                                                 aControlIndex,
   873                                                 properties );
   915                                                 properties );
       
   916 
       
   917             control->MakeVisible( EFalse );
   874 
   918 
   875             CleanupStack::PushL( control );
   919             CleanupStack::PushL( control );
   876 
   920 
   877             iControls.AppendL( control );
   921             iControls.AppendL( control );
   878 
   922 
  1743     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::SetRealOneBitmapVisibility(%d)"), aVisible);
  1787     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::SetRealOneBitmapVisibility(%d)"), aVisible);
  1744 
  1788 
  1745     if ( iRealOneBitmap )
  1789     if ( iRealOneBitmap )
  1746     {
  1790     {
  1747         iRealOneBitmap->MakeVisible( aVisible );
  1791         iRealOneBitmap->MakeVisible( aVisible );
  1748     }
  1792 
       
  1793         if ( ! aVisible )
       
  1794         {
       
  1795             // HDMI/TV-out cable connected then show the controls
       
  1796             if ( iTvOutConnected  && !iShowControls )
       
  1797             {
       
  1798                 iShowControls = ETrue;
       
  1799                 UpdateControlsVisibility();
       
  1800             }
       
  1801             else
       
  1802             {
       
  1803                 iShowControls = ETrue;
       
  1804             }
       
  1805         }
       
  1806     }// iRealOneBitmap
       
  1807 }
       
  1808 
       
  1809 // -------------------------------------------------------------------------------------------------
       
  1810 //   CMPXVideoPlaybackControlsController::IsRealOneBitmapVisible()
       
  1811 // -------------------------------------------------------------------------------------------------
       
  1812 //
       
  1813 TBool CMPXVideoPlaybackControlsController::IsRealOneBitmapVisible()
       
  1814 {
       
  1815     TBool visible = EFalse;
       
  1816 
       
  1817     if ( iRealOneBitmap )
       
  1818     {
       
  1819         visible = iRealOneBitmap->IsVisible();
       
  1820     }
       
  1821 
       
  1822     MPX_DEBUG(_L("CMPXVideoPlaybackControlsController::IsRealOneBitmapVisible(%d)"), visible);
       
  1823 
       
  1824     return visible;
  1749 }
  1825 }
  1750 
  1826 
  1751 // -------------------------------------------------------------------------------------------------
  1827 // -------------------------------------------------------------------------------------------------
  1752 // CMPXVideoPlaybackControlsController::HandleErrors
  1828 // CMPXVideoPlaybackControlsController::HandleErrors
  1753 // -------------------------------------------------------------------------------------------------
  1829 // -------------------------------------------------------------------------------------------------
  1811 // -------------------------------------------------------------------------------------------------
  1887 // -------------------------------------------------------------------------------------------------
  1812 //   CMPXVideoPlaybackControlsController::HandleTvOutEventL
  1888 //   CMPXVideoPlaybackControlsController::HandleTvOutEventL
  1813 // -------------------------------------------------------------------------------------------------
  1889 // -------------------------------------------------------------------------------------------------
  1814 //
  1890 //
  1815 void CMPXVideoPlaybackControlsController::HandleTvOutEventL(
  1891 void CMPXVideoPlaybackControlsController::HandleTvOutEventL(
  1816         TBool aConnected, TMPXVideoPlaybackControlCommandIds aEvent )
  1892         TBool aConnected, TMPXVideoPlaybackControlCommandIds aEvent, TBool aShowArIcon )
  1817 {
  1893 {
  1818     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::HandleTvOutEventL()"));
  1894     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::HandleTvOutEventL()"));
  1819 
  1895 
  1820     iFileDetails->iTvOutConnected = aConnected;
  1896     iFileDetails->iTvOutConnected = aConnected;
  1821     iControlsConfig->UpdateControlListL( aEvent );
  1897     iControlsConfig->UpdateControlListL( aEvent, aShowArIcon );
  1822     ControlsListUpdatedL();
  1898     ControlsListUpdatedL();
       
  1899 
       
  1900     for ( TInt i = 0 ; i < iControls.Count() ; i++ )
       
  1901     {
       
  1902         if ( iControls[i]->UpdateTVOutStatusL( aConnected ) )
       
  1903         {
       
  1904             break;
       
  1905         }
       
  1906     }
  1823 }
  1907 }
  1824 
  1908 
  1825 // -------------------------------------------------------------------------------------------------
  1909 // -------------------------------------------------------------------------------------------------
  1826 //   CMPXVideoPlaybackControlsController::HandleSoftKeyPressedL( TInt aValue )
  1910 //   CMPXVideoPlaybackControlsController::HandleSoftKeyPressedL( TInt aValue )
  1827 // -------------------------------------------------------------------------------------------------
  1911 // -------------------------------------------------------------------------------------------------
  1937         iMediaDetailsViewerControl = NULL;
  2021         iMediaDetailsViewerControl = NULL;
  1938     }
  2022     }
  1939 }
  2023 }
  1940 
  2024 
  1941 // -------------------------------------------------------------------------------------------------
  2025 // -------------------------------------------------------------------------------------------------
  1942 //   CMPXVideoPlaybackControlsController::ShowAspectRatioIcon
       
  1943 // -------------------------------------------------------------------------------------------------
       
  1944 //
       
  1945 TBool CMPXVideoPlaybackControlsController::ShowAspectRatioIcon()
       
  1946 {
       
  1947     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackControlsController::ShowAspectRatioIcon()"));
       
  1948 
       
  1949     TBool retVal = EFalse;
       
  1950 
       
  1951     if ( iFileDetails->iVideoEnabled &&
       
  1952          iFileDetails->iVideoHeight > 0 &&
       
  1953          iFileDetails->iVideoWidth > 0 &&
       
  1954          AknLayoutUtils::PenEnabled() )
       
  1955     {
       
  1956         TRect displayRect = iContainer->Rect();
       
  1957         TReal displayAspectRatio = ( TReal32 )displayRect.Width() / ( TReal32 )displayRect.Height();
       
  1958         TReal videoAspectRatio = ( TReal32 )iFileDetails->iVideoWidth /
       
  1959                                  ( TReal32 )iFileDetails->iVideoHeight;
       
  1960 
       
  1961         // If clip's AR is as same as screen display AR, AspectRatioIcon does not display.
       
  1962         if ( displayAspectRatio != videoAspectRatio )
       
  1963         {
       
  1964             retVal = ETrue;
       
  1965         }
       
  1966     }
       
  1967 
       
  1968     MPX_DEBUG( _L( "CMPXVideoPlaybackControlsController::ShowAspectRatioIcon()[%d]" ), retVal );
       
  1969 
       
  1970     return retVal;
       
  1971 }
       
  1972 
       
  1973 // -------------------------------------------------------------------------------------------------
       
  1974 //   CMPXVideoPlaybackControlsController::HandleLoadingStarted
  2026 //   CMPXVideoPlaybackControlsController::HandleLoadingStarted
  1975 // -------------------------------------------------------------------------------------------------
  2027 // -------------------------------------------------------------------------------------------------
  1976 //
  2028 //
  1977 void CMPXVideoPlaybackControlsController::HandleLoadingStarted()
  2029 void CMPXVideoPlaybackControlsController::HandleLoadingStarted()
  1978 {
  2030 {