⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 videoappui.cpp

📁 NOKIA S60手机3gp视频播放器源代码.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
* ============================================================================
*  Name     : CVideoAppUi from VideoAppUi.cpp
*  Part of  : Video
*  Created  : 10/14/2003 by Forum Nokia
*  Implementation notes:
*  Version  :
*  Copyright: Nokia Corporation, 2003
* ============================================================================
*/

#include "VideoAppUi.h"
#include "VideoContainer.h" 
#include <Video.rsg>
#include "video.hrh"
#include "VideoEngine.h"
#include "VideoNaviDecoratorTime.h"
#include "VideoFileDetailsDialog.h"

#include <avkon.hrh>
#include <documenthandler.h>
#include <apmstd.h>
#include <aknnavi.h>
#include <aknnavide.h>
#include <stringloader.h>
#include <eikmenup.h>

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::ConstructL()

	Description: second phase constructor
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::ConstructL()
    {
    BaseConstructL();

    iAppContainer = new (ELeave) CVideoContainer;
    iAppContainer->SetMopParent( this );
    iAppContainer->ConstructL( ClientRect() );
    AddToStackL( iAppContainer );

	iEngine = CVideoEngine::NewL();

    // Show tabs for main views from resources
    CEikStatusPane* sp = StatusPane();
    iNaviPane = (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));

	iTimeNavi =  CreateTimeNaviL();
	iNaviPane->PushL( *iTimeNavi );

    // Read time format strings from AVKON resource;
    iMinSecFormatString = 
        iEikonEnv->AllocReadResourceL(R_QTN_TIME_DURAT_MIN_SEC); 
   
    iHourMinSecFormatString = 
        iEikonEnv->AllocReadResourceL(R_QTN_TIME_DURAT_LONG);

	iCba = NULL;
    }

/*
-----------------------------------------------------------------------------

	CVideoAppUi::~CVideoAppUi()

	Description: destructor, free all the resources
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
CVideoAppUi::~CVideoAppUi()
    {
    if ( iAppContainer )
        {
        RemoveFromStack( iAppContainer );
        delete iAppContainer;
        }

	delete iEngine;
	delete iTimeNavi;

    delete iMinSecFormatString;
    delete iHourMinSecFormatString;
   }

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::DynInitMenuPaneL(
			TInt aResourceId,CEikMenuPane* aMenuPane)

	Description: This function is called by the EIKON framework just before 
				 it displays a menu pane. Its default implementation is empty, 
				 and by overriding it, the application can set the state of menu 
				 items dynamically according to the state of application data.
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::DynInitMenuPaneL(
    TInt aResourceId,CEikMenuPane* aMenuPane)
    {
    if ( aResourceId == R_VIDEO_MENU )
		{
		// Check whether the database has been created or not
		if ( iEngine->GetEngineState() != EPPlaying )
			{
			// The video clip is not being played
			aMenuPane->SetItemDimmed( EVideoCmdAppStop, ETrue );
			aMenuPane->SetItemDimmed( EVideoCmdAppPause, ETrue );
			}

		// If there is no item in the list box, hide the play, docplay
		// and file info menu items
		if ( !iAppContainer->GetNumOfItemsInListBox() )
			{
			aMenuPane->SetItemDimmed( EVideoCmdAppDocFileInfo, ETrue );
			aMenuPane->SetItemDimmed( EVideoCmdAppDocPlay, ETrue );
			aMenuPane->SetItemDimmed( EVideoCmdAppPlay, ETrue );
			}

		}
    }

/*
-----------------------------------------------------------------------------

	TKeyResponse CVideoAppUi::HandleKeyEventL(
			const TKeyEvent& aKeyEvent,TEventCode aType)

	Description: takes care of key event handling
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
TKeyResponse CVideoAppUi::HandleKeyEventL(
    const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
    {
    return EKeyWasNotConsumed;
    }

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::HandleCommandL(TInt aCommand)

	Description: takes care of command handling
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
        {
		case EAknSoftkeyExit:
        case EAknSoftkeyBack:
        case EEikCmdExit:
            {
            Exit();
            break;
            }
       
		// Play command is selected
		case EVideoCmdAppPlay:
			{
			DoPlayL();
			break;
			}

        // Stop command is selected
		case EVideoCmdAppStop:
			{
			DoStopL();
			break;
			}
        
        // Pause command is selected
		case EVideoCmdAppPause:
			{
			DoPauseL();
			break;
			}

		// DocPlay command is selected
		case EVideoCmdAppDocPlay:
			{
			DoDocPlayL();
			break;
			}

        // File info command is selected
		case EVideoCmdAppDocFileInfo:
			{
			DoGetFileInfoL();
			break;
			}
			
		// Continuer command is selected
		case EVideoCmdAppContinue:
			{
			DoResumeL();
			break;
			}

        // Return command is selected
		case EVideoCmdAppReturn:
			{
			DoStopL();
			break;
			}

        default:
            break;      
        }
    }

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::DoPlayL()

	Description: Call engine to play a video clip
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::DoPlayL()
	{
	// Set the file name first
	TFileName fileName;
	iAppContainer->GetCurrentVideoFileNameL( fileName );

	// Play the video file
	PlayVideoFileL( fileName );

	// We need change the memu to something else "Pause" and "Stop".	
	iCba = CEikButtonGroupContainer::Current();

	if( iCba) 
		{
		iCba->SetCommandSetL( R_VIDEO_PAUSE_STOP );
		iCba->DrawNow();
		}
	}

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::DoResumeL()

	Description: Resumes a paused video clip
	Comments   :

    Return values: N/A

-----------------------------------------------------------------------------
*/
void CVideoAppUi::DoResumeL()
	{
	if ( iEngine->GetEngineState() != EPPaused )
		return;

	iEngine->DoPlayL();
	
	// We need change the memu to something else "Pause" and "Stop".	
	iCba = CEikButtonGroupContainer::Current();

	if( iCba) 
		{
		iCba->SetCommandSetL( R_VIDEO_PAUSE_STOP );
		iCba->DrawNow();
		}
	}

/*
-----------------------------------------------------------------------------

	void CVideoAppUi::PlayVideoFileL(TDesC &aFileName)

	Description: Play a video file
	Comments   :

    Return values: N/A

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -