2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Interface for controlling keysounds from Avkon.
18 #ifndef __AKNSOUNDSYSTEM_H__
19 #define __AKNSOUNDSYSTEM_H__
24 #include <aknsoundinfo.h>
26 // FORWARD DECLARATIONS
27 class CAknSoundPlayer;
28 class CAknKeySoundStack;
32 * Interface for controlling keysounds from Avkon.
33 * Provides support for handling key sounds.
36 NONSHARABLE_CLASS(CAknKeySoundSystem) : public CBase
40 * Base class default constructor. If a client application is derived from @c CAknAppUi,
41 * its @c KeySounds() method should be used instead to obtain a key sound system instance.
42 * If this method is used, the client needs explicitly call @c BringToForeground().
44 * @param aUid Application UID.
45 * @return A pointer to a new @c CAknKeySoundSystem object.
47 IMPORT_C static CAknKeySoundSystem* NewL(TInt aUid);
52 IMPORT_C ~CAknKeySoundSystem();
55 * Reads key sound context from resource file and pushes it to the sound stack.
56 * All key presses for the application produce sounds as specified in this key sound context.
57 * The resource specified must be of the @c AVKON_SKEY_LIST type. There are also some default
58 * Avkon contexts available, e.g. @c R_AVKON_DEFAULT_SKEY_LIST and @c R_AVKON_SILENT_SKEY_LIST.
60 * @param aResourceId Key sound context resource ID.
62 IMPORT_C void PushContextL(TInt aResourceId);
65 * Pops the top context from the key sound stack.
67 IMPORT_C void PopContext();
70 * Plays a sound corresponding to the given key event. This is called directly by Avkon,
71 * though it can be used in other circumstances in order to play the correct sound
72 * associated with certain key presses.
74 * @param aKeyEvent The scan code of the key that caused the event.
76 IMPORT_C void PlaySound(const TKeyEvent& aKeyEvent);
79 * Plays a sound corresponding to the given sound ID. The ID can be an application specific ID
80 * or a system specific ID. System specific IDs are specified in Avkon enum @c TAvkonSystemSID.
82 * @param aSid Sound ID to be played.
84 IMPORT_C void PlaySound(TInt aSid);
87 * Installs an application specific set of sound IDs. The specified resource ID must be
88 * of the type @c AVKON_SOUND_INFO_LIST. The sound IDs contained in the resource are made
89 * available for use in sound contexts within this application only. The method can only be
90 * used to install a single application sound information list. Calling the method a
91 * second time causes the previous sound information list to be replaced. Note also that
92 * application specific SIDs should be less than 1000.
94 * @param aResourceId Avkon resource ID.
96 IMPORT_C void AddAppSoundInfoListL(TInt aResourceId);
99 * This function brings the sounds back to foreground. This function should
100 * be called from @c HandleForegroundEventL(). @c HandleForegroundEventL() is
101 * implemented in @c CAknAppUi and it is reimplemented in @c CAknViewAppUi.
102 * No need to call this function if using the @c KeySounds() method from @c CAknAppUi instead
103 * of @c CAknKeySoundSystem::NewL(). In such case @c CAknAppUi calls this method automatically.
105 IMPORT_C void BringToForeground();
108 * Stops playing the sound with given ID. Does nothing if a sound matching the ID is
111 * @param aSid Sound ID to stop.
113 IMPORT_C void StopSound(TInt aSid);
116 * Locks sound context, which prevents other instances from bringing their sound contexts
117 * topmost. Only the first call is effective, i.e. if some other instance has already
118 * locked its own context, the function does nothing. This is used in system components,
119 * e.g. in key lock where key tones must be disabled while lock is active.
121 IMPORT_C void LockContext();
124 * Releases the context lock. After calling this method, all instances can freely modify
125 * their sound contexts again. The caller of the method can be some other instance than
126 * the instance that locked the context.
128 IMPORT_C void ReleaseContext();
131 * Reads sound information from given Avkon sound ID. This method is intended for applications
132 * that need Avkon sound definitions for playing sounds with their own audio instances of
133 * Multimedia Framework (such applications should not read Avkon resources as the resource
134 * format can change without any notice but instead use this method).
137 * @param aAvkonSid ID for Avkon sound whose information is requested.
138 * @param aInfo Sound information will be put in this structure.
139 * @return @c KErrNone if succesful, @c KErrNotFound if requested sound ID is not found.
141 IMPORT_C TInt RequestSoundInfoL(TInt aAvkonSid, CAknSoundInfo& aInfo);
144 * Returns top context id from the session.
147 * @return The resource id of the context that is at the top of the sound stack.
149 IMPORT_C TInt TopContext();
152 * Disables next matching key sound until next pointer up event.
155 * @param aScanCode ScanCode of key which sound is disabled.
157 void DisableNextKeySound(TInt aScanCode);
160 CAknKeySoundSystem();
161 void ConstructL(TInt aUid);
164 CAknSoundPlayer* iSoundPlayer;
168 #endif // __AKNSOUNDSYSTEM_H__