|
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: Implementation of media key handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CMPXMEDIAKEYHANDLERIMP_H |
|
21 #define C_CMPXMEDIAKEYHANDLERIMP_H |
|
22 |
|
23 |
|
24 // INCLUDES |
|
25 #include <remconcoreapitargetobserver.h> |
|
26 #include <coecntrl.h> |
|
27 #include <mpxplaybackobserver.h> |
|
28 #include <mpxplaybackframeworkdefs.h> |
|
29 |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CRemConInterfaceSelector; |
|
33 class CRemConCoreApiTarget; |
|
34 class CRepository; |
|
35 class CMPXRemConKeyResponse; |
|
36 class MMPXPlaybackUtility; |
|
37 class CAknVolumePopup; |
|
38 class CMPXNotifierDialog; |
|
39 class MMPXMediaKeyHandlerObserver; |
|
40 class MMPXMetaDataHandler; |
|
41 #ifdef UPNP_INCLUDED |
|
42 class CUpnpCopyCommand; |
|
43 #endif |
|
44 // CLASS DECLARATION |
|
45 |
|
46 /** |
|
47 * Media hard key handler implementation class |
|
48 * |
|
49 * @lib mpxmediakeyhandler.lib |
|
50 * @since S60 v3.1 |
|
51 */ |
|
52 NONSHARABLE_CLASS( CMPXMediaKeyHandlerImp ): public CBase, |
|
53 public MMPXMediaKeyHandler, |
|
54 public MRemConCoreApiTargetObserver, |
|
55 public MMPXPlaybackObserver, |
|
56 public MCoeControlObserver, |
|
57 public MMPXPlaybackCallback |
|
58 { |
|
59 public: |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 * |
|
64 * @since 3.1 |
|
65 * @param aFlags Flags for creating popups. |
|
66 * @param aObserver Observer for media key handling. |
|
67 * @return Pointer to newly created object. |
|
68 */ |
|
69 static MMPXMediaKeyHandler* NewL( |
|
70 TMPXMediaKeyPopupFlags aFlags, |
|
71 MMPXMediaKeyHandlerObserver* aObserver ); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 virtual ~CMPXMediaKeyHandlerImp(); |
|
77 |
|
78 private: |
|
79 |
|
80 /** |
|
81 * C++ default constructor. |
|
82 * |
|
83 * @param aFlags Flags for creating popups. |
|
84 * @param aObserver Custom command observer for media key handling. |
|
85 */ |
|
86 CMPXMediaKeyHandlerImp( MMPXMediaKeyHandlerObserver* aObserver ); |
|
87 |
|
88 /** |
|
89 * By default Symbian 2nd phase constructor is private. |
|
90 */ |
|
91 void ConstructL( TMPXMediaKeyPopupFlags aFlags ); |
|
92 |
|
93 /** |
|
94 * Filter and send command to playback utility. |
|
95 * |
|
96 * @param aCommandId command Id to be sent. |
|
97 */ |
|
98 void FilterAndSendCommand( TMPXPlaybackCommand aCommandId ); |
|
99 |
|
100 /** |
|
101 * Help filter and send command to playback utility. |
|
102 * |
|
103 * @param aCommandId command Id to be sent. |
|
104 */ |
|
105 void DoFilterAndSendCommandL( TMPXPlaybackCommand aCommandId ); |
|
106 |
|
107 /** |
|
108 * Handle playback message |
|
109 * |
|
110 * @param aMessage playback message |
|
111 */ |
|
112 void DoHandlePlaybackMessageL( const CMPXMessage& aMessage ); |
|
113 |
|
114 /** |
|
115 * Handle playback property |
|
116 * |
|
117 * @param aProperty the property |
|
118 * @param aValue the value of the property |
|
119 * @param aError error code |
|
120 */ |
|
121 void DoHandlePropertyL( TMPXPlaybackProperty aProperty, TInt aValue, TInt aError ); |
|
122 |
|
123 /** |
|
124 * Handle media properties. |
|
125 * |
|
126 * @param aMedia media properties |
|
127 * @param aError error code |
|
128 */ |
|
129 void DoHandleMediaL( const CMPXMedia& aMedia, TInt aError ); |
|
130 |
|
131 /** |
|
132 * Handle playback state changed. |
|
133 * |
|
134 * @param aState New Playback state |
|
135 */ |
|
136 void DoHandleStateChangedL( TMPXPlaybackState aState ); |
|
137 |
|
138 /** |
|
139 * Callback for timer |
|
140 * |
|
141 * @param aPtr Pointer pass to this callback function. |
|
142 * @return Zero if callback function doesn't need to be called again. |
|
143 * Otherwise, non-zero. |
|
144 */ |
|
145 static TInt TimerCallback( TAny* aPtr ); |
|
146 |
|
147 /** |
|
148 * Handle repeat event |
|
149 */ |
|
150 void HandleRepeatEvent(); |
|
151 |
|
152 /** |
|
153 * Retrieves the current player name and type |
|
154 */ |
|
155 void GetSubPlayerInfoL( |
|
156 TDes& aSubPlayerName, |
|
157 TMPXPlaybackPlayerType& aCurrentPlayerType ); |
|
158 |
|
159 /** |
|
160 * Sets the volume popup title to current remote player |
|
161 */ |
|
162 void SetVolumePopupTitleL(); |
|
163 |
|
164 /** |
|
165 * Checks if UPnP is set up and available |
|
166 */ |
|
167 TBool IsUpnpVisibleL(); |
|
168 |
|
169 /** |
|
170 * Updates the volume and the volume command |
|
171 */ |
|
172 void UpdateVolume(); |
|
173 |
|
174 // from base class MMPXMediaKeyHandler |
|
175 |
|
176 /** |
|
177 * From MMPXMediaKeyHandler |
|
178 * Show playback popup |
|
179 * |
|
180 * @param aMode Playback popup behaviour mode |
|
181 */ |
|
182 void ShowPlaybackPopupL( TMPXPlaybackPopupModes aMode ); |
|
183 |
|
184 /** |
|
185 * From MMPXMediaKeyHandler |
|
186 * Show Volume popup |
|
187 */ |
|
188 void ShowVolumePopupL(); |
|
189 |
|
190 /** |
|
191 * From MMPXMediaKeyHandler |
|
192 * Dismiss notifier popup. |
|
193 * |
|
194 * @param aFlags Popup flag to determine which popup(s) should |
|
195 * be dismissed. |
|
196 */ |
|
197 void DismissNotifier( TMPXMediaKeyPopupFlags aFlags ); |
|
198 |
|
199 /** |
|
200 * Enable or disable Media Key behavior |
|
201 * @since 3.1 |
|
202 * @param aEnable, ETrue, media keys are sent to observers |
|
203 * EFalse, media keys are ignored |
|
204 */ |
|
205 void SetEnableMediaKeys( TBool aEnable ); |
|
206 |
|
207 /** |
|
208 * Gets called when orientation change begins |
|
209 */ |
|
210 void NotifyOrientationChangeBegin(); |
|
211 |
|
212 // from base class MMPXPlaybackObserver |
|
213 |
|
214 /** |
|
215 * From MMPXPlaybackObserver |
|
216 * Handle playback message |
|
217 * |
|
218 * @param aMessage playback message |
|
219 * @param aErr system error code. |
|
220 */ |
|
221 void HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError ); |
|
222 |
|
223 // from base class MMPXPlaybackCallback |
|
224 |
|
225 /** |
|
226 * From MMPXPlaybackCallback |
|
227 * Handle playback property |
|
228 * |
|
229 * @param aProperty the property |
|
230 * @param aValue the value of the property |
|
231 * @param aError error code |
|
232 */ |
|
233 void HandlePropertyL( TMPXPlaybackProperty aProperty, TInt aValue, TInt aError ); |
|
234 |
|
235 /** |
|
236 * From MMPXPlaybackCallback |
|
237 * Method is called continously until aComplete=ETrue, signifying that |
|
238 * it is done and there will be no more callbacks |
|
239 * Only new items are passed each time |
|
240 * |
|
241 * @param aPlayer UID of the subplayer |
|
242 * @param aSubPlayers a list of sub players |
|
243 * @param aComplete ETrue no more sub players. EFalse more subplayer |
|
244 * expected |
|
245 * @param aError error code |
|
246 */ |
|
247 void HandleSubPlayerNamesL( |
|
248 TUid aPlayer, |
|
249 const MDesCArray* aSubPlayers, |
|
250 TBool aComplete, |
|
251 TInt aError ); |
|
252 |
|
253 /** |
|
254 * From MMPXPlaybackCallback |
|
255 * Handle media properties |
|
256 * |
|
257 * @param aMedia media |
|
258 * @param aError error code |
|
259 */ |
|
260 void HandleMediaL( const CMPXMedia& aMedia, TInt aError ); |
|
261 |
|
262 // from base class MRemConCoreApiTargetObserver |
|
263 |
|
264 /** |
|
265 * From MRemConCoreApiTargetObserver |
|
266 * A 'play' command has been received. |
|
267 * |
|
268 * @param aSpeed The playback speed. |
|
269 * @param aButtonAct The button action associated with the command. |
|
270 */ |
|
271 void MrccatoPlay( |
|
272 TRemConCoreApiPlaybackSpeed aSpeed, |
|
273 TRemConCoreApiButtonAction aButtonAct ); |
|
274 |
|
275 /** |
|
276 * From MRemConCoreApiTargetObserver |
|
277 * A command has been received. |
|
278 * |
|
279 * @param aOperationId The operation ID of the command. |
|
280 * @param aButtonAct The button action associated with the command. |
|
281 */ |
|
282 void MrccatoCommand( |
|
283 TRemConCoreApiOperationId aOperationId, |
|
284 TRemConCoreApiButtonAction aButtonAct ); |
|
285 |
|
286 /** |
|
287 * From MRemConCoreApiTargetObserver |
|
288 * A 'tune function' command has been received. |
|
289 * |
|
290 * @param aTwoPart Determine which channel to be used. |
|
291 * @param aMajorChannel The major channel number. |
|
292 * @param aMinorChannel The minor channel number. |
|
293 * @param aButtonAct The button action associated with the command. |
|
294 */ |
|
295 void MrccatoTuneFunction( |
|
296 TBool aTwoPart, |
|
297 TUint aMajorChannel, |
|
298 TUint aMinorChannel, |
|
299 TRemConCoreApiButtonAction aButtonAct ); |
|
300 |
|
301 /** |
|
302 * From MRemConCoreApiTargetObserver |
|
303 * A 'select disk function' has been received. |
|
304 * |
|
305 * @param aDisk The disk. |
|
306 * @param aButtonAct The button action associated with the command. |
|
307 */ |
|
308 void MrccatoSelectDiskFunction( |
|
309 TUint aDisk, |
|
310 TRemConCoreApiButtonAction aButtonAct ); |
|
311 |
|
312 /** |
|
313 * From MRemConCoreApiTargetObserver |
|
314 * A 'select AV input function' has been received. |
|
315 * |
|
316 * @param aAvInputSignalNumber The AV input. |
|
317 * @param aButtonAct The button action associated with the command. |
|
318 */ |
|
319 void MrccatoSelectAvInputFunction( |
|
320 TUint8 aAvInputSignalNumber, |
|
321 TRemConCoreApiButtonAction aButtonAct ); |
|
322 |
|
323 /** |
|
324 * From MRemConCoreApiTargetObserver |
|
325 * A 'select audio input function' has been received. |
|
326 * |
|
327 * @param aAudioInputSignalNumber The audio input. |
|
328 * @param aButtonAct The button action associated with the command. |
|
329 */ |
|
330 void MrccatoSelectAudioInputFunction( |
|
331 TUint8 aAudioInputSignalNumber, |
|
332 TRemConCoreApiButtonAction aButtonAct ); |
|
333 |
|
334 /** |
|
335 * From MCoeControlObserver. To handle the volume events. |
|
336 */ |
|
337 void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); |
|
338 |
|
339 /** |
|
340 * Check the mpx app is foreground. |
|
341 * |
|
342 * @return The check result. If mpx is foreground, return true. |
|
343 */ |
|
344 TBool IsAppForeground(); |
|
345 |
|
346 static TInt VolumePopupSynchTimerCallback( TAny* aPtr ); |
|
347 void DoVolumePopupSynch(); |
|
348 void StartVolumePopupSynchTimer(); |
|
349 |
|
350 |
|
351 /** |
|
352 * Callback function of Filter event timer |
|
353 * |
|
354 * @param aPtr, Pointer to an instance of CMPXMediaKeyHandlerImp |
|
355 * @return value is ignored and is irrelevant in that context |
|
356 */ |
|
357 static TInt FilterEventTimerCallback( TAny* aPtr ); |
|
358 |
|
359 /** |
|
360 * Do with the rest event of VolPopup |
|
361 * |
|
362 * VolPopup CallBack functon is frequently called, |
|
363 * But Music Palyer deals with the event slowly. |
|
364 * Thus VolPopup will not display smoothly. |
|
365 * So Music Player needs timer to filter some events. |
|
366 */ |
|
367 void DoFilterEventTimer(); |
|
368 |
|
369 private: // Data |
|
370 |
|
371 CRemConInterfaceSelector* iInterfaceSelector; // owned |
|
372 CRemConCoreApiTarget* iCoreTarget; // not own |
|
373 CPeriodic* iTimer; // owned |
|
374 CMPXRemConKeyResponse* iResponseHandler; // owned |
|
375 CRepository* iSettingsRepository; // owned |
|
376 CAknVolumePopup* iVolPopup; // owned |
|
377 CMPXNotifierDialog* iPlaybackPopup; // owned |
|
378 |
|
379 MMPXPlaybackUtility* iPlaybackUtility; // not own |
|
380 MMPXMediaKeyHandlerObserver* iObserver; // not own |
|
381 |
|
382 // RemCon target for handling AVRCP 1.3 metadata commands |
|
383 MMPXMetaDataHandler* iMetaDataHandler; // own |
|
384 |
|
385 TInt iResourceOffset; // must be freed |
|
386 TInt iShowPopups; // Indicate which popup(s) should be shown |
|
387 TMPXPlaybackCommand iCommandId; // Command ID for repeat key events |
|
388 TBool iEnable; // Media Key enabled / disabled |
|
389 TBool iUpnpFrameworkSupport; // UPnP framework support |
|
390 |
|
391 /** |
|
392 * Current track's info |
|
393 */ |
|
394 HBufC* iTrackTitle; // owned |
|
395 TMPXPlaybackState iPlayerState; |
|
396 TInt iPlaybackPosition; // in seconds |
|
397 TBool iSkipping; |
|
398 TInt iCurrentVol; |
|
399 TBool iIncreaseVol; |
|
400 TBool iMuted; |
|
401 TInt iVolumeSteps; // Number of volume steps in ui |
|
402 #ifdef UPNP_INCLUDED |
|
403 CUpnpCopyCommand* iUpnpCopyCommand; |
|
404 #endif |
|
405 TInt iUpnpVolume; // absolute upnp volume value |
|
406 TInt iPreviousVol; //Last time volume |
|
407 CPeriodic* iVolumePopupSynchTimer; |
|
408 CPeriodic* iFilterEventTimer; //owned, filter volumePopup event |
|
409 }; |
|
410 |
|
411 #endif // C_CMPXMEDIAKEYHANDLERIMP_H |
|
412 |
|
413 // End of File |