Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 12:09, 14 May 2008.

CS000952 - Enabling and disabling all key sounds using CAknKeySoundSystem

From Forum Nokia Wiki


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

 
Powered by MediaWiki