|
1 /* |
|
2 * Copyright (c) 2007-2008 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: The music control for the slideshow |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CSHWMUSICCONTROL_H__ |
|
21 #define __CSHWMUSICCONTROL_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <e32base.h> |
|
26 |
|
27 #include <mpxplaybackobserver.h> // MMPXPlaybackCallback |
|
28 #include <mpxplaybackframeworkdefs.h> // TMPXPlaybackProperty |
|
29 |
|
30 #include "shwmusicobserver.h" // MShwMusicObserver |
|
31 #include "shweventobserver.h" |
|
32 #include "shweventpublisherbase.h" |
|
33 |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class MMPXPlaybackUtility; |
|
37 |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * CShwMusicControl |
|
43 * Slideshow music control wraps the MPX music control for slideshow |
|
44 * @lib shwslideshowengine.lib |
|
45 * @author Loughlin Spollen |
|
46 */ |
|
47 NONSHARABLE_CLASS( CShwMusicControl ) |
|
48 : public CShwEventPublisherBase, |
|
49 public MShwEventObserver, |
|
50 public MMPXPlaybackCallback, |
|
51 public MMPXPlaybackObserver |
|
52 { |
|
53 public: // Constructors and destructor |
|
54 |
|
55 /** |
|
56 * Constructor. |
|
57 * @param aFilePath, the list that this view control manages |
|
58 * @param aMusicObsvr, the music control observer which receives |
|
59 * notification of music on/off and |
|
60 * volume level. |
|
61 */ |
|
62 static CShwMusicControl* NewL(MShwMusicObserver& aMusicObsvr, |
|
63 const TDesC& aFilePath); |
|
64 |
|
65 /** |
|
66 * Destructor. |
|
67 */ |
|
68 ~CShwMusicControl(); |
|
69 |
|
70 private: |
|
71 |
|
72 /** |
|
73 * Constructor |
|
74 * @param aFilePath, the list that this view control manages |
|
75 * @param aMusicObsrvr* the music control observer. May be Null. |
|
76 */ |
|
77 CShwMusicControl(MShwMusicObserver& aMusicObsvr, |
|
78 const TDesC& aFilePath); |
|
79 |
|
80 /** |
|
81 * 2nd stage constructor |
|
82 */ |
|
83 void ConstructL(); |
|
84 |
|
85 /** |
|
86 * Initialise the player utility member |
|
87 */ |
|
88 void InitPlayerL(); |
|
89 |
|
90 /** |
|
91 * Retrieve the current volume settings from the player |
|
92 * utility member |
|
93 * Volume settins are retrieved asyncronously |
|
94 */ |
|
95 void VolumeL(); |
|
96 |
|
97 public: // From MShwEventObserver |
|
98 |
|
99 /** @ref MShwEventObserver::NotifyL */ |
|
100 void NotifyL(MShwEvent* aEvent); |
|
101 |
|
102 public: // From MMPXPlaybackCallback |
|
103 |
|
104 /** |
|
105 * Handle playback property |
|
106 * @ref MMPXPlaybackCallback::HandlePropertyL |
|
107 */ |
|
108 void HandlePropertyL( |
|
109 TMPXPlaybackProperty aProperty, |
|
110 TInt aValue, TInt aError ); |
|
111 |
|
112 /** |
|
113 * Method is called continously until aComplete=ETrue, |
|
114 * signifying that it is done and there will be no more |
|
115 * callbacks |
|
116 * Only new items are passed each time |
|
117 * @ref MMPXPlaybackCallback::HandleSubPlayerNamesL |
|
118 */ |
|
119 void HandleSubPlayerNamesL( |
|
120 TUid aPlayer, const MDesCArray* aSubPlayers, |
|
121 TBool aComplete, TInt aError ); |
|
122 |
|
123 /** |
|
124 * Handle extended media properties |
|
125 * @ref MMPXPlaybackCallback::HandleMediaL |
|
126 */ |
|
127 void HandleMediaL( |
|
128 const CMPXMedia& aProperties, TInt aError ); |
|
129 |
|
130 private: // From MMPXPlaybackObserver |
|
131 |
|
132 /** |
|
133 * Handle playback message - required for debugging state of MPX |
|
134 * Player component |
|
135 */ |
|
136 void HandlePlaybackMessageL( |
|
137 const TMPXPlaybackMessage& aMessage ); |
|
138 |
|
139 /** |
|
140 * Handle playback message |
|
141 * NOTE: only one of HandlePlaybackMessage callback can be implemented |
|
142 * |
|
143 * @param aMsg playback message, ownership not transferred. |
|
144 * Please check aMsg is not NULL before using it. If aErr is not |
|
145 * KErrNone, plugin might still call back with more info in the aMsg. |
|
146 * @param aErr system error code. |
|
147 */ |
|
148 void HandlePlaybackMessage(const CMPXMessage& aMsg); |
|
149 |
|
150 private: // Implementation |
|
151 |
|
152 // implmentation of the NotifyL |
|
153 void HandleEventL( MShwEvent* aEvent ); |
|
154 |
|
155 /// Own: music is beeing switched on |
|
156 TBool iSwitchingMusicOn; |
|
157 |
|
158 /// Ref: the path to the music file |
|
159 const TDesC& iFilePath; |
|
160 |
|
161 /// Own: the MPX player utility |
|
162 MMPXPlaybackUtility* iPlaybackUtility; |
|
163 |
|
164 /// Ref: Music Observer |
|
165 MShwMusicObserver& iMusicObsvr; |
|
166 |
|
167 /// Own: the max volume setting |
|
168 TInt iMaxVolume; |
|
169 |
|
170 /// Own: the current volume setting |
|
171 TInt iCurrentVolume; |
|
172 |
|
173 // It is set to ETrue if music can be played |
|
174 TBool iCanPlay; |
|
175 |
|
176 // It is set to ETrue if music player is not yet initialized |
|
177 TBool iPlayCached; |
|
178 |
|
179 /// Own: state flag |
|
180 enum TState |
|
181 { |
|
182 EMusicOn, |
|
183 EMusicOff |
|
184 } iState; |
|
185 |
|
186 }; |
|
187 |
|
188 #endif // __CSHWMUSICCONTROL_H__ |