|
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: Wrapper class which forwards calls to TTS Utility |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NSSVASTTSUTILITYWRAPPER_H |
|
20 #define NSSVASTTSUTILITYWRAPPER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <nssttsutilityobserver.h> |
|
25 #include <nssttscommon.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class MTtsUtilityBase; |
|
29 |
|
30 // CLASS DECLARATION |
|
31 |
|
32 /** |
|
33 * CNssTtsUtilityWrapper |
|
34 * @since 3.1 |
|
35 * @see nssttsutility.h |
|
36 * @see nssttsutilitybase.h |
|
37 * @see nssttsutilityobserver.h |
|
38 */ |
|
39 NONSHARABLE_CLASS ( CNssTtsUtilityWrapper ) : public CActive, public MTtsClientUtilityObserver |
|
40 { |
|
41 public: // Constructors & destructor |
|
42 |
|
43 /** |
|
44 * Two-phased constructor |
|
45 * |
|
46 * @since 3.1 |
|
47 */ |
|
48 static CNssTtsUtilityWrapper* NewL( MTtsClientUtilityObserver& aObserver, |
|
49 TInt aPriority = EMdaPriorityNormal, |
|
50 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality ); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 virtual ~CNssTtsUtilityWrapper(); |
|
56 |
|
57 public: // New functions |
|
58 |
|
59 /** |
|
60 * Adds new style to style collection. |
|
61 * |
|
62 * @since 3.1 |
|
63 * @param "TTtsStyle& aStyle" Reference to style. |
|
64 * @return Assigned style ID. |
|
65 */ |
|
66 TTtsStyleID AddStyleL( const TTtsStyle& aStyle ); |
|
67 |
|
68 /** |
|
69 * Opens a parsed text source and plays it. |
|
70 * |
|
71 * @since 3.1 |
|
72 * @param "CTtsParsedText& aText" Parsed text object to play. |
|
73 * @param "TInt aPriority" Playback priority. |
|
74 * @param "TMdaPriorityPreference aPref" Playback priority preference. |
|
75 */ |
|
76 void OpenAndPlayParsedTextL( CTtsParsedText& aText, |
|
77 TInt aPriority = EMdaPriorityNormal, |
|
78 TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality ); |
|
79 |
|
80 /** |
|
81 * Stops playback of the audio sample as soon as possible. |
|
82 * |
|
83 * If the audio sample is playing, playback is stopped as soon as |
|
84 * possible. If playback is already complete, nothing further happens as |
|
85 * a result of calling this function. The callback function |
|
86 * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is not |
|
87 * called. |
|
88 * |
|
89 * @since 3.1 |
|
90 */ |
|
91 void Stop(); |
|
92 |
|
93 /** |
|
94 * Begins playback of the initialised audio sample at the current volume |
|
95 * and priority levels. |
|
96 * |
|
97 * When playing of the audio sample is complete, successfully or |
|
98 * otherwise, the callback function |
|
99 * <code>MMdaAudioPlayerCallback::MapcPlayComplete()</code> is |
|
100 * called. |
|
101 * |
|
102 * @since 3.1 |
|
103 */ |
|
104 void Play(); |
|
105 |
|
106 /** |
|
107 * Closes the current audio clip (allowing another clip to be opened) |
|
108 * |
|
109 * @since 3.1 |
|
110 */ |
|
111 void Close(); |
|
112 |
|
113 private: // Functions |
|
114 |
|
115 /** |
|
116 * C++ constructor. |
|
117 */ |
|
118 CNssTtsUtilityWrapper( MTtsClientUtilityObserver& aObserver, |
|
119 TInt aPriority, |
|
120 TMdaPriorityPreference aPref ); |
|
121 |
|
122 /** |
|
123 * EPOC constructor. |
|
124 */ |
|
125 void ConstructL(); |
|
126 |
|
127 /* |
|
128 * From MTtsClientUtilityObserver |
|
129 */ |
|
130 void MapcCustomCommandEvent( TInt aEvent, TInt aError ); |
|
131 |
|
132 /* |
|
133 * From MTtsClientUtilityObserver |
|
134 */ |
|
135 void MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& aDuration ); |
|
136 |
|
137 /* |
|
138 * From MTtsClientUtilityObserver |
|
139 */ |
|
140 void MapcPlayComplete( TInt aError ); |
|
141 |
|
142 /** |
|
143 * From CActive |
|
144 */ |
|
145 void RunL(); |
|
146 |
|
147 /** |
|
148 * From CActive |
|
149 */ |
|
150 void DoCancel(); |
|
151 |
|
152 /** |
|
153 * Sets the active object ready to be run |
|
154 */ |
|
155 void Ready(); |
|
156 |
|
157 private: // Member variables |
|
158 |
|
159 // Handle to library loader |
|
160 RLibrary iLib; |
|
161 |
|
162 // UID of the utility client |
|
163 TUid iClientUid; |
|
164 |
|
165 // Pointer to the utility base class |
|
166 MTtsUtilityBase* iUtility; |
|
167 |
|
168 // Reference to the observer |
|
169 MTtsClientUtilityObserver& iObserver; |
|
170 |
|
171 // Audio priority and preference |
|
172 TInt iPriority; |
|
173 TMdaPriorityPreference iPref; |
|
174 |
|
175 // Stored callback parameters |
|
176 TInt iError; |
|
177 TTimeIntervalMicroSeconds iDuration; |
|
178 |
|
179 // Callback function |
|
180 enum TTtsUtilityVasCallback |
|
181 { |
|
182 EInitComplete, |
|
183 EPlayComplete |
|
184 }; |
|
185 |
|
186 TTtsUtilityVasCallback iState; |
|
187 }; |
|
188 |
|
189 #endif // NSSVASSIUTILITYWRAPPER_H |
|
190 |
|
191 // End of file |