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

📄 systemsoundsview.cpp

📁 symbian for c++ 系统声音调用例子
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CSystemSoundsView from SystemSoundsView.h
*  Part of  : SystemSounds
*  Created  : 06/12/2003 by Forum Nokia
*  Implementation notes:
*     Initial content was generated by Nokia Series 60 AppWizard.
*  Version  : 1.0
*  Copyright: Nokia
* ============================================================================
*/

// INCLUDE FILES
#include  <aknviewappui.h>
#include  <avkon.hrh>
#include  <SystemSounds.rsg>
#include  "SystemSoundsView.h"
#include  "SystemSoundsContainer.h" 
#include  "SystemSounds.hrh"

// Definitions
#define KWavSoundId 2

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

// ---------------------------------------------------------
// CSystemSoundsView::ConstructL(const TRect& aRect)
// EPOC two-phased constructor
// ---------------------------------------------------------
//
void CSystemSoundsView::ConstructL()
    {
    BaseConstructL( R_SYSTEMSOUNDS_VIEW1 );

    // Create player
    iSoundPlayer = (STATIC_CAST(CAknAppUi*,
									CEikonEnv::Static()->AppUi()))->KeySounds();

    // Add system wav to soundlist
    TRAPD(error, iSoundPlayer->AddAppSoundInfoListL( R_SYSTEM_WAV_SOUND ));
    if ( ( error != KErrAlreadyExists ) && ( error != KErrNone) )
    User::LeaveIfError(error);

    }

// ---------------------------------------------------------
// CSystemSoundsView::~CSystemSoundsView()
// ?implementation_description
// ---------------------------------------------------------
//
CSystemSoundsView::~CSystemSoundsView()
    {
    if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
        }

    delete iContainer;
    }

// ---------------------------------------------------------
// TUid CSystemSoundsView::Id()
// ?implementation_description
// ---------------------------------------------------------
//
TUid CSystemSoundsView::Id() const
    {
    return KViewId;
    }

// ---------------------------------------------------------
// CSystemSoundsView::HandleCommandL(TInt aCommand)
// ?implementation_description
// ---------------------------------------------------------
//
void CSystemSoundsView::HandleCommandL(TInt aCommand)
    {  
    if (aCommand>=EAvkonSIDNoSound && aCommand<=EAvkonSIDRingGoing)
        {
        TInt soundNumber=aCommand;
        // Play system sounds
        // Note that some of the sounds are played in the loudspeaker, 
        // some in the earpiece (speaker)
        // These sounds follow the profiles. However, those system sounds 
        // involving phone speaker, not loudspeaker will be played even in the silent mode. 
        // You need to have the phone on the ear to hear it.
	    if (iSoundPlayer)iSoundPlayer->PlaySound(soundNumber);
        }

    switch ( aCommand )
        {
        case EAknSoftkeyBack:
            {
            AppUi()->HandleCommandL(EEikCmdExit);
            break;
            }
        
        case ESystemSoundsView1Cmd1:
            {
            TInt soundNumber=KWavSoundId;
            // Play system wav sound
	        if (iSoundPlayer)iSoundPlayer->PlaySound(soundNumber);
            break;
            }


        default:
            {
            AppUi()->HandleCommandL( aCommand );
            break;
            }
        }
    }

// ---------------------------------------------------------
// CSystemSoundsView::HandleClientRectChange()
// ---------------------------------------------------------
//
void CSystemSoundsView::HandleClientRectChange()
    {
    if ( iContainer )
        {
        iContainer->SetRect( ClientRect() );
        }
    }

// ---------------------------------------------------------
// CSystemSoundsView::DoActivateL(...)
// ---------------------------------------------------------
//
void CSystemSoundsView::DoActivateL(
   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
   const TDesC8& /*aCustomMessage*/)
    {
    if (!iContainer)
        {
        iContainer = new (ELeave) CSystemSoundsContainer;
        iContainer->SetMopParent(this);
        iContainer->ConstructL( ClientRect() );
        AppUi()->AddToStackL( *this, iContainer );
        } 
   }

// ---------------------------------------------------------
// CSystemSoundsView::HandleCommandL(TInt aCommand)
// ---------------------------------------------------------
//
void CSystemSoundsView::DoDeactivate()
    {
    if ( iContainer )
        {
        AppUi()->RemoveFromViewStack( *this, iContainer );
        }
    
    delete iContainer;
    iContainer = NULL;
    }

// End of File

⌨️ 快捷键说明

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