|
1 /* |
|
2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This class is used for volume setting |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMMAVOLUMECONTROL_H |
|
20 #define CMMAVOLUMECONTROL_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "cmmacontrol.h" |
|
24 #include "mmmaplayerstatelistener.h" |
|
25 |
|
26 // CONSTANS |
|
27 _LIT(KMMAVolumeControlName, "VolumeControl"); |
|
28 const TInt KMMAVolumeMaxLevel = 100; |
|
29 |
|
30 class CMMAPlayer; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 /** |
|
34 * This class is used for volume setting |
|
35 * |
|
36 * |
|
37 */ |
|
38 |
|
39 class CMMAVolumeControl : public CMMAControl, |
|
40 public MMMAPlayerStateListener |
|
41 { |
|
42 public: |
|
43 static void StaticSetLevelL(CMMAVolumeControl* aVolumeControl, |
|
44 TInt aLevel); |
|
45 static void StaticGetLevelL(CMMAVolumeControl* aVolumeControl, |
|
46 TInt* aLevel); |
|
47 |
|
48 ~CMMAVolumeControl(); |
|
49 |
|
50 protected: |
|
51 CMMAVolumeControl(CMMAPlayer* aPlayer); |
|
52 void ConstructBaseL(); |
|
53 |
|
54 /** |
|
55 * Sets the level to player. |
|
56 * @param aLevel Sound level to set. |
|
57 */ |
|
58 virtual void DoSetLevelL(TInt aLevel) = 0; |
|
59 |
|
60 /** |
|
61 * Get volume level from player. |
|
62 * @return Current level. |
|
63 */ |
|
64 virtual TInt DoGetLevelL() = 0; |
|
65 |
|
66 public: // From CMMAControl |
|
67 const TDesC& ClassName() const; |
|
68 |
|
69 /** |
|
70 * Refresh volume control. |
|
71 */ |
|
72 void RefreshControl(); |
|
73 |
|
74 public: // From MMMAPlayerStateListener |
|
75 void StateChanged(TInt aState); |
|
76 |
|
77 |
|
78 public: // New methods |
|
79 /** |
|
80 * Adds new volume level to volume control. Actual volume level will |
|
81 * be calculated using all levels added to the control. |
|
82 * @return Index for new level. |
|
83 */ |
|
84 IMPORT_C TInt AddLevelL(); |
|
85 |
|
86 /** |
|
87 * Sets new volume level for certain level index. After level is set |
|
88 * new actual level is calculated and commited to player in derived |
|
89 * class. |
|
90 * @param aLevelIndex Level's index |
|
91 * @param aVolumeLevel New volume level for level index. Level must be |
|
92 * between 0 and 100. |
|
93 */ |
|
94 IMPORT_C void SetVolumeLevelL(TInt aLevelIndex, |
|
95 TInt aVolumeLevel); |
|
96 void GetVolumeLevelL(TInt aLevelIndex, |
|
97 TInt* aVolumeLevel); |
|
98 |
|
99 |
|
100 |
|
101 private: // New methods |
|
102 |
|
103 /** |
|
104 * Refresh volume level, basically set the volume level again. |
|
105 */ |
|
106 void RefreshVolume(); |
|
107 |
|
108 /** |
|
109 * Sets level if player is started and sends java event level |
|
110 * changed. |
|
111 * @param aLevel Sound level to set. |
|
112 */ |
|
113 void SetLevelL(TInt aLevel); |
|
114 |
|
115 /** |
|
116 * Calculates new overall level using all values in iLevels array. |
|
117 * @return Current level. |
|
118 */ |
|
119 TInt CalculateLevel(); |
|
120 protected: // data |
|
121 CMMAPlayer* iPlayer; |
|
122 |
|
123 // Previous level setted to player. Used to check if level is changed. |
|
124 TInt iLevel; |
|
125 |
|
126 // Array containing all levels. |
|
127 RArray< TInt > iLevels; |
|
128 |
|
129 }; |
|
130 |
|
131 #endif // CMMAVOLUMECONTROL_H |