?? recorderadapter.cpp
字號:
/* Copyright (c) 2004, Nokia. All rights reserved */
// INCLUDE FILES
#include <eikmenup.h>
#include <eikapp.h>
#include <sound.rsg>
#include "sound.pan"
#include "sound.hrh"
#include "recorderadapter.h"
#include "soundappui.h"
// ========================= MEMBER FUNCTIONS ==================================
// -----------------------------------------------------------------------------
// CRecorderAdapter::CRecorderAdapter()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CRecorderAdapter::CRecorderAdapter( CSoundAppUi& aAppUi ) : iAppUi( aAppUi )
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CRecorderAdapter* CRecorderAdapter::NewL( CSoundAppUi& aAppUi )
{
CRecorderAdapter* self = NewLC( aAppUi );
CleanupStack::Pop( self );
return self;
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CRecorderAdapter* CRecorderAdapter::NewLC( CSoundAppUi& aAppUi )
{
CRecorderAdapter* self = new ( ELeave ) CRecorderAdapter( aAppUi );
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CRecorderAdapter::ConstructL()
{
// Load a string from the resource file.
// Identifying string for this audio utility.
itextResourceIdentifier = CCoeEnv::Static()->AllocReadResourceL(
R_SOUN_MODE_RECORDER );
iMdaAudioRecorderUtility = CMdaAudioRecorderUtility::NewL( *this );
const TDesC& aFileName = KRecorderFile;
#ifdef __WINS__
// on emulator, the sound files used by application
// are deployed onto c: drive
_LIT( tFullPath,"c:\\system\\apps\\sound\\" );
TParse parse;
#else
// on real phone, application can be installed to the
// memory card ( non-"C:" drive ), this part of code evaluates
// current application path:
// find the instance of EikonEnv
CEikonEnv& ee = *CEikonEnv::Static();
// derive the instance of EikonAppUi
CEikAppUi& ea = *( ee.EikAppUi() );
// fetch the application full filename
TFileName tAppFullName = ea.Application()->AppFullName();
TParse parse;
// form parse object containing full app name
parse.Set( tAppFullName, NULL, NULL );
// get application path with drive letter
TFileName tFullPath = parse.DriveAndPath();
#endif
// use tparse to get the full path to sound file
parse.Set( tFullPath, &aFileName, NULL );
TFileName tFullFileName = parse.FullName();
// Open an existing sample file for playback or recording,
// causes MMdaObjectStateChangeObserver::MoscoStateChangeEvent
// to be called
iMdaAudioRecorderUtility->OpenFileL( tFullFileName );
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::~CRecorderAdapter()
// Destructor.
// -----------------------------------------------------------------------------
//
CRecorderAdapter::~CRecorderAdapter()
{
delete iMdaAudioRecorderUtility;
// Delete private HBuf member for indetify
delete itextResourceIdentifier;
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::UpdateMenuL()
// Uppdate the menu
// -----------------------------------------------------------------------------
//
void CRecorderAdapter::UpdateMenuL( CEikMenuPane* aMenuPane )
{
aMenuPane->SetItemDimmed( ESoundCmdPlay, ETrue );
aMenuPane->SetItemDimmed( ESoundCmdRecord, ETrue );
aMenuPane->SetItemDimmed( ESoundCmdStop, ETrue );
aMenuPane->SetItemDimmed( ESoundCmdChange, ETrue );
switch ( iMdaAudioRecorderUtility->State() )
{
case CMdaAudioRecorderUtility::ENotReady:
aMenuPane->SetItemDimmed( ESoundCmdChange, EFalse );
break;
case CMdaAudioRecorderUtility::EOpen:
aMenuPane->SetItemDimmed( ESoundCmdPlay, EFalse );
aMenuPane->SetItemDimmed( ESoundCmdRecord, EFalse );
aMenuPane->SetItemDimmed( ESoundCmdChange, EFalse );
break;
case CMdaAudioRecorderUtility::EPlaying:
aMenuPane->SetItemDimmed( ESoundCmdStop, EFalse );
break;
case CMdaAudioRecorderUtility::ERecording:
aMenuPane->SetItemDimmed( ESoundCmdStop, EFalse );
break;
default:
User::Panic( KRecorderAdapter, KSoundPanicInvalidMdaState );
break;
}
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::PlayL()
// Play the wav
// -----------------------------------------------------------------------------
//
void CRecorderAdapter::PlayL()
{
// Play through the device speaker
iMdaAudioRecorderUtility->
SetAudioDeviceMode( CMdaAudioRecorderUtility::ELocal );
// Set maximum volume for playback
iMdaAudioRecorderUtility->SetVolume( iMdaAudioRecorderUtility->MaxVolume() );
// Set the playback position to the start of the file
iMdaAudioRecorderUtility->SetPosition( TTimeIntervalMicroSeconds( 0 ) );
iMdaAudioRecorderUtility->PlayL();
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::StopL()
// Stop the play
// -----------------------------------------------------------------------------
//
void CRecorderAdapter::StopL()
{
iMdaAudioRecorderUtility->Stop();
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::RecordL()
// Record from phone microphone
// -----------------------------------------------------------------------------
//
void CRecorderAdapter::RecordL()
{
// Record from the device microphone
iMdaAudioRecorderUtility->SetAudioDeviceMode(
CMdaAudioRecorderUtility::ELocal );
// Set maximum gain for recording
iMdaAudioRecorderUtility->SetGain( iMdaAudioRecorderUtility->MaxGain() );
// Delete current audio sample from beginning of file
iMdaAudioRecorderUtility->SetPosition( TTimeIntervalMicroSeconds( 0 ) );
iMdaAudioRecorderUtility->CropL();
iMdaAudioRecorderUtility->RecordL();
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::Identify()
// Identify mode
// -----------------------------------------------------------------------------
//
const TDesC& CRecorderAdapter::Identify()
{
return *itextResourceIdentifier;
}
// -----------------------------------------------------------------------------
// CRecorderAdapter::MoscoStateChangeEvent()
// Mosco State Change Event are here
// -----------------------------------------------------------------------------
//
void CRecorderAdapter::MoscoStateChangeEvent( CBase* /*aObject*/,
TInt /*aPreviousState*/,
TInt /*aCurrentState*/,
TInt /*aErrorCode*/ )
{
// Mo implementation required
}
// End of File
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -