videoplayback/videoplaybackviews/src/mpxvideobaseplaybackview.cpp
branchRCL_3
changeset 11 8970fbd719ec
parent 10 112a725ff2c2
child 12 7f2b2a65da29
equal deleted inserted replaced
10:112a725ff2c2 11:8970fbd719ec
    14 * Description:   Implementation of Video base playback view
    14 * Description:   Implementation of Video base playback view
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // Version : %version: 68 %
    19 // Version : %version: e003sa33#71 %
    20 
    20 
    21 
    21 
    22 //  Include Files
    22 //  Include Files
    23 
    23 
    24 #include <aknViewAppUi.h>
    24 #include <aknViewAppUi.h>
    65 #include <mpxvideoplaybackdefs.h>
    65 #include <mpxvideoplaybackdefs.h>
    66 #include "mpxmediavideodefs.h"
    66 #include "mpxmediavideodefs.h"
    67 #include "mpxvideo_debug.h"
    67 #include "mpxvideo_debug.h"
    68 #include "mpxvideoplayercustomviewmsgconsts.h"
    68 #include "mpxvideoplayercustomviewmsgconsts.h"
    69 
    69 
    70 //  Member Functions
    70 //
       
    71 //  Set a constant for the information timeout of 5 seconds
       
    72 //
       
    73 const TInt KInformationNoteTimeout = 5000000;
    71 
    74 
    72 // -------------------------------------------------------------------------------------------------
    75 // -------------------------------------------------------------------------------------------------
    73 // CMPXVideoBasePlaybackView::CMPXVideoBasePlaybackView()
    76 // CMPXVideoBasePlaybackView::CMPXVideoBasePlaybackView()
    74 // -------------------------------------------------------------------------------------------------
    77 // -------------------------------------------------------------------------------------------------
    75 //
    78 //
   111     //  Create Active Object for closing player
   114     //  Create Active Object for closing player
   112     //
   115     //
   113     iCloseAO = CIdle::NewL( CActive::EPriorityStandard );
   116     iCloseAO = CIdle::NewL( CActive::EPriorityStandard );
   114 
   117 
   115     BaseConstructL( R_MPX_VIDEO_PLAYBACK_VIEW );
   118     BaseConstructL( R_MPX_VIDEO_PLAYBACK_VIEW );
       
   119 
       
   120     iAknEventMonitor = static_cast<CAknAppUiBase*>(CCoeEnv::Static()->AppUi())->EventMonitor();
   116 }
   121 }
   117 
   122 
   118 // -------------------------------------------------------------------------------------------------
   123 // -------------------------------------------------------------------------------------------------
   119 // CMPXVideoBasePlaybackView::~CMPXVideoBasePlaybackView()
   124 // CMPXVideoBasePlaybackView::~CMPXVideoBasePlaybackView()
   120 // -------------------------------------------------------------------------------------------------
   125 // -------------------------------------------------------------------------------------------------
   454         //
   459         //
   455         iDisplayHandler = CMPXVideoPlaybackDisplayHandler::NewL( iPlaybackUtility, iContainer );
   460         iDisplayHandler = CMPXVideoPlaybackDisplayHandler::NewL( iPlaybackUtility, iContainer );
   456     }
   461     }
   457 
   462 
   458     //
   463     //
       
   464     //  Register for window visibility changes
       
   465     //
       
   466     iContainer->GetWindow().EnableVisibilityChangeEvents();
       
   467 
       
   468     iKeyboardInFocus = ETrue;
       
   469     iAknEventMonitor->Enable( ETrue );
       
   470     iAknEventMonitor->AddObserverL( this );
       
   471 
       
   472     //
   459     //  Deactivate the CBA set the LSK & RSK to empty
   473     //  Deactivate the CBA set the LSK & RSK to empty
   460     //
   474     //
   461     Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_EMPTY );
   475     Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_EMPTY );
   462 
   476 
   463     //
   477     //
   491     //
   505     //
   492     //  Close the playback plugin to release all references to previous clip
   506     //  Close the playback plugin to release all references to previous clip
   493     //
   507     //
   494     MPX_TRAPD( err, HandleCommandL( EMPXPbvCmdClose ) );
   508     MPX_TRAPD( err, HandleCommandL( EMPXPbvCmdClose ) );
   495 
   509 
       
   510     iAknEventMonitor->Enable( EFalse );
       
   511     iAknEventMonitor->RemoveObserver( this );
       
   512     iKeyboardInFocus = EFalse;
       
   513 
   496     //
   514     //
   497     //  Delete the display handler when the view is deactivated
   515     //  Delete the display handler when the view is deactivated
   498     //
   516     //
   499     if ( iDisplayHandler )
   517     if ( iDisplayHandler )
   500     {
   518     {
   531         iClipName = NULL;
   549         iClipName = NULL;
   532     }
   550     }
   533 }
   551 }
   534 
   552 
   535 // -------------------------------------------------------------------------------------------------
   553 // -------------------------------------------------------------------------------------------------
   536 // From CAknView
   554 //   CMPXVideoBasePlaybackView::HandleForegroundEventL()
   537 // Foreground event handling function.
       
   538 // -------------------------------------------------------------------------------------------------
   555 // -------------------------------------------------------------------------------------------------
   539 //
   556 //
   540 void CMPXVideoBasePlaybackView::HandleForegroundEventL( TBool aForeground )
   557 void CMPXVideoBasePlaybackView::HandleForegroundEventL( TBool aForeground )
   541 {
   558 {
   542     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleForegroundEventL()"),
   559     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleForegroundEventL()"),
   543                    _L("aForeground = %d"), aForeground );
   560                    _L("aForeground = %d"), aForeground );
   544 
   561 
   545     TMPXVideoPlaybackCommand videoCmd = EPbCmdHandleBackground;
       
   546 
       
   547     if ( aForeground )
   562     if ( aForeground )
   548     {
   563     {
   549         videoCmd = EPbCmdHandleForeground;
       
   550         iContainer->HandleEventL( EMPXControlCmdHandleForegroundEvent );
   564         iContainer->HandleEventL( EMPXControlCmdHandleForegroundEvent );
       
   565         iKeyboardInFocus = ETrue;
       
   566 
       
   567         SendWindowCommandL( EPbCmdHandleForeground );
   551     }
   568     }
   552     else
   569     else
   553     {
   570     {
   554         iContainer->HandleEventL( EMPXControlCmdHandleBackgroundEvent );
   571         iContainer->HandleEventL( EMPXControlCmdHandleBackgroundEvent );
   555     }
   572         iKeyboardInFocus = EFalse;
   556 
   573 
   557     //
   574         SendWindowCommandL( EPbCmdHandleBackground );
   558     //  create command to pass to playback plugin
   575     }
   559     //
       
   560     CMPXCommand* cmd = CMPXCommand::NewL();
       
   561     CleanupStack::PushL( cmd );
       
   562 
       
   563     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
   564     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
   565     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand, videoCmd );
       
   566     cmd->SetTObjectValueL<TBool>( KMPXMediaVideoAppForeground, IsAppInFrontL() );
       
   567 
       
   568     iPlaybackUtility->CommandL( *cmd );
       
   569     CleanupStack::PopAndDestroy( cmd );
       
   570 
   576 
   571     CAknView::HandleForegroundEventL( aForeground );
   577     CAknView::HandleForegroundEventL( aForeground );
   572 }
   578 }
   573 
   579 
   574 // -------------------------------------------------------------------------------------------------
   580 // -------------------------------------------------------------------------------------------------
   871 //
   877 //
   872 void CMPXVideoBasePlaybackView::HandleClosePlaybackViewL()
   878 void CMPXVideoBasePlaybackView::HandleClosePlaybackViewL()
   873 {
   879 {
   874     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleClosePlaybackViewL()"));
   880     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleClosePlaybackViewL()"));
   875 
   881 
       
   882     // Reset the playback state to stopped
       
   883     iPlaybackState = EPbStateStopped;
       
   884     
   876     if ( IsMultiItemPlaylist() )
   885     if ( IsMultiItemPlaylist() )
   877     {
   886     {
   878         RemoveBackgroundSurfaceL();
   887         RemoveBackgroundSurfaceL();
   879 
   888 
   880         iPlaybackUtility->CommandL( EPbCmdNext );
   889         iPlaybackUtility->CommandL( EPbCmdNext );
  1054             iContainer->HandleEventL( EMPXControlCmdStateChanged, aNewState );
  1063             iContainer->HandleEventL( EMPXControlCmdStateChanged, aNewState );
  1055         }
  1064         }
  1056     }
  1065     }
  1057 }
  1066 }
  1058 
  1067 
  1059 
       
  1060 // -------------------------------------------------------------------------------------------------
  1068 // -------------------------------------------------------------------------------------------------
  1061 // Handle playback error message.
  1069 // Handle playback error message.
  1062 // -------------------------------------------------------------------------------------------------
  1070 // -------------------------------------------------------------------------------------------------
  1063 //
  1071 //
  1064 void CMPXVideoBasePlaybackView::DoHandleErrorPlaybackMessageL( TInt aError )
  1072 void CMPXVideoBasePlaybackView::DoHandleErrorPlaybackMessageL( TInt aError )
  1077 void CMPXVideoBasePlaybackView::HandlePlaybackCommandComplete( CMPXCommand* /*aCommandResult*/,
  1085 void CMPXVideoBasePlaybackView::HandlePlaybackCommandComplete( CMPXCommand* /*aCommandResult*/,
  1078                                                                TInt /*aError*/ )
  1086                                                                TInt /*aError*/ )
  1079 {
  1087 {
  1080     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandlePlaybackCommandComplete()"));
  1088     MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandlePlaybackCommandComplete()"));
  1081 }
  1089 }
  1082 
       
  1083 
  1090 
  1084 // -------------------------------------------------------------------------------------------------
  1091 // -------------------------------------------------------------------------------------------------
  1085 // CMPXVideoBasePlaybackView::ParseMetaDataL()
  1092 // CMPXVideoBasePlaybackView::ParseMetaDataL()
  1086 // -------------------------------------------------------------------------------------------------
  1093 // -------------------------------------------------------------------------------------------------
  1087 //
  1094 //
  1375             // Set the iMediaRequested flag to false
  1382             // Set the iMediaRequested flag to false
  1376             iMediaRequested = EFalse;
  1383             iMediaRequested = EFalse;
  1377 
  1384 
  1378             // Handle the plugin error
  1385             // Handle the plugin error
  1379             HandlePluginErrorL( error );
  1386             HandlePluginErrorL( error );
  1380 
       
  1381             // Reset the playback state to stopped
       
  1382             iPlaybackState = EPbStateStopped;
       
  1383         }
  1387         }
  1384         else
  1388         else
  1385         {
  1389         {
  1386             DoHandleMediaL( aMedia, aError );
  1390             DoHandleMediaL( aMedia, aError );
  1387         }
  1391         }
  1478                    _L("resource = %08x"), aResourceId );
  1482                    _L("resource = %08x"), aResourceId );
  1479 
  1483 
  1480     HBufC* text = StringLoader::LoadLC( aResourceId );
  1484     HBufC* text = StringLoader::LoadLC( aResourceId );
  1481 
  1485 
  1482     CAknInformationNote* dlg = new (ELeave) CAknInformationNote( aWaitingDialog );
  1486     CAknInformationNote* dlg = new (ELeave) CAknInformationNote( aWaitingDialog );
       
  1487     dlg->SetTimeout( (CAknNoteDialog::TTimeout) KInformationNoteTimeout );
  1483     dlg->ExecuteLD( *text );
  1488     dlg->ExecuteLD( *text );
  1484     CleanupStack::PopAndDestroy( text );
  1489     CleanupStack::PopAndDestroy( text );
  1485 }
  1490 }
  1486 
  1491 
  1487 // -------------------------------------------------------------------------------------------------
  1492 // -------------------------------------------------------------------------------------------------
  1515                                                       EPbCmdInitView );
  1520                                                       EPbCmdInitView );
  1516 
  1521 
  1517     iPlaybackUtility->CommandL( *aCmd );
  1522     iPlaybackUtility->CommandL( *aCmd );
  1518 }
  1523 }
  1519 
  1524 
  1520 
       
  1521 // -------------------------------------------------------------------------------------------------
  1525 // -------------------------------------------------------------------------------------------------
  1522 //   CMPXVideoBasePlaybackView::ActivateClosePlayerActiveObject
  1526 //   CMPXVideoBasePlaybackView::ActivateClosePlayerActiveObject
  1523 // -------------------------------------------------------------------------------------------------
  1527 // -------------------------------------------------------------------------------------------------
  1524 //
  1528 //
  1525 void CMPXVideoBasePlaybackView::ActivateClosePlayerActiveObject()
  1529 void CMPXVideoBasePlaybackView::ActivateClosePlayerActiveObject()
  1622     {
  1626     {
  1623         iContainer->HandleEventL( EMPXControlCmdSetAspectRatio, newAspectRatio );
  1627         iContainer->HandleEventL( EMPXControlCmdSetAspectRatio, newAspectRatio );
  1624     }
  1628     }
  1625 }
  1629 }
  1626 
  1630 
  1627 // ---------------------------------------------------------------------------
  1631 // -------------------------------------------------------------------------------------------------
  1628 // CMPXVideoBasePlaybackView::IsAppInFrontL()
  1632 //   CMPXVideoBasePlaybackView::IsAppInFrontL()
  1629 // Returns true if app is foreground. Uses windowgroup id
  1633 // -------------------------------------------------------------------------------------------------
  1630 // ---------------------------------------------------------------------------
       
  1631 //
  1634 //
  1632 TBool CMPXVideoBasePlaybackView::IsAppInFrontL()
  1635 TBool CMPXVideoBasePlaybackView::IsAppInFrontL()
  1633 {
  1636 {
  1634     TBool ret = EFalse;
  1637     TBool ret = EFalse;
  1635     RWsSession wsSession;
  1638     RWsSession wsSession;
  1640     if ( wsSession.Handle() )
  1643     if ( wsSession.Handle() )
  1641     {
  1644     {
  1642         CArrayFixFlat<TInt>* wgList =
  1645         CArrayFixFlat<TInt>* wgList =
  1643             new (ELeave) CArrayFixFlat<TInt>( wsSession.NumWindowGroups() );
  1646             new (ELeave) CArrayFixFlat<TInt>( wsSession.NumWindowGroups() );
  1644 
  1647 
  1645         // check if our window is front or not
       
  1646         if ( wsSession.WindowGroupList( 0, wgList ) == KErrNone )
  1648         if ( wsSession.WindowGroupList( 0, wgList ) == KErrNone )
  1647         {
  1649         {
       
  1650             //
       
  1651             //  If this window group is at the start of the window group array,
       
  1652             //  this application is in the front
       
  1653             //
  1648             ret = ( iCoeEnv->RootWin().Identifier() == wgList->At(0) );
  1654             ret = ( iCoeEnv->RootWin().Identifier() == wgList->At(0) );
  1649         }
       
  1650         else
       
  1651         {
       
  1652             ret = EFalse;
       
  1653         }
  1655         }
  1654 
  1656 
  1655         delete wgList;
  1657         delete wgList;
  1656     }
  1658     }
  1657 
  1659 
  2204         CreateGeneralPlaybackCommandL( EPbCmdPlay );
  2206         CreateGeneralPlaybackCommandL( EPbCmdPlay );
  2205         iRealOneDelayedPlay = EFalse;
  2207         iRealOneDelayedPlay = EFalse;
  2206     }
  2208     }
  2207 }
  2209 }
  2208 
  2210 
       
  2211 // -------------------------------------------------------------------------------------------------
       
  2212 //   CMPXVideoBasePlaybackView::HandleWsEventL()
       
  2213 // -------------------------------------------------------------------------------------------------
       
  2214 //
       
  2215 void CMPXVideoBasePlaybackView::HandleWsEventL( const TWsEvent& aEvent,
       
  2216                                                 CCoeControl* /*aDestination*/ )
       
  2217 {
       
  2218     //
       
  2219     //  Fg/Bg events aren't received when the view has lost keyboard focus
       
  2220     //  If we are sent to full background, sent a background command to the playback plugin
       
  2221     //
       
  2222     if ( ! iKeyboardInFocus && aEvent.Type() == EEventWindowVisibilityChanged )
       
  2223     {
       
  2224         MPX_DEBUG(_L("CMpxVideoPlayerAppUi::HandleWsEventL() EEventWindowVisibilityChanged"));
       
  2225 
       
  2226         TUint visible = aEvent.VisibilityChanged()->iFlags;
       
  2227 
       
  2228         if ( visible & TWsVisibilityChangedEvent::ENotVisible )
       
  2229         {
       
  2230             MPX_DEBUG(_L("CMpxVideoPlayerAppUi::HandleWsEventL() ENotVisible"));
       
  2231             SendWindowCommandL( EPbCmdHandleBackground );
       
  2232         }
       
  2233     }
       
  2234 }
       
  2235 
       
  2236 // -------------------------------------------------------------------------------------------------
       
  2237 //   CMPXVideoBasePlaybackView::SendWindowCommandL()
       
  2238 // -------------------------------------------------------------------------------------------------
       
  2239 //
       
  2240 void CMPXVideoBasePlaybackView::SendWindowCommandL( TMPXVideoPlaybackCommand aCmd )
       
  2241 {
       
  2242     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUi::SendWindowCommandL()"),
       
  2243                    _L("aCmd = %d"), aCmd );
       
  2244 
       
  2245     //
       
  2246     //  create command to pass to playback plugin
       
  2247     //
       
  2248     CMPXCommand* cmd = CMPXCommand::NewL();
       
  2249     CleanupStack::PushL( cmd );
       
  2250 
       
  2251     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  2252     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  2253     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand, aCmd );
       
  2254     cmd->SetTObjectValueL<TBool>( KMPXMediaVideoAppForeground, IsAppInFrontL() );
       
  2255 
       
  2256     iPlaybackUtility->CommandL( *cmd );
       
  2257     CleanupStack::PopAndDestroy( cmd );
       
  2258 }
       
  2259 
  2209 // EOF
  2260 // EOF