This page was last modified 12:09, 14 May 2008.
CS000952 - Enabling and disabling all key sounds using CAknKeySoundSystem
From Forum Nokia Wiki
(Redirected from Enabling and disabling all key sounds using CAknKeySoundSystem)
| ID | CS000952 | Creation date | May 14, 2008 |
| Platform | S60 3rd Edition, FP1 | Tested on devices | Nokia N93 |
| Category | Symbian C++ | Subcategory | Multimedia, Audio |
| Keywords (APIs, classes, methods, functions): CAknKeySoundSystem, CAknAppUi, CAknAppUi::KeySounds(), CAknKeySoundSystem::PushContextL(), CAknKeySoundSystem::BringToForeground(), CAknKeySoundSystem::LockContext(), CAknKeySoundSystem::PopContext(), CAknKeySoundSystem::ReleaseContext() |
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
CS000951 - Enabling and disabling defined key sound using CAknKeySoundSystem
CS000953 - Using customized key sounds with CAknKeySoundSystem
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Realtones in theme for 6670 | Nokian_Spb | Graphics & Video & Streaming | 0 | 2006-08-17 16:46 |
| R_AVKON_SILENT_SKEY_LIST undeclared identifier | czaoth | Symbian | 1 | 2006-06-26 07:52 |
| E65 - "Own key" which code it has? | zdenko | General Symbian C++ | 0 | 2007-10-30 13:18 |
| encypting data to be sent using HTTP (MIDP 1.0) | dihex | Mobile Java Networking & Messaging & Security | 7 | 2005-10-27 20:16 |
| LOGIN: user and password to PHP form | sandro1972 | Mobile Java Networking & Messaging & Security | 6 | 2008-04-30 12:31 |

