Namespaces
Variants
Actions
Revision as of 06:46, 16 July 2012 by hamishwillee (Talk | contribs)

Enabling and disabling all key sounds using CAknKeySoundSystem

Jump to: navigation, search
Article Metadata

Tested with
Devices(s): Nokia N93

Compatibility
Platform(s): S60 3rd Edition, FP1

Article
Keywords: CAknKeySoundSystem, CAknAppUi, CAknAppUi::KeySounds(), CAknKeySoundSystem::PushContextL(), CAknKeySoundSystem::BringToForeground(), CAknKeySoundSystem::LockContext(), CAknKeySoundSystem::PopContext(), CAknKeySoundSystem::ReleaseContext()
Created: aknyman (09 May 2008)
Last edited: hamishwillee (16 Jul 2012)

Contents

Overview

This code snippet shows how CAknKeySoundSystem is used to enable/disable all key sounds at once with the predefined key map list R_AVKON_SILENT_SKEY_LIST.

This snippet can be self-signed.

MMP file

The following libraries are required:

LIBRARY avkon.lib
LIBRARY eikcore.lib
LIBRARY eiksrv.lib

Header file

 #ifndef __TESTERAPPVIEW_H__
#define __TESTERAPPVIEW_H__
 
// INCLUDES
#include <coecntrl.h>
 
class CAknKeySoundSystem;
 
class CTesterAppView : public CCoeControl
{
//...
private:
CAknKeySoundSystem* iSoundSystem;
TBool iSilentKeys;
};
 
#endif // __TESTERAPPVIEW_H__

Source file

#include <avkon.rsg>  //R_AVKON_SILENT_SKEY_LIST
#include <aknsoundsystem.h> // CAknKeySoundSystem
#include <aknappui.h>
 
void CTesterAppView::ConstructL(const TRect& aRect)
{
//...
iSilentKeys = EFalse;
iSoundSystem = static_cast<CAknAppUi*>(
CEikonEnv::Static()->AppUi() )->KeySounds();
 
if (!iSoundSystem)
{
//pointer to KeySound API object is null
User::Leave(KErrGeneral);
}
}
 
CTesterAppView::~CTesterAppView()
{
iSoundSystem = NULL;
}
 
// ---------------------------------------------------------------------------
// Disable all key sounds
// ---------------------------------------------------------------------------
//
 
void CTesterAppView::DisableAllKeySoundsL()
{
if ( iSoundSystem && !iSilentKeys )
{
//load key sound map from resources and push it to the context stack
iSoundSystem->PushContextL( R_AVKON_SILENT_SKEY_LIST );
 
//tell server to use this context stack for processing sounds
iSoundSystem->BringToForeground();
 
//lock this context to the foreground, other BringToForeground() calls
//will be ignored until ReleaseContext() is called
iSoundSystem->LockContext();
 
iSilentKeys = ETrue;
}
}
 
 
// ---------------------------------------------------------------------------
// Enable all key sounds
// ---------------------------------------------------------------------------
//
void CTesterAppView::EnableAllKeySounds()
{
if ( iSoundSystem && iSilentKeys )
{
//release the locked context
iSoundSystem->ReleaseContext();
 
//pop the pushed context from the context stack
iSoundSystem->PopContext();
 
iSilentKeys = EFalse;
}
}


Postconditions

The key sounds are enabled/disabled by calling the methods DisableAllKeySoundsL() and EnableAllKeySounds().

See also

Archived:Enabling and disabling defined key sound using CAknKeySoundSystem

Archived:Using customized key sounds with CAknKeySoundSystem

144 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved