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

📄 audioplayerview.cpp

📁 series60 应用程序开发的源代码 series60 应用程序开发的源代码
💻 CPP
字号:
/**
 *
 * @brief Definition of CAudioPlayerView
 *
 * Copyright (c) EMCC Software Ltd 2003
 * @version 1.0
 */

// INCLUDES

// Class include
#include "AudioPlayerView.h"

// System includes
#include <eiklabel.h> // CEikLabel
#include <eikenv.h>   // CEikEnv
#include <stringloader.h> // Stringloader
#include <barsread.h> //
#include <AudioPlayer.rsg> // resources

// User Includes
#include "AudioPlayer.loc"

//======================== MEMBER FUNCTIONS ==================================

/**
* C++ constructor.
*/
CAudioPlayerView::CAudioPlayerView()
{
}

/**
* Destructor
*/
CAudioPlayerView::~CAudioPlayerView()
{
    delete iDisplayStatus;
    delete iEngine;
}

/**
 * Symbian OS 2 phase constructor.
 * Constructs the CAudioPlayerAppView, popping
 * the constructed object from the CleanupStack before returning it.
 *
 * @param aRect The rectangle for this window
 * @return The newly constructed CAudioPlayerAppView
 */
CAudioPlayerView* CAudioPlayerView::NewL(const TRect& aRect)
{
    CAudioPlayerView* self = new (ELeave) CAudioPlayerView();
    CleanupStack::PushL(self);
    self->ConstructL(aRect);
    CleanupStack::Pop(self);
    return self;
}

/**
 * Symbian OS 2nd phase constructor.  Creates a Window for the controls, which it contains.
 * Constructs a label which will be used to indicate the status of the player
 *
 * @param aRect The rectangle for this window
 */
void CAudioPlayerView::ConstructL(const TRect& aRect)
{
    CreateWindowL();
    SetRect(aRect);

    iDisplayStatus = new (ELeave) CEikLabel();
    iDisplayStatus->SetContainerWindowL(*this);
    iDisplayStatus->SetRect(Rect());
    iDisplayStatus->SetAlignment(EHCenterVCenter);

    HBufC* text = StringLoader::LoadLC(R_AUDIOPLAYER_DISPLAY_STOPPED);
    iDisplayStatus->SetTextL(*text);
    CleanupStack::PopAndDestroy(text);

    iDisplayStatus->SetFont(CEikonEnv::Static()->TitleFont());

    ActivateL();
    DrawDeferred();

    iEngine = CAudioPlayerEngine::NewL(*this);
}

/**
* Draw function is used to clear the rectangular area of the control
*
* @param aRect The rectangular that would be drawn to
*/
void CAudioPlayerView::Draw(const TRect& /*aRect*/) const
{
    CWindowGc& gc = SystemGc();
    gc.Clear(Rect());
}

/**
* Framework function returning the number of controls within this one
*
* @return The number of controls
*/
TInt CAudioPlayerView::CountComponentControls() const
{
    return 1;
}
/**
* Used by the framework to get a handle on a particular control within this one
*
* @param aIndex the index of the control to be returned
* @return The control at aIndex
*/
CCoeControl* CAudioPlayerView::ComponentControl(TInt /*aIndex*/) const
{
    return iDisplayStatus;
}

/**
* MAudioPlayerEngineObserver derivation
* Updates the view to inform the user playing has stopped
*/
void CAudioPlayerView::HandlePlayingStoppedL()
{
    HBufC* text = StringLoader::LoadLC(R_AUDIOPLAYER_DISPLAY_STOPPED);
    iDisplayStatus->SetTextL(*text);
    iDisplayStatus->DrawDeferred();
    CleanupStack::PopAndDestroy(text);
}

/**
* Sets the view display to inform the user a tone is being played
* Plays a tone by making a call to the engine.
*/
void CAudioPlayerView::PlayToneL()
{
    HBufC* text = StringLoader::LoadLC(R_AUDIOPLAYER_DISPLAY_PLAYING);
    iDisplayStatus->SetTextL(*text);
    CleanupStack::PopAndDestroy(text);

    iEngine->PlayToneL();
}

/**
* Sets the view display to inform the user a wav is being played
* Plays a wav by making a call to the engine.
*/
void CAudioPlayerView::PlayWavL()
{
    HBufC* text = StringLoader::LoadLC(R_AUDIOPLAYER_DISPLAY_PLAYING);
    iDisplayStatus->SetTextL(*text);
    CleanupStack::PopAndDestroy(text);

    iEngine->PlayWavL();
}

/**
* Sets the view display to inform the user a midi file is being played
* Plays a midi by making a call to the engine.
*/
void CAudioPlayerView::PlayMidiL()
{
    HBufC* text = StringLoader::LoadLC(R_AUDIOPLAYER_DISPLAY_PLAYING);
    iDisplayStatus->SetTextL(*text);
    CleanupStack::PopAndDestroy(text);

    iEngine->PlayMidiL();
}

/**
* Sets the view display to inform the user a stream is being played
* Plays a stream by making a call to the engine.
*/
void CAudioPlayerView::PlayStreamL()
{
    HBufC* text = StringLoader::LoadLC(R_AUDIOPLAYER_DISPLAY_PLAYING);
    iDisplayStatus->SetTextL(*text);
    CleanupStack::PopAndDestroy(text);

    iEngine->PlayStreamL();
}

/**
* Informs the engine to stop playing
* Updates the view display to inform the user that playing has been stopped
*/
void CAudioPlayerView::StopL()
{
    iEngine->Stop();

    HBufC* text = StringLoader::LoadLC(R_AUDIOPLAYER_DISPLAY_STOPPED);
    iDisplayStatus->SetTextL(*text);
    CleanupStack::PopAndDestroy(text);
}

⌨️ 快捷键说明

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