×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Enabling and disabling defined key sound using CAknKeySoundSystem

From Nokia Developer Wiki
Jump to: navigation, search
extkbeditor1 (Talk | contribs)
m
lpvalente (Talk | contribs)
m (Lpvalente -)
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
+
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:Multimedia]][[Category:Audio]][[Category:S60 3rd Edition (initial release)]][[Category:Code Snippet]]
__NOEDITSECTION__
+
{{Archived|timestamp=20120313130319|user=roy.debjit| }}
{{KBCS}}
+
{{CodeSnippet
+
|id=CS000951
+
|platform=S60 3rd Edition, FP1
+
|devices=Nokia N93
+
|category=Symbian C++
+
|subcategory=Multimedia, Audio
+
|creationdate=May 14, 2008
+
|keywords=CAknKeySoundSystem, CAknAppUi, AVKON_SKEY_LIST, AVKON_SKEY_INFO, CAknAppUi::KeySounds(), CAknKeySoundSystem::PushContextL(), CAknKeySoundSystem::BringToForeground(), CAknKeySoundSystem::LockContext(),CAknKeySoundSystem::PopContext(), CAknKeySoundSystem::ReleaseContext()
+
}}
+
  
 +
 +
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= Nokia N93
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= S60 3rd Edition, FP1
 +
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= CAknKeySoundSystem, CAknAppUi, AVKON_SKEY_LIST, AVKON_SKEY_INFO, CAknAppUi::KeySounds(), CAknKeySoundSystem::PushContextL(), CAknKeySoundSystem::BringToForeground(), CAknKeySoundSystem::LockContext(),CAknKeySoundSystem::PopContext(), CAknKeySoundSystem::ReleaseContext()
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080509
 +
|author= [[User:Aknyman]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= Multimedia, Audio
 +
|id= CS000951
 +
}}
 +
 
 
==Overview==
 
==Overview==
This code snippet shows how CAknKeySoundSystem is used to enable/disable a defined key sound. EStdKeyDevice3 (the selection key) is used as an example.
+
{{Abstract|This code snippet shows how CAknKeySoundSystem is used to enable/disable a defined key sound. EStdKeyDevice3 (the selection key) is used as an example.}}
  
 
This snippet can be self-signed.
 
This snippet can be self-signed.
Line 22: Line 39:
  
 
<code>
 
<code>
LIBRARY avkon.lib
+
LIBRARY avkon.lib
LIBRARY eikcore.lib  
+
LIBRARY eikcore.lib  
LIBRARY eiksrv.lib  
+
LIBRARY eiksrv.lib  
 
</code>
 
</code>
  
Line 159: Line 176:
 
==Postconditions==
 
==Postconditions==
  
The selection key sound is enabled/disabled by calling methods <tt>DisableSelectionKeySoundL()</tt> and <tt>EnableSelectionKeySound()</tt>.
+
The selection key sound is enabled/disabled by calling methods {{Icode|DisableSelectionKeySoundL()}} and {{Icode|EnableSelectionKeySound()}}.
  
 
==See also==
 
==See also==
  
[[CS000952 - Enabling and disabling all key sounds using CAknKeySoundSystem]]
+
[[Enabling and disabling all key sounds using CAknKeySoundSystem]]
 
+
[[CS000953 - Using customized key sounds with CAknKeySoundSystem]]
+
  
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Multimedia]][[Category:Audio]][[Category:S60 3rd Edition]]
+
[[Archived:Using customized key sounds with CAknKeySoundSystem]]

Revision as of 14:12, 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}}.


Article Metadata
Tested with
Devices(s): Nokia N93
Compatibility
Platform(s): S60 3rd Edition, FP1
S60 3rd Edition (initial release)
Article
Keywords: CAknKeySoundSystem, CAknAppUi, AVKON_SKEY_LIST, AVKON_SKEY_INFO, 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 a defined key sound. EStdKeyDevice3 (the selection key) is used as an example.

This snippet can be self-signed.

MMP file

The following libraries are required:

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

Resource file

#include <eikon.rh>
#include <avkon.rsg>
#include <avkon.rh>
#include <e32keys.h> //EStdKeyDevice3
 
//----------------------------------------------------
// key sound map to disable selection key sound
//----------------------------------------------------
//
RESOURCE AVKON_SKEY_LIST r_silent_select_key_list
{
list=
{
AVKON_SKEY_INFO
{
key = EStdKeyDevice3;
sid = EAvkonSIDNoSound;
},
AVKON_SKEY_INFO
{
key = EStdKeyDevice3;
sid = EAvkonSIDNoSound;
type = ESKeyTypeLong;
},
AVKON_SKEY_INFO
{
key = EStdKeyDevice3;
sid = EAvkonSIDNoSound;
type = ESKeyTypeRepeat;
}
};
}


Header file

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

Source file

#include <Tester_0xE0060BB5.RSG> //r_silent_select_key_list
 
#include <aknsoundsystem.h> // CAknKeySoundSystem
#include <aknappui.h>
 
void CTesterAppView::ConstructL(const TRect& aRect)
{
//...
iSilentSelection = 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 selection key sound
// ---------------------------------------------------------------------------
//
void CTesterAppView::DisableSelectionKeySoundL()
{
if ( iSoundSystem && !iSilentSelection )
{
//load key sound map from resources and push it to the context stack
iSoundSystem->PushContextL( R_SILENT_SELECT_KEY_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();
 
iSilentSelection = ETrue;
}
}
 
// ---------------------------------------------------------------------------
// Enable selection key sound
// ---------------------------------------------------------------------------
//
void CTesterAppView::EnableSelectionKeySound()
{
if ( iSoundSystem && iSilentSelection )
{
//release the locked context
iSoundSystem->ReleaseContext();
 
//pop the pushed context from the context stack
iSoundSystem->PopContext();
 
iSilentSelection = EFalse;
}
}


Postconditions

The selection key sound is enabled/disabled by calling methods DisableSelectionKeySoundL() and EnableSelectionKeySound().

See also

Enabling and disabling all key sounds using CAknKeySoundSystem

Archived:Using customized key sounds with CAknKeySoundSystem

66 page views in the last 30 days.