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

📄 toneadapter.cpp

📁 symbian 可以实现控制声音大小的源码 非常实用!
💻 CPP
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */


// INCLUDE FILES
#include <eikmenup.h>
#include <sound.rsg>

#include "sound.pan"
#include "sound.hrh"
#include "toneadapter.h"
#include "soundappui.h"


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

// -----------------------------------------------------------------------------
// CToneAdapter::CToneAdapter()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CToneAdapter::CToneAdapter( CSoundAppUi& aAppUi ) : iAppUi( aAppUi ) 
    {
    // No implementation required
    }

// -----------------------------------------------------------------------------
// CToneAdapter::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CToneAdapter* CToneAdapter::NewL( CSoundAppUi& aAppUi )
    {
    CToneAdapter* self = NewLC( aAppUi );
    CleanupStack::Pop( self ); 
    return self;
    }

// -----------------------------------------------------------------------------
// CToneAdapter::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CToneAdapter* CToneAdapter::NewLC( CSoundAppUi& aAppUi )
    {
    CToneAdapter* self = new( ELeave )CToneAdapter( aAppUi );
    CleanupStack::PushL( self );
    self->ConstructL();
    return self;
    }


// -----------------------------------------------------------------------------
// CToneAdapter::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CToneAdapter::ConstructL()
    {

    // Load a string from the resource file.
    // Identifying string for this audio utility.
     itextResourceIdentifier = CCoeEnv::Static()->AllocReadResourceL( 
                                                            R_SOUN_MODE_TONER );

    iMdaAudioToneUtility = CMdaAudioToneUtility::NewL( *this );

    // Configure the audio tone utility to play a single tone
    // causes MMdaAudioToneObserver::MatoPrepareComplete to be called
    iMdaAudioToneUtility->PrepareToPlayTone( KSoundFrequency, 
                                   TTimeIntervalMicroSeconds( KSoundDuration ) );
    }

// -----------------------------------------------------------------------------
// CToneAdapter::~CToneAdapter()
// Destructor.
// -----------------------------------------------------------------------------
//
CToneAdapter::~CToneAdapter()
    {
    delete iMdaAudioToneUtility;    
    iMdaAudioToneUtility = NULL;

    // Delete private HBuf member for indetify
    delete itextResourceIdentifier;
    }


// -----------------------------------------------------------------------------
// CToneAdapter::UpdateMenuL()
// Update Menu
// -----------------------------------------------------------------------------
//
void CToneAdapter::UpdateMenuL( CEikMenuPane* aMenuPane )
    {
    aMenuPane->SetItemDimmed( ESoundCmdPlay,   ETrue );
    aMenuPane->SetItemDimmed( ESoundCmdRecord, ETrue );
    aMenuPane->SetItemDimmed( ESoundCmdStop,   ETrue );
    aMenuPane->SetItemDimmed( ESoundCmdChange, ETrue );
    
    switch ( iMdaAudioToneUtility->State() )
        {
        case EMdaAudioToneUtilityNotReady:
            aMenuPane->SetItemDimmed( ESoundCmdChange, EFalse );
            break;

        case EMdaAudioToneUtilityPrepared:
            aMenuPane->SetItemDimmed( ESoundCmdPlay, EFalse );
            aMenuPane->SetItemDimmed( ESoundCmdChange, EFalse );
            break;

        case EMdaAudioToneUtilityPlaying:
            aMenuPane->SetItemDimmed( ESoundCmdStop, EFalse );
            break;

        default:
            User::Panic( KToneAdapter, KSoundPanicInvalidMdaState );
            break;
        }
    }

// -----------------------------------------------------------------------------
// CToneAdapter::PlayL()
// Play the tone
// -----------------------------------------------------------------------------
//
void CToneAdapter::PlayL()
    {
    iMdaAudioToneUtility->Play();
    }

// -----------------------------------------------------------------------------
// CToneAdapter::RecordL()
// CMdaAudioToneUtility is not able to record
// -----------------------------------------------------------------------------
//
void CToneAdapter::RecordL() 
    {
    // No implementation required
    }

// -----------------------------------------------------------------------------
// CToneAdapter::StopL()
// Stop the toneplay
// -----------------------------------------------------------------------------
//
void CToneAdapter::StopL()
    {
    iMdaAudioToneUtility->CancelPlay();
    }

// -----------------------------------------------------------------------------
// CToneAdapter::Identify()
// Identify mode
// -----------------------------------------------------------------------------
//
const TDesC& CToneAdapter::Identify()
    {
     return *itextResourceIdentifier;
    }

// -----------------------------------------------------------------------------
// CToneAdapter::MatoPrepareComplete()
// Prepare to Complete
// -----------------------------------------------------------------------------
//
void CToneAdapter::MatoPrepareComplete( TInt /*aError*/ )
    {
    iMdaAudioToneUtility->SetVolume( iMdaAudioToneUtility->MaxVolume() );
    }


// -----------------------------------------------------------------------------
// CToneAdapter::MatoPlayComplete()
// Play Complete
// -----------------------------------------------------------------------------
//
void CToneAdapter::MatoPlayComplete( TInt /*aError*/ )
    {
    // No implementation required
    }


// End of File

⌨️ 快捷键说明

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