|
1 /* |
|
2 * Copyright (c) 2009 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: Branding Animation control |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 7 % |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <eikenv.h> |
|
23 #include <gulicon.h> |
|
24 #include <AknUtils.h> |
|
25 #include <AknIconUtils.h> |
|
26 #include <AknsDrawUtils.h> |
|
27 #include <mpxvideoplaybackcontrols.mbg> |
|
28 |
|
29 #include "mpxvideoplaybackbrandinganimation.h" |
|
30 #include "mpxvideoplaybackcontrolscontroller.h" |
|
31 #include "mpxvideo_debug.h" |
|
32 |
|
33 |
|
34 const TInt KMPXRealBrandingAnimationArrayCount = 17; // Real Branding frames' count |
|
35 const TInt KMPXGenericBrandingAnimationArrayCount = 10; // Generic Branding frames' count |
|
36 const TInt KMPXBrandingAnimationFrameInterval = 100000; // Represents delay between frames |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =================================================== |
|
39 |
|
40 CMPXVideoPlaybackBrandingAnimation::CMPXVideoPlaybackBrandingAnimation( |
|
41 CMPXVideoPlaybackControlsController* aController, TBool aRealFormat ) |
|
42 : iIconArray( KMPXRealBrandingAnimationArrayCount ) |
|
43 , iRealFormat( aRealFormat ) |
|
44 , iController( aController ) |
|
45 { |
|
46 } |
|
47 |
|
48 // ------------------------------------------------------------------------------------------------- |
|
49 // CMPXVideoPlaybackBrandingAnimation::ConstructL() |
|
50 // Symbian 2nd phase constructor can leave. |
|
51 // ------------------------------------------------------------------------------------------------- |
|
52 // |
|
53 void CMPXVideoPlaybackBrandingAnimation::ConstructL( TRect aRect ) |
|
54 { |
|
55 MPX_DEBUG(_L("CMPXVideoPlaybackBrandingAnimation::ConstructL()")); |
|
56 |
|
57 // |
|
58 // set rect |
|
59 // |
|
60 SetRect( TRect( 0, 0, aRect.Width(), aRect.Height() ) ); |
|
61 iBrandingRect = aRect; |
|
62 |
|
63 // |
|
64 // construct branding timer |
|
65 // |
|
66 iBrandingTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
67 |
|
68 // |
|
69 // create branding bitmaps |
|
70 // |
|
71 CreateBitmapsL(); |
|
72 |
|
73 } |
|
74 |
|
75 // ------------------------------------------------------------------------------------------------- |
|
76 // CMPXVideoPlaybackBrandingAnimation::NewL() |
|
77 // Two-phased constructor. |
|
78 // ------------------------------------------------------------------------------------------------- |
|
79 // |
|
80 CMPXVideoPlaybackBrandingAnimation* |
|
81 CMPXVideoPlaybackBrandingAnimation::NewL( CMPXVideoPlaybackControlsController* aController, |
|
82 TRect aRect, |
|
83 TBool aRealFormat ) |
|
84 { |
|
85 MPX_DEBUG(_L("CMPXVideoPlaybackBrandingAnimation::NewL()")); |
|
86 |
|
87 CMPXVideoPlaybackBrandingAnimation* self = |
|
88 new ( ELeave ) CMPXVideoPlaybackBrandingAnimation( aController, aRealFormat ); |
|
89 |
|
90 CleanupStack::PushL( self ); |
|
91 self->ConstructL( aRect ); |
|
92 CleanupStack::Pop(); |
|
93 return self; |
|
94 } |
|
95 |
|
96 // ------------------------------------------------------------------------------------------------- |
|
97 // CMPXVideoPlaybackBrandingAnimation::~CMPXVideoPlaybackBrandingAnimation() |
|
98 // Destructor. |
|
99 // ------------------------------------------------------------------------------------------------- |
|
100 // |
|
101 CMPXVideoPlaybackBrandingAnimation::~CMPXVideoPlaybackBrandingAnimation() |
|
102 { |
|
103 MPX_DEBUG(_L("CMPXVideoPlaybackBrandingAnimation::~CMPXVideoPlaybackBrandingAnimation()")); |
|
104 |
|
105 iIconArray.ResetAndDestroy(); |
|
106 |
|
107 if ( iBrandingTimer ) |
|
108 { |
|
109 iBrandingTimer->Cancel(); |
|
110 delete iBrandingTimer; |
|
111 iBrandingTimer = NULL; |
|
112 } |
|
113 |
|
114 } |
|
115 |
|
116 // ------------------------------------------------------------------------------------------------- |
|
117 // CMPXVideoPlaybackBrandingAnimation::CreateBitmapsL() |
|
118 // ------------------------------------------------------------------------------------------------- |
|
119 // |
|
120 void CMPXVideoPlaybackBrandingAnimation::CreateBitmapsL() |
|
121 { |
|
122 MPX_DEBUG(_L("CMPXVideoPlaybackBrandingAnimation::CreateBitmapsL()")); |
|
123 |
|
124 // |
|
125 // Create icons |
|
126 // |
|
127 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
128 |
|
129 TFileName iconsPath; |
|
130 iController->LocateBitmapFileL( iconsPath ); |
|
131 |
|
132 TInt bitmapIndex; |
|
133 |
|
134 if ( iRealFormat ) |
|
135 { |
|
136 // |
|
137 // first frame of Real Player Branding Animation |
|
138 // |
|
139 bitmapIndex = EMbmMpxvideoplaybackcontrolsQgn_graf_realplayer_splash_01; |
|
140 |
|
141 // |
|
142 // number of Real Player animation frames |
|
143 // |
|
144 iCount = KMPXRealBrandingAnimationArrayCount; |
|
145 } |
|
146 else |
|
147 { |
|
148 // |
|
149 // first frame of Generic Branding Animation |
|
150 // |
|
151 bitmapIndex = EMbmMpxvideoplaybackcontrolsQgn_graf_ring_wait_01; |
|
152 |
|
153 // |
|
154 // number of Generic animation frames |
|
155 // |
|
156 iCount = KMPXGenericBrandingAnimationArrayCount; |
|
157 } |
|
158 |
|
159 for ( TInt i = 0; i < iCount * 2; i = i + 2 ) |
|
160 { |
|
161 // |
|
162 // Create icons |
|
163 // |
|
164 CGulIcon* icon = AknsUtils::CreateGulIconL( skin, |
|
165 KAknsIIDQgnVideoPluginAnimBuffering, |
|
166 iconsPath, |
|
167 bitmapIndex + i , |
|
168 bitmapIndex + i + 1 ); |
|
169 |
|
170 if ( icon ) |
|
171 { |
|
172 // |
|
173 // push icon to the cleanup stack |
|
174 // |
|
175 CleanupStack::PushL( icon ); |
|
176 |
|
177 // |
|
178 // Set icon size |
|
179 // |
|
180 AknIconUtils::SetSize( icon->Bitmap(), iBrandingRect.Size(), EAspectRatioPreserved ); |
|
181 |
|
182 // |
|
183 // Append icon to array |
|
184 // |
|
185 iIconArray.AppendL( icon ); |
|
186 |
|
187 // |
|
188 // pop icon to the cleanup stack |
|
189 // |
|
190 CleanupStack::Pop( icon ); |
|
191 } |
|
192 } |
|
193 |
|
194 // |
|
195 // start branding timer |
|
196 // |
|
197 StartBrandingTimer(); |
|
198 } |
|
199 |
|
200 // ------------------------------------------------------------------------------------------------- |
|
201 // CMPXVideoPlaybackBrandingAnimation::CountComponentControls() |
|
202 // ------------------------------------------------------------------------------------------------- |
|
203 // |
|
204 TInt CMPXVideoPlaybackBrandingAnimation::CountComponentControls() const |
|
205 { |
|
206 return 0; |
|
207 } |
|
208 |
|
209 // ------------------------------------------------------------------------------------------------- |
|
210 // CMPXVideoPlaybackBrandingAnimation::Draw() |
|
211 // ------------------------------------------------------------------------------------------------- |
|
212 // |
|
213 void CMPXVideoPlaybackBrandingAnimation::Draw( const TRect& aRect ) const |
|
214 { |
|
215 MPX_DEBUG(_L("CMPXVideoPlaybackBrandingAnimation::Draw()")); |
|
216 |
|
217 CWindowGc& gc = SystemGc(); |
|
218 gc.SetClippingRect( aRect ); |
|
219 |
|
220 if ( Window().DisplayMode() == EColor16MAP ) |
|
221 { |
|
222 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
223 gc.SetBrushColor( TRgb::Color16MAP( 255 ) ); |
|
224 gc.Clear( aRect ); |
|
225 } |
|
226 else if ( Window().DisplayMode() == EColor16MA ) |
|
227 { |
|
228 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
229 gc.SetBrushColor( TRgb::Color16MA( 0 ) ); |
|
230 gc.Clear( aRect ); |
|
231 } |
|
232 else |
|
233 { |
|
234 // draw a solid background so that the entire progress |
|
235 // bar is shown not just the area representing the |
|
236 // portion that has been played. |
|
237 gc.SetBrushColor( KRgbBlack ); |
|
238 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
239 gc.DrawRect( aRect ); |
|
240 gc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
241 } |
|
242 |
|
243 // |
|
244 // draw branding animation |
|
245 // |
|
246 gc.BitBltMasked( iBrandingRect.iTl, |
|
247 iIconArray[ iCurrentIndex ]->Bitmap(), |
|
248 TRect( iBrandingRect.Size() ), |
|
249 iIconArray[ iCurrentIndex ]->Mask(), |
|
250 ETrue ); |
|
251 } |
|
252 |
|
253 // ------------------------------------------------------------------------------------------------- |
|
254 // CMPXVideoPlaybackBrandingAnimation::StartBrandingTimer |
|
255 // ------------------------------------------------------------------------------------------------- |
|
256 // |
|
257 void CMPXVideoPlaybackBrandingAnimation::StartBrandingTimer() |
|
258 { |
|
259 MPX_DEBUG(_L("CMPXVideoPlaybackBrandingAnimation::StartBrandingTimer()")); |
|
260 |
|
261 // |
|
262 // set branding timer |
|
263 // |
|
264 if ( ! iBrandingTimer->IsActive() ) |
|
265 { |
|
266 iBrandingTimer->Start( |
|
267 0, |
|
268 KMPXBrandingAnimationFrameInterval, |
|
269 TCallBack( CMPXVideoPlaybackBrandingAnimation::BrandingTimer, this ) ); |
|
270 } |
|
271 } |
|
272 |
|
273 // ------------------------------------------------------------------------------------------------- |
|
274 // CMPXVideoPlaybackBrandingAnimation::BrandingTimer |
|
275 // ------------------------------------------------------------------------------------------------- |
|
276 // |
|
277 TInt CMPXVideoPlaybackBrandingAnimation::BrandingTimer( TAny* aPtr ) |
|
278 { |
|
279 static_cast<CMPXVideoPlaybackBrandingAnimation*>(aPtr)->HandleBrandingTimer(); |
|
280 return KErrNone; |
|
281 } |
|
282 |
|
283 // ------------------------------------------------------------------------------------------------- |
|
284 // CMPXVideoPlaybackBrandingAnimation::HandleBrandingTimer |
|
285 // ------------------------------------------------------------------------------------------------- |
|
286 // |
|
287 void CMPXVideoPlaybackBrandingAnimation::HandleBrandingTimer() |
|
288 { |
|
289 // |
|
290 // keep track of the current animation frame |
|
291 // |
|
292 iCurrentIndex = (++iCurrentIndex) % iCount; |
|
293 |
|
294 // |
|
295 // draw the current animation frame |
|
296 // |
|
297 if ( IsVisible() ) |
|
298 { |
|
299 DrawNow(); |
|
300 } |
|
301 } |
|
302 |
|
303 // ------------------------------------------------------------------------------------------------- |
|
304 // CMPXVideoPlaybackBrandingAnimation::CancelBrandingTimer |
|
305 // ------------------------------------------------------------------------------------------------- |
|
306 // |
|
307 void CMPXVideoPlaybackBrandingAnimation::CancelBrandingTimer() |
|
308 { |
|
309 MPX_DEBUG(_L("CMPXVideoPlaybackBrandingAnimation::CancelBrandingTimer()")); |
|
310 |
|
311 if ( iBrandingTimer->IsActive() ) |
|
312 { |
|
313 iBrandingTimer->Cancel(); |
|
314 } |
|
315 } |
|
316 |
|
317 // End of File |