diff -r 112a725ff2c2 -r 8970fbd719ec videoplayback/videoplaybackviews/src/mpxvideobaseplaybackview.cpp --- a/videoplayback/videoplaybackviews/src/mpxvideobaseplaybackview.cpp Wed Mar 31 21:34:36 2010 +0300 +++ b/videoplayback/videoplaybackviews/src/mpxvideobaseplaybackview.cpp Wed Apr 14 15:59:50 2010 +0300 @@ -16,7 +16,7 @@ */ -// Version : %version: 68 % +// Version : %version: e003sa33#71 % // Include Files @@ -67,7 +67,10 @@ #include "mpxvideo_debug.h" #include "mpxvideoplayercustomviewmsgconsts.h" -// Member Functions +// +// Set a constant for the information timeout of 5 seconds +// +const TInt KInformationNoteTimeout = 5000000; // ------------------------------------------------------------------------------------------------- // CMPXVideoBasePlaybackView::CMPXVideoBasePlaybackView() @@ -113,6 +116,8 @@ iCloseAO = CIdle::NewL( CActive::EPriorityStandard ); BaseConstructL( R_MPX_VIDEO_PLAYBACK_VIEW ); + + iAknEventMonitor = static_cast(CCoeEnv::Static()->AppUi())->EventMonitor(); } // ------------------------------------------------------------------------------------------------- @@ -456,6 +461,15 @@ } // + // Register for window visibility changes + // + iContainer->GetWindow().EnableVisibilityChangeEvents(); + + iKeyboardInFocus = ETrue; + iAknEventMonitor->Enable( ETrue ); + iAknEventMonitor->AddObserverL( this ); + + // // Deactivate the CBA set the LSK & RSK to empty // Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_EMPTY ); @@ -493,6 +507,10 @@ // MPX_TRAPD( err, HandleCommandL( EMPXPbvCmdClose ) ); + iAknEventMonitor->Enable( EFalse ); + iAknEventMonitor->RemoveObserver( this ); + iKeyboardInFocus = EFalse; + // // Delete the display handler when the view is deactivated // @@ -533,8 +551,7 @@ } // ------------------------------------------------------------------------------------------------- -// From CAknView -// Foreground event handling function. +// CMPXVideoBasePlaybackView::HandleForegroundEventL() // ------------------------------------------------------------------------------------------------- // void CMPXVideoBasePlaybackView::HandleForegroundEventL( TBool aForeground ) @@ -542,31 +559,20 @@ MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleForegroundEventL()"), _L("aForeground = %d"), aForeground ); - TMPXVideoPlaybackCommand videoCmd = EPbCmdHandleBackground; - if ( aForeground ) { - videoCmd = EPbCmdHandleForeground; iContainer->HandleEventL( EMPXControlCmdHandleForegroundEvent ); + iKeyboardInFocus = ETrue; + + SendWindowCommandL( EPbCmdHandleForeground ); } else { iContainer->HandleEventL( EMPXControlCmdHandleBackgroundEvent ); - } - - // - // create command to pass to playback plugin - // - CMPXCommand* cmd = CMPXCommand::NewL(); - CleanupStack::PushL( cmd ); + iKeyboardInFocus = EFalse; - cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, ETrue ); - cmd->SetTObjectValueL( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback ); - cmd->SetTObjectValueL( KMPXMediaVideoPlaybackCommand, videoCmd ); - cmd->SetTObjectValueL( KMPXMediaVideoAppForeground, IsAppInFrontL() ); - - iPlaybackUtility->CommandL( *cmd ); - CleanupStack::PopAndDestroy( cmd ); + SendWindowCommandL( EPbCmdHandleBackground ); + } CAknView::HandleForegroundEventL( aForeground ); } @@ -873,6 +879,9 @@ { MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandleClosePlaybackViewL()")); + // Reset the playback state to stopped + iPlaybackState = EPbStateStopped; + if ( IsMultiItemPlaylist() ) { RemoveBackgroundSurfaceL(); @@ -1056,7 +1065,6 @@ } } - // ------------------------------------------------------------------------------------------------- // Handle playback error message. // ------------------------------------------------------------------------------------------------- @@ -1080,7 +1088,6 @@ MPX_ENTER_EXIT(_L("CMPXVideoBasePlaybackView::HandlePlaybackCommandComplete()")); } - // ------------------------------------------------------------------------------------------------- // CMPXVideoBasePlaybackView::ParseMetaDataL() // ------------------------------------------------------------------------------------------------- @@ -1377,9 +1384,6 @@ // Handle the plugin error HandlePluginErrorL( error ); - - // Reset the playback state to stopped - iPlaybackState = EPbStateStopped; } else { @@ -1480,6 +1484,7 @@ HBufC* text = StringLoader::LoadLC( aResourceId ); CAknInformationNote* dlg = new (ELeave) CAknInformationNote( aWaitingDialog ); + dlg->SetTimeout( (CAknNoteDialog::TTimeout) KInformationNoteTimeout ); dlg->ExecuteLD( *text ); CleanupStack::PopAndDestroy( text ); } @@ -1517,7 +1522,6 @@ iPlaybackUtility->CommandL( *aCmd ); } - // ------------------------------------------------------------------------------------------------- // CMPXVideoBasePlaybackView::ActivateClosePlayerActiveObject // ------------------------------------------------------------------------------------------------- @@ -1624,10 +1628,9 @@ } } -// --------------------------------------------------------------------------- -// CMPXVideoBasePlaybackView::IsAppInFrontL() -// Returns true if app is foreground. Uses windowgroup id -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- +// CMPXVideoBasePlaybackView::IsAppInFrontL() +// ------------------------------------------------------------------------------------------------- // TBool CMPXVideoBasePlaybackView::IsAppInFrontL() { @@ -1642,15 +1645,14 @@ CArrayFixFlat* wgList = new (ELeave) CArrayFixFlat( wsSession.NumWindowGroups() ); - // check if our window is front or not if ( wsSession.WindowGroupList( 0, wgList ) == KErrNone ) { + // + // If this window group is at the start of the window group array, + // this application is in the front + // ret = ( iCoeEnv->RootWin().Identifier() == wgList->At(0) ); } - else - { - ret = EFalse; - } delete wgList; } @@ -2206,4 +2208,53 @@ } } +// ------------------------------------------------------------------------------------------------- +// CMPXVideoBasePlaybackView::HandleWsEventL() +// ------------------------------------------------------------------------------------------------- +// +void CMPXVideoBasePlaybackView::HandleWsEventL( const TWsEvent& aEvent, + CCoeControl* /*aDestination*/ ) +{ + // + // Fg/Bg events aren't received when the view has lost keyboard focus + // If we are sent to full background, sent a background command to the playback plugin + // + if ( ! iKeyboardInFocus && aEvent.Type() == EEventWindowVisibilityChanged ) + { + MPX_DEBUG(_L("CMpxVideoPlayerAppUi::HandleWsEventL() EEventWindowVisibilityChanged")); + + TUint visible = aEvent.VisibilityChanged()->iFlags; + + if ( visible & TWsVisibilityChangedEvent::ENotVisible ) + { + MPX_DEBUG(_L("CMpxVideoPlayerAppUi::HandleWsEventL() ENotVisible")); + SendWindowCommandL( EPbCmdHandleBackground ); + } + } +} + +// ------------------------------------------------------------------------------------------------- +// CMPXVideoBasePlaybackView::SendWindowCommandL() +// ------------------------------------------------------------------------------------------------- +// +void CMPXVideoBasePlaybackView::SendWindowCommandL( TMPXVideoPlaybackCommand aCmd ) +{ + MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUi::SendWindowCommandL()"), + _L("aCmd = %d"), aCmd ); + + // + // create command to pass to playback plugin + // + CMPXCommand* cmd = CMPXCommand::NewL(); + CleanupStack::PushL( cmd ); + + cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, ETrue ); + cmd->SetTObjectValueL( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback ); + cmd->SetTObjectValueL( KMPXMediaVideoPlaybackCommand, aCmd ); + cmd->SetTObjectValueL( KMPXMediaVideoAppForeground, IsAppInFrontL() ); + + iPlaybackUtility->CommandL( *cmd ); + CleanupStack::PopAndDestroy( cmd ); +} + // EOF