📄 audioplayerappui.cpp
字号:
/*
============================================================================
Name : AudioPlayerAppUi.cpp
Author : Lion
Copyright : Your copyright notice
Description : CAudioPlayerAppUi implementation
============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <AudioPlayer.rsg>
#include <f32file.h>
#include <s32file.h>
#include "AudioPlayer.pan"
#include "AudioPlayerAppUi.h"
#include "AudioPlayerAppView.h"
#include "AudioPlayer.hrh"
#include "MyPlayer.h"
_LIT( KFileName, "C:\\private\\0827763F\\AudioPlayer.txt" );
_LIT( KText, "Hello World!");
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CAudioPlayerAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CAudioPlayerAppUi::ConstructL()
{
// Initialise app UI with standard value.
BaseConstructL();
// Create view object
iAppView = CAudioPlayerAppView::NewL( ClientRect() );
// Create a file to write the text to
RFs fsSession;
User::LeaveIfError(fsSession.Connect());
CleanupClosePushL( fsSession );
TInt err = fsSession.MkDirAll(KFileName);
if ( KErrNone != err )
{
CleanupStack::PopAndDestroy(1); // fsSession
return;
}
RFile file;
err = file.Replace(fsSession, KFileName, EFileWrite );
CleanupClosePushL( file );
if ( KErrNone != err )
{
CleanupStack::PopAndDestroy(2); // file, fsSession
return;
}
RFileWriteStream outputFileStream( file );
CleanupClosePushL( outputFileStream );
outputFileStream << KText;
CleanupStack::PopAndDestroy(3); // outputFileStream, file, fsSession
}
// -----------------------------------------------------------------------------
// CAudioPlayerAppUi::CAudioPlayerAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CAudioPlayerAppUi::CAudioPlayerAppUi()
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CAudioPlayerAppUi::~CAudioPlayerAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CAudioPlayerAppUi::~CAudioPlayerAppUi()
{
if ( iAppView )
{
delete iAppView;
iAppView = NULL;
}
}
// -----------------------------------------------------------------------------
// CAudioPlayerAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CAudioPlayerAppUi::HandleCommandL( TInt aCommand )
{
switch( aCommand )
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
case ECommand1:
{
iAppView->GetPlayer()->PlaySound();
}
break;
case ECommand2:
{
iAppView->GetPlayer()->PauseSound();
}
break;
case ECommand3:
{
iAppView->GetPlayer()->StopSound();
}
break;
default:
Panic( EAudioPlayerUi );
break;
}
}
// -----------------------------------------------------------------------------
// Called by the framework when the application status pane
// size is changed. Passes the new client rectangle to the
// AppView
// -----------------------------------------------------------------------------
//
void CAudioPlayerAppUi::HandleStatusPaneSizeChange()
{
iAppView->SetRect( ClientRect() );
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -