videoplayerappui.cpp

来自「《基于Symbian OS的手机开发与应用实践》这本书的配套源码。」· C++ 代码 · 共 120 行

CPP
120
字号
/*
* ============================================================================
*  Name     : CVideoPlayerAppUi from VideoPlayerAppui.cpp
*  Part of  : VideoPlayer
*  Created  : 31.01.2006 by ToBeReplacedByAuthor
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  :
*  Copyright: ToBeReplacedByCopyright
* ============================================================================
*/

// INCLUDE FILES
#include <avkon.hrh>
#include <aknutils.h>
#include <eikbtgpc.h>
#include <VideoPlayer.rsg>
#include "VideoPlayer.hrh"

#include "VideoPlayerAppui.h"
#include "VideoPlayerContainer.h" 

// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CVideoPlayerAppUi::ConstructL()
// 
// ----------------------------------------------------------
//
void CVideoPlayerAppUi::ConstructL()
    {
    BaseConstructL();

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

    iVideoPlayerEngine = CVideoPlayerEngine::NewL(*this, *(iAppContainer->DrawableWindow()));

    AddToStackL( iAppContainer );
    }

// ----------------------------------------------------
// CVideoPlayerAppUi::~CVideoPlayerAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CVideoPlayerAppUi::~CVideoPlayerAppUi()
    {
    if (iAppContainer)
        {
        RemoveFromStack( iAppContainer );
        delete iAppContainer;
        }
    delete iVideoPlayerEngine;
    }

// ----------------------------------------------------
// CVideoPlayerAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CVideoPlayerAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
        {
        case EAknSoftkeyBack:
        case EEikCmdExit:
            {
            Exit();
            break;
            }
        case EVideoPlayerCmdPlay:
            {
            _LIT(KVideoFile, "video.3gp");
            TFileName videoFile(KVideoFile);
            CompleteWithAppPath(videoFile);
            iVideoPlayerEngine->PlayL(videoFile);
            SetCbaL(R_SOFTKEYS_PAUSE_STOP);
            break;
            }
        case EVideoPlayerCmdPause:
            {
            iVideoPlayerEngine->PauseL();
            SetCbaL(R_SOFTKEYS_CONTINUE_STOP);
            break;
            }
        case EVideoPlayerCmdContinue:
            {
            iVideoPlayerEngine->Play();
            SetCbaL(R_SOFTKEYS_PAUSE_STOP);
            break;
            }
        case EVideoPlayerCmdStop:
            {
            iVideoPlayerEngine->Stop();
            SetCbaL(R_SOFTKEYS_PLAY_EXIT);
            break;
            }
        default:
            break;      
        }
    }

void CVideoPlayerAppUi::OnComplete(TInt aError)
    {
    TRAPD(err, SetCbaL(R_SOFTKEYS_PLAY_EXIT));
    }


void CVideoPlayerAppUi::SetCbaL(TInt aResourceId)
    {
    CEikButtonGroupContainer* cba = Cba();
    cba->SetCommandSetL(aResourceId);
    cba->DrawDeferred();
    }

// End of File  

⌨️ 快捷键说明

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