📄 vrexvideoview.cpp
字号:
/*
* ============================================================================
* Name : CVRexVideoView from VRexVideoView.cpp
* Part of : Video Example
* Created : 30/08/2006 by Forum Nokia
* Implementation notes:
* Version : 2.0
* Copyright: Nokia Corporation, 2006
* ============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <VRex.rsg>
#include <eikmenub.h> // CEikMenuBar
#include <eikmenup.h> // CEikMenuPane
#include <coecntrl.h>
#include <coemain.h>
#include "VRexVideoView.h"
#include "VRexVideoContainer.h"
#include "VRexDocument.h"
#include "VRexEngine.h"
#include <avkon.rsg>
#include <avkon.hrh>
_LIT( KVRexLoading, "Loading ..." );
// ================= MEMBER FUNCTIONS =======================
CVRexVideoView::CVRexVideoView()
: iEngine(static_cast<CVRexDocument*>(AppUi()->Document())->Engine())
{
}
// ---------------------------------------------------------
// CVRexVideoView::ConstructL(const TRect& aRect)
// EPOC two-phased constructor
// ---------------------------------------------------------
//
void CVRexVideoView::ConstructL()
{
BaseConstructL( R_VIEW2 );
}
// ---------------------------------------------------------
// CVRexVideoView::~CVRexVideoView()
// destructor
// ---------------------------------------------------------
//
CVRexVideoView::~CVRexVideoView()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
}
// ---------------------------------------------------------
// TUid CVRexVideoView::Id()
//
// ---------------------------------------------------------
//
TUid CVRexVideoView::Id() const
{
return KView2Id;
}
// ---------------------------------------------------------
// CVRexVideoView::HandleCommandL(TInt aCommand)
// takes care of view command handling
// ---------------------------------------------------------
//
void CVRexVideoView::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EVRexCmdAppReturn:
{
DoReturnL();
break;
}
case EVRexCmdAppRecord:
{
DoRecordL();
break;
}
case EVRexCmdAppStop:
{
DoStopL();
break;
}
case EVRexCmdAppPause:
{
DoPauseL();
break;
}
case EVRexCmdAppContinue:
{
DoResumeL();
break;
}
default:
{
AppUi()->HandleCommandL( aCommand );
break;
}
}
}
// ---------------------------------------------------------
// CVRexVideoView::HandleClientRectChange()
// ---------------------------------------------------------
//
void CVRexVideoView::HandleClientRectChange()
{
if ( iContainer )
{
iContainer->SetRect( ClientRect() );
}
}
// ---------------------------------------------------------
// CVRexVideoView::DoActivateL(...)
//
// ---------------------------------------------------------
//
void CVRexVideoView::DoActivateL(
const TVwsViewId& aPrevViewId,TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
// save info about previous view
iPrevious = aPrevViewId;
if (!iContainer)
{
iContainer = new (ELeave) CVRexVideoContainer;
iContainer->SetMopParent(this);
iContainer->ConstructL( ClientRect(), this, iEngine );
AppUi()->AddToStackL( *this, iContainer );
if(iEngine->EngineState() == CVRexEngine::EPreview)
{
iContainer->Finder()->StartL();
SwitchCbaL(R_VREX_RECORD_RETURN);
}
else if (iEngine->EngineState() == CVRexEngine::EPlay)
{
TFileName fileName = iEngine->CurrentFileName();
iEngine->iVPlayer->SetNewFileL(fileName);
// Set time navi pane to indicate loading
iContainer->SetNaviLabelL( KVRexLoading );
// Init the controller
DoInitControllerL();
SwitchCbaL(R_VREX_PAUSE_STOP);
}
else
User::Leave(KErrGeneral);
}
}
// ---------------------------------------------------------
// CVRexVideoView::DoDeactivate()
//
// ---------------------------------------------------------
//
void CVRexVideoView::DoDeactivate()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
iContainer = NULL;
}
/*
-----------------------------------------------------------------------------
void CVRexVideoView::DoRecordL()
Description: This method starts recording a video clip.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexVideoView::DoRecordL()
{
iEngine->SetEngineState(CVRexEngine::ERecord);
if( iEngine->iVRecorder )
{
iEngine->iVRecorder->StartL(iContainer,
iContainer->Finder()->CameraHandle());
SwitchCbaL(R_VREX_STOP);
}
else
{
User::Leave(KErrNotSupported);
}
}
/*
-----------------------------------------------------------------------------
void CVRexVideoView::DoResumeL()
Description: This method resumes playback of a video clip.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexVideoView::DoResumeL()
{
if(iEngine->iVPlayer->State() != CVideoPlayerAdapter::EPaused)
return;
iEngine->iVPlayer->PlayL();
SwitchCbaL(R_VREX_PAUSE_STOP);
}
/*
-----------------------------------------------------------------------------
void CVRexVideoView::DoStopL()
Description: This method stops playback or recording of a video clip.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexVideoView::DoStopL()
{
iContainer->SetNaviLabelL(KNullDesC);
if((iEngine->iVPlayer->State() == CVideoPlayerAdapter::EPlaying) ||
(iEngine->iVPlayer->State() == CVideoPlayerAdapter::EPaused))
iEngine->iVPlayer->Stop();
//A check is done to see if the recorder object is constructed.
//For example in 6600 it can't be constructed
if( iEngine->iVRecorder )
{
if(iEngine->iVRecorder->State() == CVideoRecorderAdapter::ERecording)
iEngine->iVRecorder->StopL();
}
}
/*
-----------------------------------------------------------------------------
void CVRexVideoView::DoPauseL()
Description: This method pauses playback of video clip.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexVideoView::DoPauseL()
{
if(iEngine->iVPlayer->State() == CVideoPlayerAdapter::EPlaying)
{
iEngine->iVPlayer->PauseL();
SwitchCbaL(R_VREX_CONTINUE_RETURN);
}
}
/*
-----------------------------------------------------------------------------
void CVRexVideoView::DoInitControllerL()
Description: This method initializes video playback controller.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexVideoView::DoInitControllerL()
{
if(iContainer)
{
TRect tmp = iContainer->VideoRect();
iEngine->iVPlayer->InitControllerL(iContainer,
iContainer->ClientWsSession(),
iContainer->ScreenDevice(),
iContainer->ClientWindow(), tmp, tmp);
}
}
/*
-----------------------------------------------------------------------------
void CVRexVideoView::DoReturnL()
Description: This method returns app to previous view.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexVideoView::DoReturnL()
{
if (iEngine->EngineState()== CVRexEngine::EPreview)
{
iContainer->Finder()->Stop();
ActivateViewL(iPrevious);
}
else if(iEngine->EngineState()== CVRexEngine::EPlay &&
iEngine->iVPlayer->State() == CVideoPlayerAdapter::EPaused)
{
iEngine->iVPlayer->Stop();
}
else
{
ActivateViewL(iPrevious);
}
}
/*
-----------------------------------------------------------------------------
void CVRexVideoView::HandleStatusPaneSizeChange()
Description: Called by framework when resource is changed.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexVideoView::HandleStatusPaneSizeChange()
{
CAknView::HandleStatusPaneSizeChange(); //call to upper class
if (iContainer)
iContainer->SetRect(ClientRect());
}
/*
-----------------------------------------------------------------------------
CVRexVideoView::SwitchCbaL(TInt aResourceId)
Description: This method changes the CBA, 0 resets to default CBA.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexVideoView::SwitchCbaL(TInt aResourceId)
{
if (aResourceId == 0)
aResourceId = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
CEikButtonGroupContainer* cba = Cba();
cba->SetCommandSetL(aResourceId);
cba->DrawNow();
}
// End of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -