|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * MsgEditor audio media control. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MSGAUDIOCONTROL_H |
|
22 #define MSGAUDIOCONTROL_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <msgmediacontrol.h> |
|
27 #include <mdaaudiosampleplayer.h> |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 // TODO simulate video playing in the emulator |
|
33 // TODO If enabled play preview visible in the options menu |
|
34 //#define _SIMULATE_EMBEDDED_PLAY 1 |
|
35 |
|
36 // DATA TYPES |
|
37 |
|
38 // FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 class CMsgEditorView; |
|
43 |
|
44 // CLASS DECLARATION |
|
45 |
|
46 // ========================================================== |
|
47 |
|
48 /** |
|
49 * Message Editor Base control handling audio |
|
50 */ |
|
51 class CMsgAudioControl : public CMsgMediaControl, |
|
52 public MMdaAudioPlayerCallback |
|
53 { |
|
54 public: // Constructor and destructor |
|
55 |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 * @param aParent parent control |
|
59 * @param aFlags display flags - by default editor state |
|
60 * @return new object |
|
61 */ |
|
62 IMPORT_C static CMsgAudioControl* NewL( CMsgEditorView& aParent, |
|
63 MMsgAsyncControlObserver* aObserver, |
|
64 TMdaPriority aPriority = EMdaPriorityNormal, |
|
65 TMdaPriorityPreference aPreference = EMdaPriorityPreferenceNone ); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 virtual ~CMsgAudioControl(); |
|
71 |
|
72 public: |
|
73 |
|
74 /** |
|
75 * From MMsgAsyncControl |
|
76 * |
|
77 * Loads the audio |
|
78 * |
|
79 * @param aAudioFile image file name - expected to be valid Audioclip |
|
80 */ |
|
81 void LoadL( RFile& aFileHandle ); |
|
82 |
|
83 /** |
|
84 * From MMsgAsyncControl |
|
85 * |
|
86 * Cancels the asyncronous operation if it is pending. |
|
87 */ |
|
88 void Cancel(); |
|
89 |
|
90 /** |
|
91 * From MMsgAsyncControl |
|
92 * |
|
93 * Close audio. |
|
94 */ |
|
95 void Close(); |
|
96 |
|
97 /** |
|
98 * From CMsgMediaControl |
|
99 * |
|
100 * Start audio playback. |
|
101 * Audio must be loaded AND prepared before calling this! |
|
102 */ |
|
103 void PlayL(); |
|
104 |
|
105 /** |
|
106 * From CMsgMediaControl |
|
107 * |
|
108 * Stop audio. |
|
109 */ |
|
110 void Stop(); |
|
111 |
|
112 /** |
|
113 * From CMsgMediaControl |
|
114 * |
|
115 * Pause audio. |
|
116 */ |
|
117 void PauseL(); |
|
118 |
|
119 /** |
|
120 * Get current volume level |
|
121 * @return Current volume level |
|
122 */ |
|
123 inline TInt Volume(); |
|
124 |
|
125 /** |
|
126 * Get maximum volume level |
|
127 * @return Maximum volume level |
|
128 */ |
|
129 inline TInt MaxVolume(); |
|
130 |
|
131 /** |
|
132 * Set volume level |
|
133 * @param aVolume Volume level wanted range 0..10. |
|
134 * @return Volume level after adjustment. |
|
135 */ |
|
136 inline void SetVolume( TInt aVolume ); |
|
137 |
|
138 public: // Functions from MMdaAudioPlayerCallback |
|
139 |
|
140 /** |
|
141 * From MMdaAudioPlayerCallback |
|
142 */ |
|
143 void MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& aDuration ); |
|
144 |
|
145 /** |
|
146 * The actual implementation of MapcInitComplete |
|
147 */ |
|
148 void DoMapcInitCompleteL( TInt aError, const TTimeIntervalMicroSeconds& aDuration ); |
|
149 |
|
150 /** |
|
151 * From MMdaAudioPlayerCallback |
|
152 */ |
|
153 void MapcPlayComplete( TInt aError ); |
|
154 |
|
155 /** |
|
156 * The actual implementation of MapcPlayComplete |
|
157 */ |
|
158 void DoMapcPlayCompleteL( TInt aError ); |
|
159 |
|
160 public: // from CMsgBaseControl |
|
161 |
|
162 /** |
|
163 * Calculates and sets the size of the control and returns new size as |
|
164 * reference aSize. |
|
165 * From CMsgBaseControl |
|
166 */ |
|
167 void SetAndGetSizeL( TSize& aSize ); |
|
168 |
|
169 /** |
|
170 * Resets (= clears) contents of the control. |
|
171 * From CMsgBaseControl |
|
172 */ |
|
173 void Reset(); |
|
174 |
|
175 public: |
|
176 |
|
177 /** |
|
178 * Called when size is changed. |
|
179 * From CMsgBaseControl |
|
180 */ |
|
181 void SizeChanged(); |
|
182 |
|
183 private: // New functions |
|
184 |
|
185 /** |
|
186 * Default C++ constructor |
|
187 */ |
|
188 CMsgAudioControl(); |
|
189 |
|
190 /** |
|
191 * constructor |
|
192 * @param aFlags |
|
193 */ |
|
194 CMsgAudioControl( MMsgBaseControlObserver& aBaseControlObserver, |
|
195 TMdaPriority aPriority, |
|
196 TMdaPriorityPreference aPreference ); |
|
197 |
|
198 /** |
|
199 * By default Symbian constructor is private. |
|
200 */ |
|
201 void ConstructL( CMsgEditorView& aParent, MMsgAsyncControlObserver* aObserver ); |
|
202 |
|
203 /** |
|
204 * Handles callback or other completion of an operation |
|
205 * @param aError error code |
|
206 * @param aNewState new state assigned to iState, if aError is KErrNone: |
|
207 * if aError indicates real error, state is not assigned |
|
208 */ |
|
209 void HandleCallback( TInt aError, |
|
210 TBool aDefaultStop, |
|
211 TMsgAsyncControlState aNewState = EMsgAsyncControlStateReady ); |
|
212 |
|
213 private: //Data |
|
214 |
|
215 CMdaAudioPlayerUtility* iAudioPlayer; |
|
216 RFile iAudioFile; |
|
217 |
|
218 TMdaPriority iPriority; |
|
219 TMdaPriorityPreference iPreference; |
|
220 }; |
|
221 |
|
222 |
|
223 #include <msgaudiocontrol.inl> |
|
224 |
|
225 #endif // MSGAUDIOCONTROL_H |