×
Namespaces

Variants
Actions
(Difference between revisions)

Enabling and disabling all key sounds using CAknKeySoundSystem

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix links)
lpvalente (Talk | contribs)
m (Lpvalente -)
Line 1: Line 1:
 
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:Multimedia]][[Category:Audio]][[Category:Code Snippet]][[Category:S60 3rd Edition FP1]]
 
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:Multimedia]][[Category:Audio]][[Category:Code Snippet]][[Category:S60 3rd Edition FP1]]
 +
{{Archived|timestamp=20120917111343|user=[[User:Lpvalente|Lpvalente]]}}
 +
 +
 
{{ArticleMetaData <!-- v1.2 -->
 
{{ArticleMetaData <!-- v1.2 -->
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
Line 27: Line 30:
  
 
==Overview==
 
==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.
+
{{Abstract|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.
 
This snippet can be self-signed.

Revision as of 14:13, 17 September 2012

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


Article Metadata
Tested with
Devices(s): Nokia N93
Compatibility
Platform(s): S60 3rd Edition, FP1
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: lpvalente (17 Sep 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

51 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×