Update contrib.
2 * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
22 @internalComponent - Internal Symbian test code
26 This test depends on the following environment:
28 ==========================================================================
29 == Required step - Install Xvid codec
30 ==========================================================================
31 Note that these drivers are distributed under the GNU GENERAL PUBLIC LICENSE.
34 http://developer.symbian.com/wiki/display/pub/Open+source+projects
35 and get the XviD source zip:
36 http://developer.symbian.com/wiki/download/attachments/1154/xvid.zip
38 ** Unzip this file and build the source in
43 ==========================================================================
44 == Required step - Running on emulator - Modify epoc.ini and wsini.ini
45 ==========================================================================
47 ** Update your epoc.ini so that GCE is enabled. Add:
49 SYMBIAN_GRAPHICS_USE_GCE ON
50 SYMBIAN_BASE_USE_GCE ON
53 ** Update your wsini.ini so that the following is present:
56 KEYCLICKPLUGIN KeyClickRef
58 CHROMAKEYCOLOR 0xFFFF00FF
62 ==========================================================================
63 == Required step - Running on hardware - Buildrom command
64 ==========================================================================
66 ** When building the rom, make sure you use the following flags
69 -DSYMBIAN_BASE_USE_GCE
70 -DSYMBIAN_GRAPHICS_USE_GCE
71 -DUSE_24BPP_DISPLAY_VARIANT
72 <further options/flags>
74 <further oby/iby files>
76 the xvid video drivers being installed in the runtime environment.
79 #include "tuiandvideo.h"
81 #include <mmf/common/mmferrors.h>
84 _LIT(KDefaultDirName, "c:\\videoplay\\");
86 _LIT(KDefaultDirName, "e:\\videoplay\\");
89 _LIT(KDefaultFileExt, "*.avi");
90 _LIT(KDefaultFile, "skiing2.avi");
92 const TTimeIntervalMicroSeconds KTapTimeOut(300*1000);
93 const TTimeIntervalMicroSeconds32 KIdleTimeOut(1*1000*1000);
94 const TTimeIntervalMicroSeconds32 KPlayTimeOut(2*1000*1000);
95 const TTimeIntervalMicroSeconds32 KButtonTimeOut(2*1000*1000);
97 _LIT(KVideoAppBitmapsFile, "z:\\resource\\apps\\videoplay2.mbm");
107 //UIBench test step commands
108 enum TTestStepCommand
110 ETestCmdInitialised = 0,
119 // From videoplay.mbg
122 EMbmVideoplayBackground,
123 EMbmVideoplayBackground_mask,
128 A command handler to act as an interface through which to drive the test.
129 @param aController View controller, in the classic sense of MVC. This object
130 is used to drive the test.
132 CCommandSink::CCommandSink (CTestAppView* aTestView) :
133 CActive(EPriorityStandard),
134 iTestView (aTestView)
136 CActiveScheduler::Add(this);
137 iStatus = KRequestPending;
141 void CCommandSink::DoCancel()
143 TRequestStatus* status = &iStatus;
144 User::RequestComplete(status, KErrNone);
147 CCommandSink::~CCommandSink()
152 void CCommandSink::Init(RThread* aTargetThread, TRequestStatus* aTargetStatus)
154 iTargetThread = aTargetThread;
155 iTargetStatus = aTargetStatus;
159 Signals the control thread (target) with a command. There must be a protocol between the
160 controller and the control (the test thread) in terms of communication of command
163 void CCommandSink::RunL ()
165 switch (iStatus.Int())
168 iTestView->PlayVideo();
171 iTestView->PauseVideo();
176 iTestView->SetRunMode(iStatus.Int());
180 iStatus = KRequestPending;
184 CTUiAndVideo::CTUiAndVideo()
186 SetTestStepName(KTUiAndVideo);
189 void CTUiAndVideo::IssueCommand (TUint aCommand)
191 TRequestStatus* targetStatus = iAppUi->CommandSink();
192 ConeThread()->RequestComplete(targetStatus, aCommand);
195 void CTUiAndVideo::StepState (TUint aNextState, TUint aPause)
198 TRequestStatus* testState = &iTestState;
199 User::RequestComplete (testState, aNextState);
203 @SYMTestCaseID GRAPHICS-UI-BENCH-XXXX
204 @SYMTestCaseDesc Put description here
205 @SYMTestActions Put description here
206 @SYMTestExpectedResults Put description here
208 TVerdict CTUiAndVideo::doTestStepL()
210 iProfiler->InitResults();
212 StepState(ETestCmdInitialised, 0);
214 TBool continueTest = ETrue;
217 User::WaitForRequest(iTestState);
218 switch (iTestState.Int())
220 case ETestCmdInitialised:
221 User::After(5000000);
223 IssueCommand(ETestCmdPlay);
224 StepState(ETestCmdBounce, 5000000);
229 IssueCommand(ETestCmdBounce);
230 StepState(ETestCmdJump, 15000000);
233 IssueCommand(ETestCmdJump);
234 StepState(ETestCmdExit, 15000000);
236 continueTest = EFalse;
239 continueTest = EFalse;
240 RDebug::Printf("Invalid test state!");
244 return TestStepResult();
250 void CTUiAndVideo::InitUIL(CCoeEnv* aCoeEnv)
252 iAppUi = new CTUiAndVideoAppUi();
254 iAppUi->ConstructL(iTestState);
255 aCoeEnv->SetAppUi(iAppUi);
258 //############################################################################################################
259 //############################################################################################################
260 //############################################################################################################
261 //############################################################################################################
263 //************************************************************************************************************
264 // Application UI implementation
265 // -- most control logic is here
266 //************************************************************************************************************
268 void SetCenter(TRect& aRect, const TPoint& aCenterPoint)
270 const TSize size = aRect.Size();
271 const TPoint pos(aCenterPoint-TSize(size.iWidth/2,size.iHeight/2).AsPoint());
272 aRect.SetRect(pos, size);
275 void CTUiAndVideoAppUi::ConstructL(TRequestStatus /*iCommandSource*/)
277 BaseConstructL(ENoAppResourceFile);
279 // Calculate the size of the application window
280 // Make the player square, slightly (one 16th) smaller than
281 // the smallest side of the screen
282 TRect rect (0, 0, 300, 150);
284 TRect screenRect = iCoeEnv->ScreenDevice()->SizeInPixels();
285 SetCenter(rect, screenRect.Center()); // Center the rect on the screen
287 // Create the application view
288 iAppView = CTestAppView::NewL(rect);
289 AddToStackL(iAppView);
291 iCommandSink = new (ELeave) CCommandSink(iAppView);
293 // Enable iIdleTimer to make the app return to foreground after a set delay
294 iIdleTimer = CPeriodic::NewL(CActive::EPriorityStandard);
295 // iUIMover moves the UI around the display.
296 iUIMover = CPeriodic::NewL(CActive::EPriorityStandard);
297 iUIMover->Start(KIdleTimeOut, 50000, TCallBack(UIMoverCallBack, this));
298 // Enable iPlayTimer to make the video pause a little while before starting playing again
299 iPlayTimer = CPeriodic::NewL(CActive::EPriorityStandard);
301 iAppView->SetPos(&rect.iTl);
302 iAppView->ActivateL();
305 // Load default video clip
306 if (KErrNone == PopulateDirFilesL(KDefaultDirName))
308 OpenSelectedFileL(KDefaultFile);
312 TRequestStatus* CTUiAndVideoAppUi::CommandSink ()
314 return &(iCommandSink->iStatus);
317 CTUiAndVideoAppUi::~CTUiAndVideoAppUi()
321 RemoveFromStack(iAppView);
328 delete iLoadingPlayer;
332 TInt CTUiAndVideoAppUi::UIMoverCallBack(TAny* aSelf)
334 CTUiAndVideoAppUi* self = static_cast<CTUiAndVideoAppUi*>(aSelf);
339 void CTUiAndVideoAppUi::SetPos()
341 iAppView->SetPos(NULL);
344 TInt CTUiAndVideoAppUi::PopulateDirFilesL(const TDesC& aDir)
346 // Load files in default folder
348 User::LeaveIfError(fs.Connect());
350 // Get the file list, sorted by name - Only with KDefaultFileExt
352 dir.Append(KDefaultFileExt);
356 TInt err = fs.GetDir(dir, KEntryAttMaskSupported, ESortByName, iDirList);
359 if ((err == KErrPathNotFound) || (err == KErrNone && iDirList->Count()==0))
361 LogError(KNullDesC, _L("Default clip not found!"));
364 __ASSERT_DEBUG(err==KErrNone, User::Panic(_L("PopulateDirFiles"), err));
366 // set the current file with the current folder (for the time being)
368 iCurrentFile.Append(aDir);
372 void CTUiAndVideoAppUi::OpenSelectedFileL(const TDesC& aFile)
374 __ASSERT_DEBUG(iDirList, User::Panic(_L("iDirList"), 0));
375 TBool defaultFound = EFalse;
376 for (iCurrentIndex=0; iCurrentIndex < iDirList->Count(); iCurrentIndex++)
378 TFileName fileName = (*iDirList)[iCurrentIndex].iName;
379 if (fileName.Compare(aFile) ==0)
381 defaultFound = ETrue;
387 // To avoid linking with eikcore.lib
388 //iEikonEnv->InfoMsg(_L("Default file not found..."));
389 iCurrentIndex = 0; // if no default, pick the first movie on the list
392 iCurrentFile.Append((*iDirList)[iCurrentIndex].iName);
393 // play the selected file.
394 HandleCommandL(ETestCmdOpen);
397 TInt CTUiAndVideoAppUi::PlayNextFileL()
399 __ASSERT_DEBUG(iDirList, User::Panic(_L("iDirList"), 0));
400 if (iCurrentIndex == (iDirList->Count()-1))
406 file.Set(iCurrentFile, NULL, NULL);
407 iCurrentFile = file.DriveAndPath();
408 iCurrentFile.Append((*iDirList)[iCurrentIndex].iName);
409 HandleCommandL(ETestCmdOpen);
413 TInt CTUiAndVideoAppUi::PlayPreviousFileL()
415 __ASSERT_DEBUG(iDirList, User::Panic(_L("iDirList"), 0));
416 if (iCurrentIndex == 0)
422 file.Set(iCurrentFile, NULL, NULL);
423 iCurrentFile = file.DriveAndPath();
424 iCurrentFile.Append((*iDirList)[iCurrentIndex].iName);
425 HandleCommandL(ETestCmdOpen);
429 void CTUiAndVideoAppUi::LogError(const TDesC& /* aFileName */, const TDesC& /* aErrorMsg */)
431 // TODO: Fix this logging strategy. Printf uses C-like pointers, not Symbian
433 //RDebug::Printf("Error: %s %s", aFileName, aErrorMsg);
435 iAppView->DisableVideo();
438 void CTUiAndVideoAppUi::HandleForegroundEventL(TBool aForeground)
440 if(!aForeground && iIdleTimer)
442 if(!iIdleTimer->IsActive())
443 iIdleTimer->Start(KIdleTimeOut, 0, TCallBack(BackgroundCallBack, this) );
447 TInt CTUiAndVideoAppUi::BackgroundCallBack(TAny* aSelf)
449 CTUiAndVideoAppUi* self = static_cast<CTUiAndVideoAppUi*>(aSelf);
450 self->BringToForeground();
454 void CTUiAndVideoAppUi::BringToForeground()
456 iIdleTimer->Cancel();
457 const TInt err = iCoeEnv->WsSession().SetWindowGroupOrdinalPosition(iCoeEnv->RootWin().Identifier(), 0);
460 TInt CTUiAndVideoAppUi::PlayTimerCallBack(TAny* aSelf)
462 CTUiAndVideoAppUi* self = static_cast<CTUiAndVideoAppUi*>(aSelf);
463 self->iPlayTimer->Cancel();
464 self->iAppView->PlayVideo();
465 self->iInitialised = ETrue;
470 void CTUiAndVideoAppUi::HandleCommandL(TInt aCommand)
474 case ETestCmdOpen: // Open and prepare
476 iAppView->DisableVideo();
479 iLoadingPlayer->RemoveDisplayWindow(const_cast<RWindow&>(iAppView->TheWindow()));
480 iLoadingPlayer->Close();
481 delete iLoadingPlayer;
482 iLoadingPlayer = NULL;
484 iLoadingPlayer = CVideoPlayerUtility2::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceNone);
485 iLoadingPlayer->OpenFileL(iCurrentFile);
488 case ETestCmdPlay: // Start playback
489 iAppView->PlayVideo();
491 case ETestCmdStop: // Stop playback
492 iAppView->StopVideo();
494 case ETestCmdPlayFile:
496 case EEikCmdExit: // Exit
498 iLoadingPlayer->RemoveDisplayWindow(const_cast<RWindow&>(iAppView->TheWindow()));
504 // Video player utility callback: open complete
505 void CTUiAndVideoAppUi::MvpuoOpenComplete(TInt aError)
507 if (aError == KErrNone )
509 iLoadingPlayer->Prepare();
511 else if(aError == KErrNotFound)
512 LogError(iCurrentFile, _L("Clip not found!"));
513 else if(aError == KErrNotReady)
514 LogError(iCurrentFile, _L("Clip not ready!"));
515 else if(aError == KErrNotSupported)
516 LogError(iCurrentFile, _L("Clip format not supported!"));
519 User::Panic(_L("MvpuoOpen"), aError);
523 // Video player utility callback: prepare complete
524 void CTUiAndVideoAppUi::MvpuoPrepareComplete(TInt aError)
530 TBuf<256> loadingMsg(_L("Loading "));
532 file.Set(iCurrentFile, NULL, NULL);
533 loadingMsg.Append(file.Name());
535 TRAPD(err, iLoadingPlayer->AddDisplayWindowL(iEikonEnv->WsSession(), *iEikonEnv->ScreenDevice(), iAppView->TheWindow()));
537 LogError(iCurrentFile, _L("Window Display in use!"));
538 else if(err == KErrNotReady)
539 LogError(iCurrentFile, _L("Window Display not ready!"));
541 User::Panic(_L("PrepareComplete1"), err);
543 iAppView->EnableVideo(iLoadingPlayer);
547 case KErrMMPartialPlayback:
548 LogError(iCurrentFile, _L("Partial playback"));
552 User::Panic(_L("Prepare"), aError);
556 // Video player utility callback, not used
557 void CTUiAndVideoAppUi::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
559 User::Panic(_L("FrameReady"), aError);
562 // Video player utility callback: play complete (error or EOF)
563 void CTUiAndVideoAppUi::MvpuoPlayComplete(TInt aError)
565 iAppView->PlayComplete(aError);
567 if (aError == KErrNone)
569 if(iPlayTimer && !iPlayTimer->IsActive())
570 iPlayTimer->Start(KPlayTimeOut, 0, TCallBack(PlayTimerCallBack, this));
572 else if(aError == KErrNotSupported)
573 LogError(iCurrentFile, _L("Clip format not supported!"));
574 else if(aError == KErrTooBig)
575 LogError(iCurrentFile, _L("The clip is too big!"));
576 else if(aError == KErrNoMemory)
577 LogError(KNullDesC, _L("Out of memory. Likely memory leak!"));
578 else if(aError == KErrNotReady)
579 LogError(KNullDesC, _L("Clip not ready. Removed MMC?!"));
581 User::Panic(_L("PlayComplete"), aError);
584 // Video player utility callback: event (not used?)
585 void CTUiAndVideoAppUi::MvpuoEvent(const TMMFEvent& aEvent)
587 User::Panic(_L("Event"), aEvent.iErrorCode);
591 //************************************************************************************************************
592 // View implementation
593 // -- draws the display
594 //************************************************************************************************************
596 CTestAppView* CTestAppView::NewL(const TRect& aRect)
598 CTestAppView* self = new(ELeave) CTestAppView();
599 CleanupStack::PushL(self);
600 self->ConstructL(aRect);
605 CTestAppView::~CTestAppView()
609 iCurrentPlayer->RemoveDisplayWindow(TheWindow());
610 iCurrentPlayer->Close();
611 delete iCurrentPlayer;
617 CTestAppView::CTestAppView() :
623 RWindow& CTestAppView::TheWindow()
625 __ASSERT_ALWAYS(iVideoPane, User::Panic(_L("TheWindow"), 0));
626 return iVideoPane->TheWindow();
629 void CTestAppView::ConstructL(const TRect& aWindowedRect)
631 iWindowedViewRect = aWindowedRect; // The rect used when the view is not full-screen
633 EnableWindowTransparency();
635 Window().SetPointerGrab(ETrue);
637 InitComponentArrayL();
639 iVideoPane = new (ELeave) CVideoPane();
640 Components().AppendLC(iVideoPane, KVideoControlID);
641 iVideoPane->ConstructL(*this);
642 CleanupStack::Pop(iVideoPane);
644 SetRect(iWindowedViewRect);
646 iBkgrdImage = new(ELeave) CFbsBitmap;
647 User::LeaveIfError(iBkgrdImage->Load(KVideoAppBitmapsFile, EMbmVideoplayBackground));
649 iBkgrdMask = new(ELeave) CFbsBitmap;
650 User::LeaveIfError(iBkgrdMask->Load(KVideoAppBitmapsFile, EMbmVideoplayBackground_mask));
655 void CTestAppView::SizeChanged()
657 const TRect reservedVideoRect = VideoPaneRect();
658 const TRect usedVideoRect = VideoPaneRect();
662 iVideoPane->BlackoutPane();
663 iVideoPane->SetRect(reservedVideoRect);
665 SetVideoSize(*iCurrentPlayer);
670 Sets the size and stretch characteristics of the video.
672 void CTestAppView::SetVideoSize(CVideoPlayerUtility2& aVideo) const
674 const TRect videoRect(iVideoPane->Rect());
676 CTUiAndVideoAppUi* myAppUi = dynamic_cast<CTUiAndVideoAppUi *>(iCoeEnv->AppUi());
678 TRAPD(err, aVideo.SetWindowClipRectL(TheWindow(), videoRect));
679 if(err == KErrArgument)
680 myAppUi->LogError(KNullDesC, _L("Clip rect not within window!"));
681 else if(err == KErrNotReady)
682 myAppUi->LogError(KNullDesC, _L("Video not ready!"));
684 User::Panic(_L("SetVideoSize2"), err);
686 TRAP(err, aVideo.SetAutoScaleL(TheWindow(), EAutoScaleStretch));
687 if(err == KErrNotFound)
688 myAppUi->LogError(KNullDesC, _L("Window not added to iLoadingPlayer!"));
689 else if(err == KErrNotReady)
690 myAppUi->LogError(KNullDesC, _L("Controller not been opened!"));
692 User::Panic(_L("SetVideoSize2"), err);
694 iVideoPane->SetVideoUseRect(VideoPaneRect());
698 @return The rect of the video pane, relative to the view.
700 TRect CTestAppView::VideoPaneRect() const
702 TRect result = Rect();
704 // Make the video screen rect 10% smaller than the whole app window
705 result.Shrink(result.Width()/10, result.Height()/10);
709 void CTestAppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
711 // call base class to dispatch any possible child events first
712 // except we don't want to enter into a loop if this method has alraedy been
713 // called from the video child control....
714 if (!iVideoPane->IsVideoPanePointerEvent())
715 CCoeControl::HandlePointerEventL(aPointerEvent);
717 if(aPointerEvent.iType == TPointerEvent::EButton1Down)
719 // get the position (we may need to get the parent's if event came from video child control)
720 iPointerDownPos = iVideoPane->IsVideoPanePointerEvent() ? aPointerEvent.iParentPosition : aPointerEvent.iPosition;
724 if(now.MicroSecondsFrom(iPointerDownTime) < KTapTimeOut) // If quick double-tap
726 IgnoreEventsUntilNextPointerUp();
730 iPointerDownTime.UniversalTime();
732 else if(aPointerEvent.iType == TPointerEvent::EDrag)
734 // Set new position relative to the amount of movement with pointer down event
735 TPoint newPos = (iVideoPane->IsVideoPanePointerEvent() ? aPointerEvent.iParentPosition : aPointerEvent.iPosition) - iPointerDownPos;
736 if(newPos != TPoint())
737 SetPosition(Position()+newPos);
741 TKeyResponse CTestAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
743 if(aType == EEventKey)
745 switch(aKeyEvent.iCode)
748 // To avoid linking with eikcore.lib
749 //if(iEikonEnv->QueryWinL(_L("Exit?"), _L("Sure you want to exit?")))
751 iEikonEnv->EikAppUi()->HandleCommandL(EEikCmdExit);
752 return EKeyWasConsumed;
756 return EKeyWasConsumed;
759 return EKeyWasConsumed;
766 return EKeyWasConsumed;
768 iRunMode = ETestCmdStill;
769 return EKeyWasConsumed;
771 return EKeyWasConsumed;
777 return EKeyWasNotConsumed;
780 void CTestAppView::Draw(const TRect& /*aRect*/) const
782 CWindowGc& gc = SystemGc();
784 // Fill the window solid
785 gc.SetDrawMode(CGraphicsContext::EDrawModePEN);
786 gc.SetBrushStyle(CGraphicsContext::ENullBrush);
787 gc.DrawBitmapMasked(Rect(), iBkgrdImage, iBkgrdImage->SizeInPixels(), iBkgrdMask, EFalse);
790 void CTestAppView::HandleControlEventL(CCoeControl */*aControl*/, TCoeEvent /*aEventType*/)
796 void CTestAppView::EnableVideo(CVideoPlayerUtility2*& aPlayer)
800 iCurrentPlayer->RemoveDisplayWindow(TheWindow());
801 iCurrentPlayer->Close();
802 delete iCurrentPlayer;
805 iCurrentPlayer = aPlayer;
806 aPlayer = NULL; // Take ownership
807 const TSize oldSize = iNativeVideoSize;
808 iCurrentPlayer->VideoFrameSizeL(iNativeVideoSize);
809 SetVideoSize(*iCurrentPlayer);
810 if (oldSize!=iNativeVideoSize)
814 // Was getting a crash at startup on the emulator...not sure why.
815 // Not currently a requirement.
816 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
817 if (iCurrentPlayer->SubtitlesAvailable())
819 iCurrentPlayer->EnableSubtitlesL();
820 iVideoPane->EnableSubtitle(iCurrentPlayer);
828 void CTestAppView::DisableVideo()
830 iVideoPane->BlackoutPane();
831 PauseVideo(); // Stop playing
835 iCurrentPlayer->RemoveDisplayWindow(TheWindow());
836 iCurrentPlayer->Close();
837 delete iCurrentPlayer;
839 iVideoPane->EnableSubtitle(NULL);
840 iCurrentPlayer = NULL;
841 iNativeVideoSize = TSize();
844 void CTestAppView::SetRunMode (TUint32 aMode)
849 void CTestAppView::PlayVideo()
851 if(iCurrentPlayer && !iIsPlaying)
853 iCurrentPlayer->Play();
857 iIsPlaying = EFalse; // Can't play if there's no player
863 void CTestAppView::PauseVideo()
865 if(iCurrentPlayer && iIsPlaying)
867 TRAPD(err, iCurrentPlayer->PauseL());
869 iCurrentPlayer->Stop();
877 void CTestAppView::StopVideo()
879 if(iCurrentPlayer && iIsPlaying)
881 iCurrentPlayer->Stop();
885 iIsPlaying = ETrue; // Can't play if there's no player
891 void CTestAppView::PlayComplete(TInt /*aError*/)
898 void CTestAppView::PlayPrevious()
900 CTUiAndVideoAppUi* myAppUi = dynamic_cast<CTUiAndVideoAppUi *>(iCoeEnv->AppUi());
901 if (myAppUi->PlayPreviousFileL() != KErrNone)
903 // To avoid linking with eikcore.lib
904 //EikonEnv->InfoMsg(_L("First clip"));
908 void CTestAppView::PlayNext()
910 CTUiAndVideoAppUi* myAppUi = dynamic_cast<CTUiAndVideoAppUi*>(iCoeEnv->AppUi());
911 if (myAppUi->PlayNextFileL() != KErrNone)
913 // To avoid linking with eikcore.lib
914 //iEikonEnv->InfoMsg(_L("Last clip"));
918 void CTestAppView::UpdateButtonState()
923 Calculate and set the position of the video UI. If iAutoPosition is zero then this
926 void CTestAppView::SetPos(TPoint* aPos)
930 TRect screenRect = iCoeEnv->ScreenDevice()->SizeInPixels();
932 TSize currentSize = Size();
933 TPoint currentPos = Position();
937 case (ETestCmdBounce):
939 if ((currentPos.iX + (currentSize.iWidth >> 1)) > screenRect.iBr.iX)
942 if ((currentPos.iY + (currentSize.iHeight >> 1)) > screenRect.iBr.iY)
945 if ((currentPos.iX + (currentSize.iWidth >> 1)) < 0)
948 if ((currentPos.iY + (currentSize.iHeight >> 1)) < 0)
951 iVidPos.iX += iIncrement.iX* iDirection.iX;
952 iVidPos.iY += iIncrement.iY * iDirection.iY;
957 iVidPos.iX = Math::Random() % 100;//(screenRect.iBr.iX + (currentSize.iWidth >> 1));
958 iVidPos.iY = Math::Random() % 100;//(screenRect.iBr.iY + (currentSize.iHeight >> 1));
971 SetPosition(iVidPos);
974 //************************************************************************************************************
975 //** CVideoPane class - place 'video' window.
976 //************************************************************************************************************
979 This controll is used so that the video is not rendered onto transparency.
981 CVideoPane::~CVideoPane()
985 CVideoPane::CVideoPane()
989 void CVideoPane::ConstructL(CCoeControl& aParent)
991 CreateWindowL(&aParent);
993 Window().SetPointerGrab(ETrue);
996 void CVideoPane::HandlePointerEventL(const TPointerEvent& aPointerEvent)
998 // we need to set this flag to true, which is checked in the parent to avoid loops
999 iIsVideoPanePointerEvent = ETrue;
1000 TRAPD(err, Parent()->HandlePointerEventL(aPointerEvent));
1001 iIsVideoPanePointerEvent = EFalse;
1002 User::LeaveIfError(err);
1006 void CVideoPane::BlackoutPane()
1008 iVideoUseRect = TRect(); // reset
1011 void CVideoPane::SetVideoUseRect(const TRect& aRect)
1013 iVideoUseRect = aRect;
1014 iVideoUseRect.Move(-Position()); // Compensate for the fact that the pane is window owning
1017 void CVideoPane::SizeChanged()
1019 CCoeControl::SizeChanged();
1020 iVideoUseRect = TRect(); // reset
1023 TBool CVideoPane::IsVideoPanePointerEvent()
1025 return iIsVideoPanePointerEvent;
1028 void CVideoPane::EnableSubtitle(CVideoPlayerUtility2* aSubtitlePlayer)
1030 iSubtitlePlayer = aSubtitlePlayer;
1033 void CVideoPane::Draw(const TRect& aRect) const
1035 (void)aRect; //to remove warning if SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT not defined
1036 CWindowGc& gc=SystemGc();
1038 gc.SetBrushColor(KRgbRed);
1040 gc.SetBrushColor(KRgbBlack);
1042 DrawUtils::ClearBetweenRects(gc, Rect(), iVideoUseRect);
1044 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1045 if (iSubtitlePlayer)
1046 iSubtitlePlayer->RedrawSubtitle(Window(), aRect);