📄 audioplayerappview.cpp
字号:
/*
============================================================================
Name : AudioPlayerAppView.cpp
Author : Lion
Copyright : Your copyright notice
Description : Application view implementation
============================================================================
*/
// INCLUDE FILES
#include <coemain.h>
#include "AudioPlayerAppView.h"
#include "MyPlayer.h"
#include <eiklabel.h>
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CAudioPlayerAppView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
_LIT(KMusicName, "c:\\audio_sample.amr");
CAudioPlayerAppView* CAudioPlayerAppView::NewL( const TRect& aRect )
{
CAudioPlayerAppView* self = CAudioPlayerAppView::NewLC( aRect );
CleanupStack::Pop( self );
return self;
}
// -----------------------------------------------------------------------------
// CAudioPlayerAppView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CAudioPlayerAppView* CAudioPlayerAppView::NewLC( const TRect& aRect )
{
CAudioPlayerAppView* self = new ( ELeave ) CAudioPlayerAppView;
CleanupStack::PushL( self );
self->ConstructL( aRect );
return self;
}
// -----------------------------------------------------------------------------
// CAudioPlayerAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CAudioPlayerAppView::ConstructL( const TRect& aRect )
{
// Create a window for this application view
CreateWindowL();
iLabel = new (ELeave) CEikLabel;
iLabel->SetContainerWindowL(*this);
iLabel->SetTextL(_L("AudioPlayer"));
iPlayer = new (ELeave) CMyPlayer;
iPlayer->CreatePlayerL(KMusicName);
iPlayer->SetContainer(this);
// iPlayer->PlaySound();
// Set the windows size
SetRect( aRect );
// Activate the window, which makes it ready to be drawn
ActivateL();
}
// -----------------------------------------------------------------------------
// CAudioPlayerAppView::CAudioPlayerAppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CAudioPlayerAppView::CAudioPlayerAppView()
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CAudioPlayerAppView::~CAudioPlayerAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
CAudioPlayerAppView::~CAudioPlayerAppView()
{
// No implementation required
if (iPlayer)
{
delete iPlayer;
iPlayer = NULL;
}
if (iLabel)
{
delete iLabel;
iLabel = NULL;
}
}
// -----------------------------------------------------------------------------
// CAudioPlayerAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CAudioPlayerAppView::Draw( const TRect& /*aRect*/ ) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Gets the control's extent
TRect drawRect( Rect());
// Clears the screen
gc.Clear( drawRect );
}
// -----------------------------------------------------------------------------
// CAudioPlayerAppView::SizeChanged()
// Called by framework when the view sizes changed.
// -----------------------------------------------------------------------------
//
void CAudioPlayerAppView::SizeChanged()
{
iLabel->SetExtentToWholeScreen();
DrawNow();
}
CMyPlayer* CAudioPlayerAppView::GetPlayer()
{
return iPlayer;
}
TInt CAudioPlayerAppView::CountComponentControls() const
{
return 1;
}
CCoeControl* CAudioPlayerAppView::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
return iLabel;
break;
default:
return NULL;
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -