|
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 the License "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: Uses the interface MPluginAdapter to notify browser of construction |
|
15 and destruction of the plug-in, implements interface MPluginOptionHandler |
|
16 to add menus and draws animated images while video player loading the data |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <AknUtils.h> |
|
23 #include <aknclearer.h> |
|
24 #include <AknBitmapAnimation.h> |
|
25 #include <data_caging_path_literals.hrh> |
|
26 #include <barsread.h> // For TResourceReader |
|
27 #include <StringLoader.h> |
|
28 #include <PluginAdapterInterface.h> |
|
29 #include <BrowserAudioVideoPlugin.rsg> // For text |
|
30 |
|
31 #include "BavpLogger.h" |
|
32 #include "BavpView.h" |
|
33 #include "BrCtlDefs.h" |
|
34 #include "BavpController.h" |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CBavpView::CBavpView |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 CBavpView::CBavpView() |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CBavpView::ConstructL |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CBavpView::ConstructL( const CCoeControl* aParent, |
|
53 const TRect& aRect, CBavpPlugin* aBavPlugin ) |
|
54 { |
|
55 Log( EFalse, _L("CBavpView::ConstructL") ); |
|
56 iBavPlugin = aBavPlugin; |
|
57 |
|
58 CreateWindowL(aParent); |
|
59 ActivateL(); // Draws icon |
|
60 iRect = aRect; |
|
61 CCoeControl::SetRect( aRect ); // Calls SizeChanged |
|
62 |
|
63 User::LeaveIfError( iWsSession.Connect() ); |
|
64 iWindowId = iCoeEnv->RootWin().Identifier(); |
|
65 |
|
66 // Video buffering animation, used to show that content is buffering |
|
67 iVideoBuffAnimation = CAknBitmapAnimation::NewL(); |
|
68 iVideoBuffAnimation->SetContainerWindowL( *this ); |
|
69 TResourceReader rrBuffering; |
|
70 iCoeEnv->CreateResourceReaderLC( rrBuffering, R_ANIMATION_BUFFERING ); |
|
71 iVideoBuffAnimation->ConstructFromResourceL( rrBuffering ); |
|
72 CleanupStack::PopAndDestroy(); // rrBuffering |
|
73 iIsVideoBuffAnimRunning = EFalse; |
|
74 |
|
75 // Bad content animation, used to show that content is not available |
|
76 iBadContentAnimation = CAknBitmapAnimation::NewL(); |
|
77 iBadContentAnimation->SetContainerWindowL( *this ); |
|
78 TResourceReader rrNoContentAnim; |
|
79 iCoeEnv->CreateResourceReaderLC( rrNoContentAnim, R_NO_CONTENT_ANIMATION ); |
|
80 iBadContentAnimation->ConstructFromResourceL( rrNoContentAnim ); |
|
81 CleanupStack::PopAndDestroy(); // rrNoContentAnim |
|
82 iIsBadContentAnimRunning = EFalse; |
|
83 |
|
84 // Video stopped animation, used to show that video content is stopped |
|
85 iVideoStoppedAnimation = CAknBitmapAnimation::NewL(); |
|
86 iVideoStoppedAnimation->SetContainerWindowL( *this ); |
|
87 TResourceReader rrVideoStoppedAnim; |
|
88 iCoeEnv->CreateResourceReaderLC( rrVideoStoppedAnim, R_VIDEO_STOPPED_ANIMATION ); |
|
89 iVideoStoppedAnimation->ConstructFromResourceL( rrVideoStoppedAnim ); |
|
90 CleanupStack::PopAndDestroy(); // rrVideoStoppedAnim |
|
91 iIsVideoStoppedAnimRunning = EFalse; |
|
92 |
|
93 // Video paused animation, used to show that video content is paused |
|
94 iVideoPausedAnimation = CAknBitmapAnimation::NewL(); |
|
95 iVideoPausedAnimation->SetContainerWindowL( *this ); |
|
96 TResourceReader rrVideoPausedAnim; |
|
97 iCoeEnv->CreateResourceReaderLC( rrVideoPausedAnim, R_VIDEO_PAUSED_ANIMATION ); |
|
98 iVideoPausedAnimation->ConstructFromResourceL( rrVideoPausedAnim ); |
|
99 CleanupStack::PopAndDestroy(); // rrVideoPausedAnim |
|
100 iIsVideoPausedAnimRunning = EFalse; |
|
101 |
|
102 // Audio playing animation, used when no video is present, only audio |
|
103 iAudioPlayAnimation = CAknBitmapAnimation::NewL(); |
|
104 iAudioPlayAnimation->SetContainerWindowL( *this ); |
|
105 TResourceReader rrAudioPlayAnim; |
|
106 iCoeEnv->CreateResourceReaderLC( rrAudioPlayAnim, R_AUDIO_PLAY_ANIMATION ); |
|
107 iAudioPlayAnimation->ConstructFromResourceL( rrAudioPlayAnim ); |
|
108 CleanupStack::PopAndDestroy(); // rrAudioPlayAnim |
|
109 iIsAudioPlayAnimRunning = EFalse; |
|
110 |
|
111 // Audio stopped animation, used to show that audio content is stopped |
|
112 iAudioStoppedAnimation = CAknBitmapAnimation::NewL(); |
|
113 iAudioStoppedAnimation->SetContainerWindowL( *this ); |
|
114 TResourceReader rrAudioStoppedAnim; |
|
115 iCoeEnv->CreateResourceReaderLC( rrAudioStoppedAnim, R_AUDIO_STOPPED_ANIMATION ); |
|
116 iAudioStoppedAnimation->ConstructFromResourceL( rrAudioStoppedAnim ); |
|
117 CleanupStack::PopAndDestroy(); // rrAudioStoppedAnim |
|
118 iIsAudioStoppedAnimRunning = EFalse; |
|
119 |
|
120 // Audio paused animation, used to show that audio content is paused |
|
121 iAudioPausedAnimation = CAknBitmapAnimation::NewL(); |
|
122 iAudioPausedAnimation->SetContainerWindowL( *this ); |
|
123 TResourceReader rrAudioPausedAnim; |
|
124 iCoeEnv->CreateResourceReaderLC( rrAudioPausedAnim, R_AUDIO_PAUSED_ANIMATION ); |
|
125 iAudioPausedAnimation->ConstructFromResourceL( rrAudioPausedAnim ); |
|
126 CleanupStack::PopAndDestroy(); // rrAudioPausedAnim |
|
127 iIsAudioPausedAnimRunning = EFalse; |
|
128 |
|
129 Log( EFalse, _L("CBavpView::ConstructL - Start Buffering animation") ); |
|
130 RunAnimation(iVideoBuffAnimation, iIsVideoBuffAnimRunning); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CBavpView::NewL |
|
135 // Two-phased constructor. |
|
136 // ----------------------------------------------------------------------------- |
|
137 CBavpView* CBavpView::NewL( const CCoeControl* aParent, |
|
138 const TRect& aRect, CBavpPlugin* aBavPlugin ) |
|
139 { |
|
140 Log( EFalse, _L("CBavpView::NewL") ); |
|
141 |
|
142 CBavpView* self = new( ELeave ) CBavpView; |
|
143 CleanupStack::PushL( self ); |
|
144 self->ConstructL( aParent, aRect, aBavPlugin ); |
|
145 CleanupStack::Pop( self ); |
|
146 return self; |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CBavpView::Destructor |
|
151 // ----------------------------------------------------------------------------- |
|
152 CBavpView::~CBavpView() |
|
153 { |
|
154 Log( EFalse, _L("CBavpView::~CBavpView") ); |
|
155 |
|
156 // Check if the keyhandling is on the stack, if yes, remove it |
|
157 if ( iIsOnStack ) |
|
158 { |
|
159 // Check if the animation is active |
|
160 // if it is not start animation |
|
161 iEikonEnv->EikAppUi()->RemoveFromStack( this ); |
|
162 } |
|
163 |
|
164 // Cancel video buffering animation, if it's still running |
|
165 if ( iIsVideoBuffAnimRunning ) |
|
166 { |
|
167 iVideoBuffAnimation->CancelAnimation(); |
|
168 } |
|
169 delete iVideoBuffAnimation; |
|
170 |
|
171 // Cancel video stopped animation, if it's still running |
|
172 if ( iIsVideoStoppedAnimRunning ) |
|
173 { |
|
174 iVideoStoppedAnimation->CancelAnimation(); |
|
175 } |
|
176 delete iVideoStoppedAnimation; |
|
177 |
|
178 // Cancel video paused animation, if it's still running |
|
179 if ( iIsVideoPausedAnimRunning ) |
|
180 { |
|
181 iVideoPausedAnimation->CancelAnimation(); |
|
182 } |
|
183 delete iVideoPausedAnimation; |
|
184 |
|
185 // Cancel audio only animation, if it's still running |
|
186 if ( iIsAudioPlayAnimRunning ) |
|
187 { |
|
188 iAudioPlayAnimation->CancelAnimation(); |
|
189 } |
|
190 delete iAudioPlayAnimation; |
|
191 |
|
192 // Cancel audio stopped animation, if it's still running |
|
193 if ( iIsAudioStoppedAnimRunning ) |
|
194 { |
|
195 iAudioStoppedAnimation->CancelAnimation(); |
|
196 } |
|
197 delete iAudioStoppedAnimation; |
|
198 |
|
199 // Cancel audio paused animation, if it's still running |
|
200 if ( iIsAudioPausedAnimRunning ) |
|
201 { |
|
202 iAudioPausedAnimation->CancelAnimation(); |
|
203 } |
|
204 delete iAudioPausedAnimation; |
|
205 |
|
206 // Cancel bad content animation, if it's still running |
|
207 if ( iIsBadContentAnimRunning ) |
|
208 { |
|
209 iBadContentAnimation->CancelAnimation(); |
|
210 } |
|
211 delete iBadContentAnimation; |
|
212 |
|
213 iWsSession.Close(); |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CBavpView::SizeChanged |
|
218 // Responds to size changes to sets the size and position of the contents of |
|
219 // this control |
|
220 // ----------------------------------------------------------------------------- |
|
221 void CBavpView::SizeChanged() |
|
222 { |
|
223 Log( EFalse, _L("CBavpView::SizeChanged") ); |
|
224 |
|
225 if ( iBavpController ) |
|
226 { |
|
227 iRect = Rect(); |
|
228 iBavpController->RefreshRectCoordinates(); |
|
229 } |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CBavpView::AddPluginOptionMenuItemsL |
|
234 // Add the Option Menu items to the menuPane, these will be handled by plugin. |
|
235 // ----------------------------------------------------------------------------- |
|
236 void CBavpView::AddPluginOptionMenuItemsL( CEikMenuPane& aMenuPane, |
|
237 TInt aCommandBase, |
|
238 TInt /*aAfter*/ ) |
|
239 { |
|
240 Log( EFalse, _L("CBavpView::AddPluginOptionMenuItemsL") ); |
|
241 |
|
242 iCommandBase = aCommandBase; |
|
243 TInt index( 0 ); |
|
244 |
|
245 // The menus are only added, if the controller exists and we're in |
|
246 // normal screen and not bad content |
|
247 if ( !iBavpController || iBavpController->IsClipFullScreen() || |
|
248 iBavpController->State() == EBavpBadContent ) |
|
249 { |
|
250 return; |
|
251 } |
|
252 |
|
253 // Display the "Mute" menu item, unless we have HW volume keys, and... |
|
254 if ( !HAS_HW_VOLUME_KEYS && |
|
255 !iBavpController->IsVolumeMuted() && |
|
256 !iBavpController->IsClipRewinding() && |
|
257 !iBavpController->IsClipFastForwarding() ) |
|
258 { |
|
259 InsertOneMenuItemL( aMenuPane, EBavpCmdMuteVolume, |
|
260 R_TEXT_VIDEO_PLUGIN_VOLUME_MUTE, index); |
|
261 index++; |
|
262 } |
|
263 |
|
264 // Check CurrentState to determine the menu items to add |
|
265 switch ( iBavpController->State() ) |
|
266 { |
|
267 case EBavpStopped: |
|
268 case EBavpRewindComplete: |
|
269 case EBavpPlayComplete: |
|
270 { |
|
271 // The content is at the beginning, user can play |
|
272 InsertOneMenuItemL( aMenuPane, EBavpCmdPlay, |
|
273 R_TEXT_VIDEO_PLUGIN_PLAY, index ); |
|
274 index ++; |
|
275 break; |
|
276 } |
|
277 case EBavpPlaying: |
|
278 { |
|
279 // Check if it can be paused |
|
280 if ( iBavpController->IsClipSeekable() ) |
|
281 { |
|
282 InsertOneMenuItemL( aMenuPane, EBavpCmdPause, |
|
283 R_TEXT_VIDEO_PLUGIN_PAUSE, index); |
|
284 index++; |
|
285 } |
|
286 |
|
287 // If playing, user can also stop |
|
288 InsertOneMenuItemL( aMenuPane, EBavpCmdStop, |
|
289 R_TEXT_VIDEO_PLUGIN_STOP, index ); |
|
290 index++; |
|
291 // Add FF and Rewind, only if content seekable, local media, video |
|
292 if ( iBavpController->IsClipSeekable() && |
|
293 iBavpController->IsClipLocalMedia() && |
|
294 iBavpController->IsClipVideo() ) |
|
295 { |
|
296 InsertOneMenuItemL( aMenuPane, EBavpCmdFastForward, |
|
297 R_TEXT_VIDEO_PLUGIN_FAST_FORWARD, index ); |
|
298 index++; |
|
299 InsertOneMenuItemL( aMenuPane, EBavpCmdRewind, |
|
300 R_TEXT_VIDEO_PLUGIN_REWIND, index ); |
|
301 index++; |
|
302 } |
|
303 // Add full screen, only if video content |
|
304 if ( iBavpController->IsClipVideo() ) |
|
305 { |
|
306 InsertOneMenuItemL( aMenuPane, EBavpCmdPlayFullScreen, |
|
307 R_TEXT_VIDEO_PLUGIN_FULL_SCREEN, index ); |
|
308 index++; |
|
309 } |
|
310 break; |
|
311 } |
|
312 case EBavpPaused: |
|
313 { |
|
314 // If paused, user can continue (play) or stop |
|
315 InsertOneMenuItemL( aMenuPane, EBavpCmdPlay, |
|
316 R_TEXT_VIDEO_PLUGIN_PLAY, index ); |
|
317 index++; |
|
318 |
|
319 InsertOneMenuItemL( aMenuPane, EBavpCmdStop, |
|
320 R_TEXT_VIDEO_PLUGIN_STOP, index ); |
|
321 index++; |
|
322 // Add FF and Rewind, only if content seekable, local media, video |
|
323 if ( iBavpController->IsClipSeekable() && |
|
324 iBavpController->IsClipLocalMedia() && |
|
325 iBavpController->IsClipVideo() ) |
|
326 { |
|
327 InsertOneMenuItemL( aMenuPane, EBavpCmdFastForward, |
|
328 R_TEXT_VIDEO_PLUGIN_FAST_FORWARD, index ); |
|
329 index++; |
|
330 InsertOneMenuItemL( aMenuPane, EBavpCmdRewind, |
|
331 R_TEXT_VIDEO_PLUGIN_REWIND, index ); |
|
332 index++; |
|
333 } |
|
334 break; |
|
335 } |
|
336 case EBavpFastForwarding: |
|
337 case EBavpRewinding: |
|
338 { |
|
339 // User can play, while FF or Rewinding |
|
340 InsertOneMenuItemL( aMenuPane, EBavpCmdPlay, |
|
341 R_TEXT_VIDEO_PLUGIN_PLAY, index ); |
|
342 index++; |
|
343 // Add pause, we should only be fast-forwarding or rewinding |
|
344 // seekable content, no need to check |
|
345 InsertOneMenuItemL( aMenuPane, EBavpCmdPause, |
|
346 R_TEXT_VIDEO_PLUGIN_PAUSE, index); |
|
347 index++; |
|
348 break; |
|
349 } |
|
350 case EBavpFastForwardComplete: |
|
351 { |
|
352 // Content is at the end, user can replay |
|
353 InsertOneMenuItemL( aMenuPane, EBavpCmdPlay, |
|
354 R_TEXT_VIDEO_PLUGIN_PLAY, index ); |
|
355 index++; |
|
356 // Add rewind, we should only be fast-forwarding seekable content, |
|
357 // no need to check |
|
358 InsertOneMenuItemL( aMenuPane, EBavpCmdRewind, |
|
359 R_TEXT_VIDEO_PLUGIN_REWIND, index ); |
|
360 index++; |
|
361 break; |
|
362 } |
|
363 default: |
|
364 { |
|
365 break; |
|
366 } |
|
367 } // End of switch |
|
368 |
|
369 // Display "Media Volume" menu item, unless we have HW volume keys and... |
|
370 if ( !HAS_HW_VOLUME_KEYS && |
|
371 !iBavpController->IsClipRewinding() && |
|
372 !iBavpController->IsClipFastForwarding() ) |
|
373 { |
|
374 // User can adjust volume |
|
375 InsertOneMenuItemL( aMenuPane, EBavpCmdChangeVolume, |
|
376 R_TEXT_VIDEO_PLUGIN_MEDIA_VOLUME, index ); |
|
377 } |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CBavpView::HandlePluginCommandL |
|
382 // Handle the user command from the option menu to the plugin. |
|
383 // ----------------------------------------------------------------------------- |
|
384 void CBavpView::HandlePluginCommandL( TInt aCommand ) |
|
385 { |
|
386 iBavpController->HandleCommandL( (TBavpCommandIds)(aCommand - iCommandBase) ); |
|
387 } |
|
388 |
|
389 // ----------------------------------------------------------------------------- |
|
390 // CBavpView::OfferKeyEventL |
|
391 // Control framework calls this function to handle the key event |
|
392 // ----------------------------------------------------------------------------- |
|
393 TKeyResponse CBavpView::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
394 TEventCode aType ) |
|
395 { |
|
396 Log( EFalse, _L("CBavpView::OfferKeyEventL") ); |
|
397 |
|
398 TKeyResponse keyResponse( EKeyWasNotConsumed ); |
|
399 |
|
400 //Check if the controller is already initialized |
|
401 if (iBavpController) |
|
402 { |
|
403 // Let the Audio or Video controller handle the key presses |
|
404 keyResponse = iBavpController->HandleKeysL( aKeyEvent, aType ); |
|
405 } |
|
406 |
|
407 return keyResponse; |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // CBavpView::SetRect |
|
412 // Sets the control's extent, specifying a TRect |
|
413 // ----------------------------------------------------------------------------- |
|
414 void CBavpView::SetRect( NPWindow* aWindow ) |
|
415 { |
|
416 Log( EFalse, _L("CBavpView::SetRect") ); |
|
417 iWindowRect = TRect(TPoint(aWindow->x, aWindow->y), TSize(aWindow->width, aWindow->height)); |
|
418 iClipRect = TRect(aWindow->clipRect.left, aWindow->clipRect.top, aWindow->clipRect.right, aWindow->clipRect.bottom); |
|
419 TRect r(iClipRect); |
|
420 r.Intersection(iWindowRect); |
|
421 TBool flag = iRect != r; |
|
422 iRect = r; |
|
423 CCoeControl::SetRect( iRect ); |
|
424 |
|
425 // Set the rect only when the animation is playing |
|
426 if ( iIsVideoBuffAnimRunning && iVideoBuffAnimation && |
|
427 flag) |
|
428 { |
|
429 iVideoBuffAnimation->CancelAnimation(); |
|
430 TRect animRect( iWindowRect); |
|
431 iVideoBuffAnimation->SetRect( animRect ); |
|
432 TRAP_IGNORE( iVideoBuffAnimation->StartAnimationL() ); |
|
433 } |
|
434 else if ( iIsAudioPlayAnimRunning && iAudioPlayAnimation && |
|
435 flag) |
|
436 { |
|
437 iAudioPlayAnimation->CancelAnimation(); |
|
438 TRect animRect( iWindowRect); |
|
439 iAudioPlayAnimation->SetRect( animRect ); |
|
440 TRAP_IGNORE( iAudioPlayAnimation->StartAnimationL() ); |
|
441 } |
|
442 else if ( iIsAudioStoppedAnimRunning && iAudioStoppedAnimation && |
|
443 flag) |
|
444 { |
|
445 iAudioStoppedAnimation->CancelAnimation(); |
|
446 TRect animRect( iWindowRect); |
|
447 iAudioStoppedAnimation->SetRect( animRect ); |
|
448 TRAP_IGNORE( iAudioStoppedAnimation->StartAnimationL() ); |
|
449 } |
|
450 else if ( iIsAudioPausedAnimRunning && iAudioPausedAnimation && |
|
451 flag) |
|
452 { |
|
453 iAudioPausedAnimation->CancelAnimation(); |
|
454 TRect animRect( iWindowRect); |
|
455 iAudioPausedAnimation->SetRect( animRect ); |
|
456 TRAP_IGNORE( iAudioPausedAnimation->StartAnimationL() ); |
|
457 } |
|
458 else if ( iIsVideoStoppedAnimRunning && iVideoStoppedAnimation && |
|
459 flag) |
|
460 { |
|
461 iVideoStoppedAnimation->CancelAnimation(); |
|
462 TRect animRect( iWindowRect); |
|
463 iVideoStoppedAnimation->SetRect( animRect ); |
|
464 TRAP_IGNORE( iVideoStoppedAnimation->StartAnimationL() ); |
|
465 } |
|
466 else if ( iIsVideoPausedAnimRunning && iVideoPausedAnimation && |
|
467 flag) |
|
468 { |
|
469 iVideoPausedAnimation->CancelAnimation(); |
|
470 TRect animRect( iWindowRect); |
|
471 iVideoPausedAnimation->SetRect( animRect ); |
|
472 TRAP_IGNORE( iVideoPausedAnimation->StartAnimationL() ); |
|
473 } |
|
474 else if ( iIsBadContentAnimRunning && iBadContentAnimation && |
|
475 flag) |
|
476 { |
|
477 iBadContentAnimation->CancelAnimation(); |
|
478 TRect animRect( iWindowRect); |
|
479 iBadContentAnimation->SetRect( animRect ); |
|
480 TRAP_IGNORE( iBadContentAnimation->StartAnimationL() ); |
|
481 } |
|
482 } |
|
483 |
|
484 // ----------------------------------------------------------------------------- |
|
485 // CBavpView::IsTopWindow |
|
486 // Return ETrue if the CCoeControl is the top window instance |
|
487 // ----------------------------------------------------------------------------- |
|
488 TBool CBavpView::IsTopWindowL() |
|
489 { |
|
490 Log( EFalse, _L("CBavpView::IsTopWindowL") ); |
|
491 |
|
492 TBool ret( EFalse ); |
|
493 TInt numWg( iWsSession.NumWindowGroups() ); |
|
494 CArrayFixFlat<TInt>* wgList = new (ELeave) CArrayFixFlat<TInt>( numWg ); |
|
495 |
|
496 // Check if our window is front or not |
|
497 if ( iWsSession.WindowGroupList( 0, wgList ) == KErrNone ) |
|
498 { |
|
499 ret = ( iWindowId == wgList->At(0) ); |
|
500 } |
|
501 else |
|
502 { |
|
503 ret = EFalse; |
|
504 } |
|
505 |
|
506 delete wgList; |
|
507 return ret; |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // CBavpView::UpdateView |
|
512 // Check animation running status, display the animated image if the video |
|
513 // player is not playing |
|
514 // ----------------------------------------------------------------------------- |
|
515 void CBavpView::UpdateView() |
|
516 { |
|
517 Log( EFalse, _L("CBavpView::UpdateView") ); |
|
518 |
|
519 // Handle the bad content case, ie MMF reports an error that needs to |
|
520 // be displayed to the user. (loss of network or bad content) |
|
521 if ( iBavpController->State() == EBavpBadContent && !iIsBadContentAnimRunning ) |
|
522 { |
|
523 Log( EFalse, _L("CBavpView::UpdateView - Bad Content") ); |
|
524 RunAnimation( iBadContentAnimation, iIsBadContentAnimRunning ); |
|
525 } |
|
526 // Handle the beffering content state |
|
527 else if ( iBavpController->State() == EBavpBuffering && !iIsVideoBuffAnimRunning ) |
|
528 { |
|
529 Log( EFalse, _L("CBavpView::UpdateView - Buffering media") ); |
|
530 RunAnimation( iVideoBuffAnimation, iIsVideoBuffAnimRunning ); |
|
531 } |
|
532 // Handle the video animations states |
|
533 else if ( iBavpController->IsClipVideo() ) |
|
534 { |
|
535 Log( EFalse, _L("CBavpView::UpdateView - We got Video") ); |
|
536 if ( iBavpController->State() == EBavpPlaying ) |
|
537 { |
|
538 Log( EFalse, _L("CBavpView::UpdateView - Video Playing, stop animation") ); |
|
539 TBool flag( EFalse ); |
|
540 RunAnimation( NULL, flag ); |
|
541 } |
|
542 else if ( iBavpController->State() == EBavpStopped && !iIsVideoStoppedAnimRunning ) |
|
543 { |
|
544 Log( EFalse, _L("CBavpView::UpdateView - Video Stopped") ); |
|
545 RunAnimation( iVideoStoppedAnimation, iIsVideoStoppedAnimRunning ); |
|
546 } |
|
547 else if ( iBavpController->State() == EBavpPaused && !iIsVideoPausedAnimRunning ) |
|
548 { |
|
549 Log( EFalse, _L("CBavpView::UpdateView - Video Paused") ); |
|
550 RunAnimation( iVideoPausedAnimation, iIsVideoPausedAnimRunning ); |
|
551 } |
|
552 } |
|
553 // Handle the audio animations states |
|
554 else |
|
555 { |
|
556 Log( EFalse, _L("CBavpView::UpdateView - We got Audio") ); |
|
557 if ( iBavpController->State() == EBavpPlaying && !iIsAudioPlayAnimRunning ) |
|
558 { |
|
559 Log( EFalse, _L("CBavpView::UpdateView - Audio Playing") ); |
|
560 RunAnimation( iAudioPlayAnimation, iIsAudioPlayAnimRunning ); |
|
561 } |
|
562 else if ( iBavpController->State() == EBavpStopped || |
|
563 iBavpController->State() == EBavpPlayComplete && |
|
564 !iIsAudioStoppedAnimRunning ) |
|
565 { |
|
566 Log( EFalse, _L("CBavpView::UpdateView - Audio Stopped") ); |
|
567 RunAnimation( iAudioStoppedAnimation, iIsAudioStoppedAnimRunning ); |
|
568 } |
|
569 else if ( iBavpController->State() == EBavpPaused && !iIsAudioPausedAnimRunning ) |
|
570 { |
|
571 Log( EFalse, _L("CBavpView::UpdateView - Audio Paused") ); |
|
572 RunAnimation( iAudioPausedAnimation, iIsAudioPausedAnimRunning ); |
|
573 } |
|
574 } |
|
575 } |
|
576 |
|
577 // ----------------------------------------------------------------------------- |
|
578 // CBavpView::FocusChanged |
|
579 // This method is called once CCoeControl::SetFocus is called, could be when |
|
580 // BavpPlugin::NotifyL causes SetFocus to be called |
|
581 // ----------------------------------------------------------------------------- |
|
582 void CBavpView::FocusChanged( TDrawNow /*aDrawNow*/ ) |
|
583 { |
|
584 iBavpController->BavpFocusChanged( IsFocused() ); |
|
585 } |
|
586 |
|
587 // ----------------------------------------------------------------------------- |
|
588 // CBavpView::Draw |
|
589 // This method is called by CCoeControl::Draw |
|
590 // ----------------------------------------------------------------------------- |
|
591 void CBavpView::Draw( const TRect& aRect ) const |
|
592 { |
|
593 |
|
594 if (iBavpController && !iBavpController->IsClipFullScreen()) { |
|
595 if ( Window().DisplayMode() == EColor16MA ) |
|
596 { |
|
597 Log( EFalse, _L("BavpView::Draw() - DisplayMode=EColor16MA") ); |
|
598 CWindowGc& gc = SystemGc(); |
|
599 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
600 #ifdef _DEBUG |
|
601 gc.SetBrushColor(TRgb::Color16MA(0x0000ff00)); |
|
602 #else |
|
603 gc.SetBrushColor( TRgb::Color16MA(0) ); |
|
604 #endif |
|
605 gc.Clear( aRect ); |
|
606 } |
|
607 |
|
608 if (iBavpController->State() == EBavpPlayComplete) { |
|
609 TRAP_IGNORE(iBavpController->setPositionL(iBavpController->Duration())); |
|
610 } |
|
611 else if (iBavpController->State() == EBavpPaused) { |
|
612 TRAP_IGNORE(iBavpController->setPositionL(iBavpController->getPositionL())); |
|
613 } |
|
614 } |
|
615 |
|
616 |
|
617 } |
|
618 |
|
619 // ----------------------------------------------------------------------------- |
|
620 // CBavpView::ControllerStateChangedL |
|
621 // Check animation running status and the display screen mode |
|
622 // ----------------------------------------------------------------------------- |
|
623 void CBavpView::ControllerStateChangedL() |
|
624 { |
|
625 Log( EFalse, _L("CBavpView::ControllerStateChangedL") ); |
|
626 |
|
627 // If not in full screen mode and if it is on the stack, then remove |
|
628 // from the stack |
|
629 if ( !iBavpController->IsClipFullScreen() && iIsOnStack ) |
|
630 { |
|
631 iIsOnStack = EFalse; |
|
632 iEikonEnv->EikAppUi()->RemoveFromStack( this ); |
|
633 } |
|
634 else if ( iBavpController->IsClipFullScreen() && !iIsOnStack ) |
|
635 { |
|
636 // If full screen mode and not on stack, add to stack |
|
637 iIsOnStack = ETrue; |
|
638 iEikonEnv->EikAppUi()->AddToStackL( this ); |
|
639 } |
|
640 } |
|
641 |
|
642 // ----------------------------------------------------------------------------- |
|
643 // CBavpView::InsertOneMenuItemL |
|
644 // Insert one menu item |
|
645 // ----------------------------------------------------------------------------- |
|
646 void CBavpView::InsertOneMenuItemL( CEikMenuPane& aMenuPane, TInt aCommand, |
|
647 TInt aResourceId, TInt index ) |
|
648 { |
|
649 Log( EFalse, _L("CBavpView::InsertOneMenuItemL") ); |
|
650 |
|
651 CEikMenuPaneItem::SData item; |
|
652 HBufC* buf = StringLoader::LoadLC( aResourceId ); |
|
653 item.iText.Copy( *buf ); |
|
654 CleanupStack::PopAndDestroy(); // buf |
|
655 buf = NULL; |
|
656 |
|
657 item.iCommandId = aCommand + iCommandBase; |
|
658 item.iFlags = 0; |
|
659 item.iCascadeId = 0; |
|
660 aMenuPane.InsertMenuItemL( item, index ); |
|
661 } |
|
662 |
|
663 // ----------------------------------------------------------------------------- |
|
664 // CBavpView::RunAnimation |
|
665 // Run the animation specified, and stop all the other animations |
|
666 // If the animation and run flag are NULL, we stop all animations |
|
667 // Check if animation is already running, if so don't stop, this causes flicker |
|
668 // ----------------------------------------------------------------------------- |
|
669 void CBavpView::RunAnimation( CAknBitmapAnimation* aAnimation, |
|
670 TBool &aAnimRunning ) |
|
671 { |
|
672 Log( EFalse, _L("CBavpView::RunAnimation") ); |
|
673 // Display the animation specified, after cancelling any |
|
674 // other animations first. |
|
675 // |
|
676 // Stop the video buffering animation |
|
677 if ( iIsVideoBuffAnimRunning && iVideoBuffAnimation != aAnimation ) |
|
678 { |
|
679 Log( EFalse, _L("CBavpView::RunAnimation - cancel VideoBuffAnimation") ); |
|
680 iVideoBuffAnimation->CancelAnimation(); |
|
681 iIsVideoBuffAnimRunning = EFalse; |
|
682 } |
|
683 else if ( iIsVideoStoppedAnimRunning && iVideoStoppedAnimation != aAnimation ) |
|
684 { |
|
685 // Stop the video stopped animation |
|
686 Log( EFalse, _L("CBavpView::RunAnimation - cancel VideoStoppedAnimation") ); |
|
687 iVideoStoppedAnimation->CancelAnimation(); |
|
688 iIsVideoStoppedAnimRunning = EFalse; |
|
689 } |
|
690 else if ( iIsVideoPausedAnimRunning && iVideoPausedAnimation != aAnimation ) |
|
691 { |
|
692 // Stop the video paused animation |
|
693 Log( EFalse, _L("CBavpView::RunAnimation - cancel VideoPausedAnimation") ); |
|
694 iVideoPausedAnimation->CancelAnimation(); |
|
695 iIsVideoPausedAnimRunning = EFalse; |
|
696 } |
|
697 else if ( iIsAudioPlayAnimRunning && iAudioPlayAnimation != aAnimation ) |
|
698 { |
|
699 // Stop the audio playing animation |
|
700 Log( EFalse, _L("CBavpView::RunAnimation - cancel AudioPlayAnimation") ); |
|
701 iAudioPlayAnimation->CancelAnimation(); |
|
702 iIsAudioPlayAnimRunning = EFalse; |
|
703 } |
|
704 else if ( iIsAudioStoppedAnimRunning && iAudioStoppedAnimation != aAnimation ) |
|
705 { |
|
706 // Stop the audio stopped animation |
|
707 Log( EFalse, _L("CBavpView::RunAnimation - cancel AudioStoppedAnimation") ); |
|
708 iAudioStoppedAnimation->CancelAnimation(); |
|
709 iIsAudioStoppedAnimRunning = EFalse; |
|
710 } |
|
711 else if ( iIsAudioPausedAnimRunning && iAudioPausedAnimation != aAnimation ) |
|
712 { |
|
713 // Stop the audio paused animation |
|
714 Log( EFalse, _L("CBavpView::RunAnimation - cancel AudioPausedAnimation") ); |
|
715 iAudioPausedAnimation->CancelAnimation(); |
|
716 iIsAudioPausedAnimRunning = EFalse; |
|
717 } |
|
718 else if ( iIsBadContentAnimRunning && iBadContentAnimation != aAnimation ) |
|
719 { |
|
720 // Stop the bad content animation |
|
721 Log( EFalse, _L("CBavpView::RunAnimation - cancel BadContentAnimation") ); |
|
722 iBadContentAnimation->CancelAnimation(); |
|
723 iIsBadContentAnimRunning = EFalse; |
|
724 } |
|
725 |
|
726 // Now, start the animation specified, if it isn't already running. |
|
727 // If the animation and run flag are NULL, we don't start any animations. |
|
728 if ( aAnimation && !aAnimRunning ) |
|
729 { |
|
730 Log( EFalse, _L("CBavpView::RunAnimation - start new animation") ); |
|
731 if ( aAnimation->Rect().Size() != iRect.Size() ) |
|
732 { |
|
733 TRect animRect( iWindowRect); |
|
734 aAnimation->SetRect( animRect ); |
|
735 } |
|
736 TRAP_IGNORE |
|
737 ( |
|
738 aAnimation->StartAnimationL(); |
|
739 aAnimRunning = ETrue; |
|
740 ); |
|
741 } |
|
742 |
|
743 } |
|
744 |
|
745 // End of File |