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