sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@test
|
sl@0
|
22 |
@internalComponent - Internal Symbian test code
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
/**
|
sl@0
|
26 |
This test depends on the following environment:
|
sl@0
|
27 |
|
sl@0
|
28 |
==========================================================================
|
sl@0
|
29 |
== Required step - Install Xvid codec
|
sl@0
|
30 |
==========================================================================
|
sl@0
|
31 |
Note that these drivers are distributed under the GNU GENERAL PUBLIC LICENSE.
|
sl@0
|
32 |
|
sl@0
|
33 |
** Go to:
|
sl@0
|
34 |
http://developer.symbian.com/wiki/display/pub/Open+source+projects
|
sl@0
|
35 |
and get the XviD source zip:
|
sl@0
|
36 |
http://developer.symbian.com/wiki/download/attachments/1154/xvid.zip
|
sl@0
|
37 |
|
sl@0
|
38 |
** Unzip this file and build the source in
|
sl@0
|
39 |
xvidhwdevice\group
|
sl@0
|
40 |
xvidpu\group
|
sl@0
|
41 |
|
sl@0
|
42 |
|
sl@0
|
43 |
==========================================================================
|
sl@0
|
44 |
== Required step - Running on emulator - Modify epoc.ini and wsini.ini
|
sl@0
|
45 |
==========================================================================
|
sl@0
|
46 |
|
sl@0
|
47 |
** Update your epoc.ini so that GCE is enabled. Add:
|
sl@0
|
48 |
...
|
sl@0
|
49 |
SYMBIAN_GRAPHICS_USE_GCE ON
|
sl@0
|
50 |
SYMBIAN_BASE_USE_GCE ON
|
sl@0
|
51 |
...
|
sl@0
|
52 |
|
sl@0
|
53 |
** Update your wsini.ini so that the following is present:
|
sl@0
|
54 |
...
|
sl@0
|
55 |
WINDOWMODE COLOR16MAP
|
sl@0
|
56 |
KEYCLICKPLUGIN KeyClickRef
|
sl@0
|
57 |
TRANSPARENCY
|
sl@0
|
58 |
CHROMAKEYCOLOR 0xFFFF00FF
|
sl@0
|
59 |
...
|
sl@0
|
60 |
|
sl@0
|
61 |
|
sl@0
|
62 |
==========================================================================
|
sl@0
|
63 |
== Required step - Running on hardware - Buildrom command
|
sl@0
|
64 |
==========================================================================
|
sl@0
|
65 |
|
sl@0
|
66 |
** When building the rom, make sure you use the following flags
|
sl@0
|
67 |
buildrom
|
sl@0
|
68 |
<options>
|
sl@0
|
69 |
-DSYMBIAN_BASE_USE_GCE
|
sl@0
|
70 |
-DSYMBIAN_GRAPHICS_USE_GCE
|
sl@0
|
71 |
-DUSE_24BPP_DISPLAY_VARIANT
|
sl@0
|
72 |
<further options/flags>
|
sl@0
|
73 |
videoplay.iby
|
sl@0
|
74 |
<further oby/iby files>
|
sl@0
|
75 |
|
sl@0
|
76 |
the xvid video drivers being installed in the runtime environment.
|
sl@0
|
77 |
*/
|
sl@0
|
78 |
|
sl@0
|
79 |
#include "tuiandvideo.h"
|
sl@0
|
80 |
|
sl@0
|
81 |
#include <mmf/common/mmferrors.h>
|
sl@0
|
82 |
|
sl@0
|
83 |
#ifdef __WINS__
|
sl@0
|
84 |
_LIT(KDefaultDirName, "c:\\videoplay\\");
|
sl@0
|
85 |
#else
|
sl@0
|
86 |
_LIT(KDefaultDirName, "e:\\videoplay\\");
|
sl@0
|
87 |
#endif
|
sl@0
|
88 |
|
sl@0
|
89 |
_LIT(KDefaultFileExt, "*.avi");
|
sl@0
|
90 |
_LIT(KDefaultFile, "skiing2.avi");
|
sl@0
|
91 |
|
sl@0
|
92 |
const TTimeIntervalMicroSeconds KTapTimeOut(300*1000);
|
sl@0
|
93 |
const TTimeIntervalMicroSeconds32 KIdleTimeOut(1*1000*1000);
|
sl@0
|
94 |
const TTimeIntervalMicroSeconds32 KPlayTimeOut(2*1000*1000);
|
sl@0
|
95 |
const TTimeIntervalMicroSeconds32 KButtonTimeOut(2*1000*1000);
|
sl@0
|
96 |
|
sl@0
|
97 |
_LIT(KVideoAppBitmapsFile, "z:\\resource\\apps\\videoplay2.mbm");
|
sl@0
|
98 |
|
sl@0
|
99 |
//From videoplay.hrh
|
sl@0
|
100 |
enum TTestCommands
|
sl@0
|
101 |
{
|
sl@0
|
102 |
ETestCmdOpen = 1000,
|
sl@0
|
103 |
ETestCmdStop,
|
sl@0
|
104 |
ETestCmdPlayFile
|
sl@0
|
105 |
};
|
sl@0
|
106 |
|
sl@0
|
107 |
//UIBench test step commands
|
sl@0
|
108 |
enum TTestStepCommand
|
sl@0
|
109 |
{
|
sl@0
|
110 |
ETestCmdInitialised = 0,
|
sl@0
|
111 |
ETestCmdPlay,
|
sl@0
|
112 |
ETestCmdPause,
|
sl@0
|
113 |
ETestCmdBounce,
|
sl@0
|
114 |
ETestCmdJump,
|
sl@0
|
115 |
ETestCmdStill,
|
sl@0
|
116 |
ETestCmdExit
|
sl@0
|
117 |
};
|
sl@0
|
118 |
|
sl@0
|
119 |
// From videoplay.mbg
|
sl@0
|
120 |
enum TMbmVideoplay
|
sl@0
|
121 |
{
|
sl@0
|
122 |
EMbmVideoplayBackground,
|
sl@0
|
123 |
EMbmVideoplayBackground_mask,
|
sl@0
|
124 |
};
|
sl@0
|
125 |
|
sl@0
|
126 |
|
sl@0
|
127 |
/**
|
sl@0
|
128 |
A command handler to act as an interface through which to drive the test.
|
sl@0
|
129 |
@param aController View controller, in the classic sense of MVC. This object
|
sl@0
|
130 |
is used to drive the test.
|
sl@0
|
131 |
*/
|
sl@0
|
132 |
CCommandSink::CCommandSink (CTestAppView* aTestView) :
|
sl@0
|
133 |
CActive(EPriorityStandard),
|
sl@0
|
134 |
iTestView (aTestView)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
CActiveScheduler::Add(this);
|
sl@0
|
137 |
iStatus = KRequestPending;
|
sl@0
|
138 |
SetActive();
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
void CCommandSink::DoCancel()
|
sl@0
|
142 |
{
|
sl@0
|
143 |
TRequestStatus* status = &iStatus;
|
sl@0
|
144 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
CCommandSink::~CCommandSink()
|
sl@0
|
148 |
{
|
sl@0
|
149 |
Cancel();
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
void CCommandSink::Init(RThread* aTargetThread, TRequestStatus* aTargetStatus)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
iTargetThread = aTargetThread;
|
sl@0
|
155 |
iTargetStatus = aTargetStatus;
|
sl@0
|
156 |
}
|
sl@0
|
157 |
|
sl@0
|
158 |
/**
|
sl@0
|
159 |
Signals the control thread (target) with a command. There must be a protocol between the
|
sl@0
|
160 |
controller and the control (the test thread) in terms of communication of command
|
sl@0
|
161 |
signals.
|
sl@0
|
162 |
*/
|
sl@0
|
163 |
void CCommandSink::RunL ()
|
sl@0
|
164 |
{
|
sl@0
|
165 |
switch (iStatus.Int())
|
sl@0
|
166 |
{
|
sl@0
|
167 |
case ETestCmdPlay:
|
sl@0
|
168 |
iTestView->PlayVideo();
|
sl@0
|
169 |
break;
|
sl@0
|
170 |
case ETestCmdPause:
|
sl@0
|
171 |
iTestView->PauseVideo();
|
sl@0
|
172 |
break;
|
sl@0
|
173 |
case ETestCmdBounce:
|
sl@0
|
174 |
case ETestCmdJump:
|
sl@0
|
175 |
case ETestCmdStill:
|
sl@0
|
176 |
iTestView->SetRunMode(iStatus.Int());
|
sl@0
|
177 |
break;
|
sl@0
|
178 |
}
|
sl@0
|
179 |
|
sl@0
|
180 |
iStatus = KRequestPending;
|
sl@0
|
181 |
SetActive();
|
sl@0
|
182 |
}
|
sl@0
|
183 |
|
sl@0
|
184 |
CTUiAndVideo::CTUiAndVideo()
|
sl@0
|
185 |
{
|
sl@0
|
186 |
SetTestStepName(KTUiAndVideo);
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
void CTUiAndVideo::IssueCommand (TUint aCommand)
|
sl@0
|
190 |
{
|
sl@0
|
191 |
TRequestStatus* targetStatus = iAppUi->CommandSink();
|
sl@0
|
192 |
ConeThread()->RequestComplete(targetStatus, aCommand);
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
void CTUiAndVideo::StepState (TUint aNextState, TUint aPause)
|
sl@0
|
196 |
{
|
sl@0
|
197 |
User::After(aPause);
|
sl@0
|
198 |
TRequestStatus* testState = &iTestState;
|
sl@0
|
199 |
User::RequestComplete (testState, aNextState);
|
sl@0
|
200 |
}
|
sl@0
|
201 |
|
sl@0
|
202 |
/**
|
sl@0
|
203 |
@SYMTestCaseID GRAPHICS-UI-BENCH-XXXX
|
sl@0
|
204 |
@SYMTestCaseDesc Put description here
|
sl@0
|
205 |
@SYMTestActions Put description here
|
sl@0
|
206 |
@SYMTestExpectedResults Put description here
|
sl@0
|
207 |
*/
|
sl@0
|
208 |
TVerdict CTUiAndVideo::doTestStepL()
|
sl@0
|
209 |
{
|
sl@0
|
210 |
iProfiler->InitResults();
|
sl@0
|
211 |
|
sl@0
|
212 |
StepState(ETestCmdInitialised, 0);
|
sl@0
|
213 |
|
sl@0
|
214 |
TBool continueTest = ETrue;
|
sl@0
|
215 |
while (continueTest)
|
sl@0
|
216 |
{
|
sl@0
|
217 |
User::WaitForRequest(iTestState);
|
sl@0
|
218 |
switch (iTestState.Int())
|
sl@0
|
219 |
{
|
sl@0
|
220 |
case ETestCmdInitialised:
|
sl@0
|
221 |
User::After(5000000);
|
sl@0
|
222 |
case ETestCmdPlay:
|
sl@0
|
223 |
IssueCommand(ETestCmdPlay);
|
sl@0
|
224 |
StepState(ETestCmdBounce, 5000000);
|
sl@0
|
225 |
break;
|
sl@0
|
226 |
case ETestCmdPause:
|
sl@0
|
227 |
break;
|
sl@0
|
228 |
case ETestCmdBounce:
|
sl@0
|
229 |
IssueCommand(ETestCmdBounce);
|
sl@0
|
230 |
StepState(ETestCmdJump, 15000000);
|
sl@0
|
231 |
break;
|
sl@0
|
232 |
case ETestCmdJump:
|
sl@0
|
233 |
IssueCommand(ETestCmdJump);
|
sl@0
|
234 |
StepState(ETestCmdExit, 15000000);
|
sl@0
|
235 |
case ETestCmdExit:
|
sl@0
|
236 |
continueTest = EFalse;
|
sl@0
|
237 |
break;
|
sl@0
|
238 |
default:
|
sl@0
|
239 |
continueTest = EFalse;
|
sl@0
|
240 |
RDebug::Printf("Invalid test state!");
|
sl@0
|
241 |
}
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
return TestStepResult();
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
/**
|
sl@0
|
248 |
Runs on test thread.
|
sl@0
|
249 |
*/
|
sl@0
|
250 |
void CTUiAndVideo::InitUIL(CCoeEnv* aCoeEnv)
|
sl@0
|
251 |
{
|
sl@0
|
252 |
iAppUi = new CTUiAndVideoAppUi();
|
sl@0
|
253 |
|
sl@0
|
254 |
iAppUi->ConstructL(iTestState);
|
sl@0
|
255 |
aCoeEnv->SetAppUi(iAppUi);
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
//############################################################################################################
|
sl@0
|
259 |
//############################################################################################################
|
sl@0
|
260 |
//############################################################################################################
|
sl@0
|
261 |
//############################################################################################################
|
sl@0
|
262 |
|
sl@0
|
263 |
//************************************************************************************************************
|
sl@0
|
264 |
// Application UI implementation
|
sl@0
|
265 |
// -- most control logic is here
|
sl@0
|
266 |
//************************************************************************************************************
|
sl@0
|
267 |
|
sl@0
|
268 |
void SetCenter(TRect& aRect, const TPoint& aCenterPoint)
|
sl@0
|
269 |
{
|
sl@0
|
270 |
const TSize size = aRect.Size();
|
sl@0
|
271 |
const TPoint pos(aCenterPoint-TSize(size.iWidth/2,size.iHeight/2).AsPoint());
|
sl@0
|
272 |
aRect.SetRect(pos, size);
|
sl@0
|
273 |
}
|
sl@0
|
274 |
|
sl@0
|
275 |
void CTUiAndVideoAppUi::ConstructL(TRequestStatus /*iCommandSource*/)
|
sl@0
|
276 |
{
|
sl@0
|
277 |
BaseConstructL(ENoAppResourceFile);
|
sl@0
|
278 |
|
sl@0
|
279 |
// Calculate the size of the application window
|
sl@0
|
280 |
// Make the player square, slightly (one 16th) smaller than
|
sl@0
|
281 |
// the smallest side of the screen
|
sl@0
|
282 |
TRect rect (0, 0, 300, 150);
|
sl@0
|
283 |
|
sl@0
|
284 |
TRect screenRect = iCoeEnv->ScreenDevice()->SizeInPixels();
|
sl@0
|
285 |
SetCenter(rect, screenRect.Center()); // Center the rect on the screen
|
sl@0
|
286 |
|
sl@0
|
287 |
// Create the application view
|
sl@0
|
288 |
iAppView = CTestAppView::NewL(rect);
|
sl@0
|
289 |
AddToStackL(iAppView);
|
sl@0
|
290 |
|
sl@0
|
291 |
iCommandSink = new (ELeave) CCommandSink(iAppView);
|
sl@0
|
292 |
|
sl@0
|
293 |
// Enable iIdleTimer to make the app return to foreground after a set delay
|
sl@0
|
294 |
iIdleTimer = CPeriodic::NewL(CActive::EPriorityStandard);
|
sl@0
|
295 |
// iUIMover moves the UI around the display.
|
sl@0
|
296 |
iUIMover = CPeriodic::NewL(CActive::EPriorityStandard);
|
sl@0
|
297 |
iUIMover->Start(KIdleTimeOut, 50000, TCallBack(UIMoverCallBack, this));
|
sl@0
|
298 |
// Enable iPlayTimer to make the video pause a little while before starting playing again
|
sl@0
|
299 |
iPlayTimer = CPeriodic::NewL(CActive::EPriorityStandard);
|
sl@0
|
300 |
|
sl@0
|
301 |
iAppView->SetPos(&rect.iTl);
|
sl@0
|
302 |
iAppView->ActivateL();
|
sl@0
|
303 |
iAppView->DrawNow();
|
sl@0
|
304 |
|
sl@0
|
305 |
// Load default video clip
|
sl@0
|
306 |
if (KErrNone == PopulateDirFilesL(KDefaultDirName))
|
sl@0
|
307 |
{
|
sl@0
|
308 |
OpenSelectedFileL(KDefaultFile);
|
sl@0
|
309 |
}
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
TRequestStatus* CTUiAndVideoAppUi::CommandSink ()
|
sl@0
|
313 |
{
|
sl@0
|
314 |
return &(iCommandSink->iStatus);
|
sl@0
|
315 |
}
|
sl@0
|
316 |
|
sl@0
|
317 |
CTUiAndVideoAppUi::~CTUiAndVideoAppUi()
|
sl@0
|
318 |
{
|
sl@0
|
319 |
if(iAppView)
|
sl@0
|
320 |
{
|
sl@0
|
321 |
RemoveFromStack(iAppView);
|
sl@0
|
322 |
delete iAppView;
|
sl@0
|
323 |
}
|
sl@0
|
324 |
delete iCommandSink;
|
sl@0
|
325 |
delete iIdleTimer;
|
sl@0
|
326 |
delete iUIMover;
|
sl@0
|
327 |
delete iPlayTimer;
|
sl@0
|
328 |
delete iLoadingPlayer;
|
sl@0
|
329 |
delete iDirList;
|
sl@0
|
330 |
}
|
sl@0
|
331 |
|
sl@0
|
332 |
TInt CTUiAndVideoAppUi::UIMoverCallBack(TAny* aSelf)
|
sl@0
|
333 |
{
|
sl@0
|
334 |
CTUiAndVideoAppUi* self = static_cast<CTUiAndVideoAppUi*>(aSelf);
|
sl@0
|
335 |
self->SetPos();
|
sl@0
|
336 |
return KErrNone;
|
sl@0
|
337 |
}
|
sl@0
|
338 |
|
sl@0
|
339 |
void CTUiAndVideoAppUi::SetPos()
|
sl@0
|
340 |
{
|
sl@0
|
341 |
iAppView->SetPos(NULL);
|
sl@0
|
342 |
}
|
sl@0
|
343 |
|
sl@0
|
344 |
TInt CTUiAndVideoAppUi::PopulateDirFilesL(const TDesC& aDir)
|
sl@0
|
345 |
{
|
sl@0
|
346 |
// Load files in default folder
|
sl@0
|
347 |
RFs fs;
|
sl@0
|
348 |
User::LeaveIfError(fs.Connect());
|
sl@0
|
349 |
|
sl@0
|
350 |
// Get the file list, sorted by name - Only with KDefaultFileExt
|
sl@0
|
351 |
TFileName dir(aDir);
|
sl@0
|
352 |
dir.Append(KDefaultFileExt);
|
sl@0
|
353 |
|
sl@0
|
354 |
delete iDirList;
|
sl@0
|
355 |
iDirList = NULL;
|
sl@0
|
356 |
TInt err = fs.GetDir(dir, KEntryAttMaskSupported, ESortByName, iDirList);
|
sl@0
|
357 |
fs.Close();
|
sl@0
|
358 |
|
sl@0
|
359 |
if ((err == KErrPathNotFound) || (err == KErrNone && iDirList->Count()==0))
|
sl@0
|
360 |
{
|
sl@0
|
361 |
LogError(KNullDesC, _L("Default clip not found!"));
|
sl@0
|
362 |
return KErrNotFound;
|
sl@0
|
363 |
}
|
sl@0
|
364 |
__ASSERT_DEBUG(err==KErrNone, User::Panic(_L("PopulateDirFiles"), err));
|
sl@0
|
365 |
|
sl@0
|
366 |
// set the current file with the current folder (for the time being)
|
sl@0
|
367 |
iCurrentFile.Zero();
|
sl@0
|
368 |
iCurrentFile.Append(aDir);
|
sl@0
|
369 |
return KErrNone;
|
sl@0
|
370 |
}
|
sl@0
|
371 |
|
sl@0
|
372 |
void CTUiAndVideoAppUi::OpenSelectedFileL(const TDesC& aFile)
|
sl@0
|
373 |
{
|
sl@0
|
374 |
__ASSERT_DEBUG(iDirList, User::Panic(_L("iDirList"), 0));
|
sl@0
|
375 |
TBool defaultFound = EFalse;
|
sl@0
|
376 |
for (iCurrentIndex=0; iCurrentIndex < iDirList->Count(); iCurrentIndex++)
|
sl@0
|
377 |
{
|
sl@0
|
378 |
TFileName fileName = (*iDirList)[iCurrentIndex].iName;
|
sl@0
|
379 |
if (fileName.Compare(aFile) ==0)
|
sl@0
|
380 |
{
|
sl@0
|
381 |
defaultFound = ETrue;
|
sl@0
|
382 |
break;
|
sl@0
|
383 |
}
|
sl@0
|
384 |
}
|
sl@0
|
385 |
if (!defaultFound)
|
sl@0
|
386 |
{
|
sl@0
|
387 |
// To avoid linking with eikcore.lib
|
sl@0
|
388 |
//iEikonEnv->InfoMsg(_L("Default file not found..."));
|
sl@0
|
389 |
iCurrentIndex = 0; // if no default, pick the first movie on the list
|
sl@0
|
390 |
}
|
sl@0
|
391 |
|
sl@0
|
392 |
iCurrentFile.Append((*iDirList)[iCurrentIndex].iName);
|
sl@0
|
393 |
// play the selected file.
|
sl@0
|
394 |
HandleCommandL(ETestCmdOpen);
|
sl@0
|
395 |
}
|
sl@0
|
396 |
|
sl@0
|
397 |
TInt CTUiAndVideoAppUi::PlayNextFileL()
|
sl@0
|
398 |
{
|
sl@0
|
399 |
__ASSERT_DEBUG(iDirList, User::Panic(_L("iDirList"), 0));
|
sl@0
|
400 |
if (iCurrentIndex == (iDirList->Count()-1))
|
sl@0
|
401 |
{
|
sl@0
|
402 |
return KErrNotFound;
|
sl@0
|
403 |
}
|
sl@0
|
404 |
iCurrentIndex++;
|
sl@0
|
405 |
TParse file;
|
sl@0
|
406 |
file.Set(iCurrentFile, NULL, NULL);
|
sl@0
|
407 |
iCurrentFile = file.DriveAndPath();
|
sl@0
|
408 |
iCurrentFile.Append((*iDirList)[iCurrentIndex].iName);
|
sl@0
|
409 |
HandleCommandL(ETestCmdOpen);
|
sl@0
|
410 |
return KErrNone;
|
sl@0
|
411 |
}
|
sl@0
|
412 |
|
sl@0
|
413 |
TInt CTUiAndVideoAppUi::PlayPreviousFileL()
|
sl@0
|
414 |
{
|
sl@0
|
415 |
__ASSERT_DEBUG(iDirList, User::Panic(_L("iDirList"), 0));
|
sl@0
|
416 |
if (iCurrentIndex == 0)
|
sl@0
|
417 |
{
|
sl@0
|
418 |
return KErrNotFound;
|
sl@0
|
419 |
}
|
sl@0
|
420 |
iCurrentIndex--;
|
sl@0
|
421 |
TParse file;
|
sl@0
|
422 |
file.Set(iCurrentFile, NULL, NULL);
|
sl@0
|
423 |
iCurrentFile = file.DriveAndPath();
|
sl@0
|
424 |
iCurrentFile.Append((*iDirList)[iCurrentIndex].iName);
|
sl@0
|
425 |
HandleCommandL(ETestCmdOpen);
|
sl@0
|
426 |
return KErrNone;
|
sl@0
|
427 |
}
|
sl@0
|
428 |
|
sl@0
|
429 |
void CTUiAndVideoAppUi::LogError(const TDesC& /* aFileName */, const TDesC& /* aErrorMsg */)
|
sl@0
|
430 |
{
|
sl@0
|
431 |
// TODO: Fix this logging strategy. Printf uses C-like pointers, not Symbian
|
sl@0
|
432 |
// descriptors
|
sl@0
|
433 |
//RDebug::Printf("Error: %s %s", aFileName, aErrorMsg);
|
sl@0
|
434 |
if(iAppView)
|
sl@0
|
435 |
iAppView->DisableVideo();
|
sl@0
|
436 |
}
|
sl@0
|
437 |
|
sl@0
|
438 |
void CTUiAndVideoAppUi::HandleForegroundEventL(TBool aForeground)
|
sl@0
|
439 |
{
|
sl@0
|
440 |
if(!aForeground && iIdleTimer)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
if(!iIdleTimer->IsActive())
|
sl@0
|
443 |
iIdleTimer->Start(KIdleTimeOut, 0, TCallBack(BackgroundCallBack, this) );
|
sl@0
|
444 |
}
|
sl@0
|
445 |
}
|
sl@0
|
446 |
|
sl@0
|
447 |
TInt CTUiAndVideoAppUi::BackgroundCallBack(TAny* aSelf)
|
sl@0
|
448 |
{
|
sl@0
|
449 |
CTUiAndVideoAppUi* self = static_cast<CTUiAndVideoAppUi*>(aSelf);
|
sl@0
|
450 |
self->BringToForeground();
|
sl@0
|
451 |
return KErrNone;
|
sl@0
|
452 |
}
|
sl@0
|
453 |
|
sl@0
|
454 |
void CTUiAndVideoAppUi::BringToForeground()
|
sl@0
|
455 |
{
|
sl@0
|
456 |
iIdleTimer->Cancel();
|
sl@0
|
457 |
const TInt err = iCoeEnv->WsSession().SetWindowGroupOrdinalPosition(iCoeEnv->RootWin().Identifier(), 0);
|
sl@0
|
458 |
}
|
sl@0
|
459 |
|
sl@0
|
460 |
TInt CTUiAndVideoAppUi::PlayTimerCallBack(TAny* aSelf)
|
sl@0
|
461 |
{
|
sl@0
|
462 |
CTUiAndVideoAppUi* self = static_cast<CTUiAndVideoAppUi*>(aSelf);
|
sl@0
|
463 |
self->iPlayTimer->Cancel();
|
sl@0
|
464 |
self->iAppView->PlayVideo();
|
sl@0
|
465 |
self->iInitialised = ETrue;
|
sl@0
|
466 |
|
sl@0
|
467 |
return KErrNone;
|
sl@0
|
468 |
}
|
sl@0
|
469 |
|
sl@0
|
470 |
void CTUiAndVideoAppUi::HandleCommandL(TInt aCommand)
|
sl@0
|
471 |
{
|
sl@0
|
472 |
switch (aCommand)
|
sl@0
|
473 |
{
|
sl@0
|
474 |
case ETestCmdOpen: // Open and prepare
|
sl@0
|
475 |
{
|
sl@0
|
476 |
iAppView->DisableVideo();
|
sl@0
|
477 |
if(iLoadingPlayer)
|
sl@0
|
478 |
{
|
sl@0
|
479 |
iLoadingPlayer->RemoveDisplayWindow(const_cast<RWindow&>(iAppView->TheWindow()));
|
sl@0
|
480 |
iLoadingPlayer->Close();
|
sl@0
|
481 |
delete iLoadingPlayer;
|
sl@0
|
482 |
iLoadingPlayer = NULL;
|
sl@0
|
483 |
}
|
sl@0
|
484 |
iLoadingPlayer = CVideoPlayerUtility2::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceNone);
|
sl@0
|
485 |
iLoadingPlayer->OpenFileL(iCurrentFile);
|
sl@0
|
486 |
break;
|
sl@0
|
487 |
}
|
sl@0
|
488 |
case ETestCmdPlay: // Start playback
|
sl@0
|
489 |
iAppView->PlayVideo();
|
sl@0
|
490 |
break;
|
sl@0
|
491 |
case ETestCmdStop: // Stop playback
|
sl@0
|
492 |
iAppView->StopVideo();
|
sl@0
|
493 |
break;
|
sl@0
|
494 |
case ETestCmdPlayFile:
|
sl@0
|
495 |
break;
|
sl@0
|
496 |
case EEikCmdExit: // Exit
|
sl@0
|
497 |
if(iLoadingPlayer)
|
sl@0
|
498 |
iLoadingPlayer->RemoveDisplayWindow(const_cast<RWindow&>(iAppView->TheWindow()));
|
sl@0
|
499 |
// Exit();
|
sl@0
|
500 |
break;
|
sl@0
|
501 |
}
|
sl@0
|
502 |
}
|
sl@0
|
503 |
|
sl@0
|
504 |
// Video player utility callback: open complete
|
sl@0
|
505 |
void CTUiAndVideoAppUi::MvpuoOpenComplete(TInt aError)
|
sl@0
|
506 |
{
|
sl@0
|
507 |
if (aError == KErrNone )
|
sl@0
|
508 |
{
|
sl@0
|
509 |
iLoadingPlayer->Prepare();
|
sl@0
|
510 |
}
|
sl@0
|
511 |
else if(aError == KErrNotFound)
|
sl@0
|
512 |
LogError(iCurrentFile, _L("Clip not found!"));
|
sl@0
|
513 |
else if(aError == KErrNotReady)
|
sl@0
|
514 |
LogError(iCurrentFile, _L("Clip not ready!"));
|
sl@0
|
515 |
else if(aError == KErrNotSupported)
|
sl@0
|
516 |
LogError(iCurrentFile, _L("Clip format not supported!"));
|
sl@0
|
517 |
else
|
sl@0
|
518 |
{
|
sl@0
|
519 |
User::Panic(_L("MvpuoOpen"), aError);
|
sl@0
|
520 |
}
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
// Video player utility callback: prepare complete
|
sl@0
|
524 |
void CTUiAndVideoAppUi::MvpuoPrepareComplete(TInt aError)
|
sl@0
|
525 |
{
|
sl@0
|
526 |
switch ( aError )
|
sl@0
|
527 |
{
|
sl@0
|
528 |
case KErrNone:
|
sl@0
|
529 |
{
|
sl@0
|
530 |
TBuf<256> loadingMsg(_L("Loading "));
|
sl@0
|
531 |
TParse file;
|
sl@0
|
532 |
file.Set(iCurrentFile, NULL, NULL);
|
sl@0
|
533 |
loadingMsg.Append(file.Name());
|
sl@0
|
534 |
|
sl@0
|
535 |
TRAPD(err, iLoadingPlayer->AddDisplayWindowL(iEikonEnv->WsSession(), *iEikonEnv->ScreenDevice(), iAppView->TheWindow()));
|
sl@0
|
536 |
if(err == KErrInUse)
|
sl@0
|
537 |
LogError(iCurrentFile, _L("Window Display in use!"));
|
sl@0
|
538 |
else if(err == KErrNotReady)
|
sl@0
|
539 |
LogError(iCurrentFile, _L("Window Display not ready!"));
|
sl@0
|
540 |
else if(err)
|
sl@0
|
541 |
User::Panic(_L("PrepareComplete1"), err);
|
sl@0
|
542 |
|
sl@0
|
543 |
iAppView->EnableVideo(iLoadingPlayer);
|
sl@0
|
544 |
}
|
sl@0
|
545 |
break;
|
sl@0
|
546 |
|
sl@0
|
547 |
case KErrMMPartialPlayback:
|
sl@0
|
548 |
LogError(iCurrentFile, _L("Partial playback"));
|
sl@0
|
549 |
break;
|
sl@0
|
550 |
|
sl@0
|
551 |
default:
|
sl@0
|
552 |
User::Panic(_L("Prepare"), aError);
|
sl@0
|
553 |
}
|
sl@0
|
554 |
}
|
sl@0
|
555 |
|
sl@0
|
556 |
// Video player utility callback, not used
|
sl@0
|
557 |
void CTUiAndVideoAppUi::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
|
sl@0
|
558 |
{
|
sl@0
|
559 |
User::Panic(_L("FrameReady"), aError);
|
sl@0
|
560 |
}
|
sl@0
|
561 |
|
sl@0
|
562 |
// Video player utility callback: play complete (error or EOF)
|
sl@0
|
563 |
void CTUiAndVideoAppUi::MvpuoPlayComplete(TInt aError)
|
sl@0
|
564 |
{
|
sl@0
|
565 |
iAppView->PlayComplete(aError);
|
sl@0
|
566 |
|
sl@0
|
567 |
if (aError == KErrNone)
|
sl@0
|
568 |
{
|
sl@0
|
569 |
if(iPlayTimer && !iPlayTimer->IsActive())
|
sl@0
|
570 |
iPlayTimer->Start(KPlayTimeOut, 0, TCallBack(PlayTimerCallBack, this));
|
sl@0
|
571 |
}
|
sl@0
|
572 |
else if(aError == KErrNotSupported)
|
sl@0
|
573 |
LogError(iCurrentFile, _L("Clip format not supported!"));
|
sl@0
|
574 |
else if(aError == KErrTooBig)
|
sl@0
|
575 |
LogError(iCurrentFile, _L("The clip is too big!"));
|
sl@0
|
576 |
else if(aError == KErrNoMemory)
|
sl@0
|
577 |
LogError(KNullDesC, _L("Out of memory. Likely memory leak!"));
|
sl@0
|
578 |
else if(aError == KErrNotReady)
|
sl@0
|
579 |
LogError(KNullDesC, _L("Clip not ready. Removed MMC?!"));
|
sl@0
|
580 |
else if (aError)
|
sl@0
|
581 |
User::Panic(_L("PlayComplete"), aError);
|
sl@0
|
582 |
}
|
sl@0
|
583 |
|
sl@0
|
584 |
// Video player utility callback: event (not used?)
|
sl@0
|
585 |
void CTUiAndVideoAppUi::MvpuoEvent(const TMMFEvent& aEvent)
|
sl@0
|
586 |
{
|
sl@0
|
587 |
User::Panic(_L("Event"), aEvent.iErrorCode);
|
sl@0
|
588 |
}
|
sl@0
|
589 |
|
sl@0
|
590 |
|
sl@0
|
591 |
//************************************************************************************************************
|
sl@0
|
592 |
// View implementation
|
sl@0
|
593 |
// -- draws the display
|
sl@0
|
594 |
//************************************************************************************************************
|
sl@0
|
595 |
|
sl@0
|
596 |
CTestAppView* CTestAppView::NewL(const TRect& aRect)
|
sl@0
|
597 |
{
|
sl@0
|
598 |
CTestAppView* self = new(ELeave) CTestAppView();
|
sl@0
|
599 |
CleanupStack::PushL(self);
|
sl@0
|
600 |
self->ConstructL(aRect);
|
sl@0
|
601 |
CleanupStack::Pop();
|
sl@0
|
602 |
return self;
|
sl@0
|
603 |
}
|
sl@0
|
604 |
|
sl@0
|
605 |
CTestAppView::~CTestAppView()
|
sl@0
|
606 |
{
|
sl@0
|
607 |
if(iCurrentPlayer)
|
sl@0
|
608 |
{
|
sl@0
|
609 |
iCurrentPlayer->RemoveDisplayWindow(TheWindow());
|
sl@0
|
610 |
iCurrentPlayer->Close();
|
sl@0
|
611 |
delete iCurrentPlayer;
|
sl@0
|
612 |
}
|
sl@0
|
613 |
delete iBkgrdImage;
|
sl@0
|
614 |
delete iBkgrdMask;
|
sl@0
|
615 |
}
|
sl@0
|
616 |
|
sl@0
|
617 |
CTestAppView::CTestAppView() :
|
sl@0
|
618 |
iIncrement (2, 2),
|
sl@0
|
619 |
iDirection (1, 1)
|
sl@0
|
620 |
{
|
sl@0
|
621 |
}
|
sl@0
|
622 |
|
sl@0
|
623 |
RWindow& CTestAppView::TheWindow()
|
sl@0
|
624 |
{
|
sl@0
|
625 |
__ASSERT_ALWAYS(iVideoPane, User::Panic(_L("TheWindow"), 0));
|
sl@0
|
626 |
return iVideoPane->TheWindow();
|
sl@0
|
627 |
}
|
sl@0
|
628 |
|
sl@0
|
629 |
void CTestAppView::ConstructL(const TRect& aWindowedRect)
|
sl@0
|
630 |
{
|
sl@0
|
631 |
iWindowedViewRect = aWindowedRect; // The rect used when the view is not full-screen
|
sl@0
|
632 |
CreateWindowL();
|
sl@0
|
633 |
EnableWindowTransparency();
|
sl@0
|
634 |
EnableDragEvents();
|
sl@0
|
635 |
Window().SetPointerGrab(ETrue);
|
sl@0
|
636 |
|
sl@0
|
637 |
InitComponentArrayL();
|
sl@0
|
638 |
|
sl@0
|
639 |
iVideoPane = new (ELeave) CVideoPane();
|
sl@0
|
640 |
Components().AppendLC(iVideoPane, KVideoControlID);
|
sl@0
|
641 |
iVideoPane->ConstructL(*this);
|
sl@0
|
642 |
CleanupStack::Pop(iVideoPane);
|
sl@0
|
643 |
|
sl@0
|
644 |
SetRect(iWindowedViewRect);
|
sl@0
|
645 |
|
sl@0
|
646 |
iBkgrdImage = new(ELeave) CFbsBitmap;
|
sl@0
|
647 |
User::LeaveIfError(iBkgrdImage->Load(KVideoAppBitmapsFile, EMbmVideoplayBackground));
|
sl@0
|
648 |
|
sl@0
|
649 |
iBkgrdMask = new(ELeave) CFbsBitmap;
|
sl@0
|
650 |
User::LeaveIfError(iBkgrdMask->Load(KVideoAppBitmapsFile, EMbmVideoplayBackground_mask));
|
sl@0
|
651 |
|
sl@0
|
652 |
ActivateL();
|
sl@0
|
653 |
}
|
sl@0
|
654 |
|
sl@0
|
655 |
void CTestAppView::SizeChanged()
|
sl@0
|
656 |
{
|
sl@0
|
657 |
const TRect reservedVideoRect = VideoPaneRect();
|
sl@0
|
658 |
const TRect usedVideoRect = VideoPaneRect();
|
sl@0
|
659 |
|
sl@0
|
660 |
if(iVideoPane)
|
sl@0
|
661 |
{
|
sl@0
|
662 |
iVideoPane->BlackoutPane();
|
sl@0
|
663 |
iVideoPane->SetRect(reservedVideoRect);
|
sl@0
|
664 |
if(iCurrentPlayer)
|
sl@0
|
665 |
SetVideoSize(*iCurrentPlayer);
|
sl@0
|
666 |
}
|
sl@0
|
667 |
}
|
sl@0
|
668 |
|
sl@0
|
669 |
/**
|
sl@0
|
670 |
Sets the size and stretch characteristics of the video.
|
sl@0
|
671 |
*/
|
sl@0
|
672 |
void CTestAppView::SetVideoSize(CVideoPlayerUtility2& aVideo) const
|
sl@0
|
673 |
{
|
sl@0
|
674 |
const TRect videoRect(iVideoPane->Rect());
|
sl@0
|
675 |
|
sl@0
|
676 |
CTUiAndVideoAppUi* myAppUi = dynamic_cast<CTUiAndVideoAppUi *>(iCoeEnv->AppUi());
|
sl@0
|
677 |
|
sl@0
|
678 |
TRAPD(err, aVideo.SetWindowClipRectL(TheWindow(), videoRect));
|
sl@0
|
679 |
if(err == KErrArgument)
|
sl@0
|
680 |
myAppUi->LogError(KNullDesC, _L("Clip rect not within window!"));
|
sl@0
|
681 |
else if(err == KErrNotReady)
|
sl@0
|
682 |
myAppUi->LogError(KNullDesC, _L("Video not ready!"));
|
sl@0
|
683 |
else if(err)
|
sl@0
|
684 |
User::Panic(_L("SetVideoSize2"), err);
|
sl@0
|
685 |
#if 1
|
sl@0
|
686 |
TRAP(err, aVideo.SetAutoScaleL(TheWindow(), EAutoScaleStretch));
|
sl@0
|
687 |
if(err == KErrNotFound)
|
sl@0
|
688 |
myAppUi->LogError(KNullDesC, _L("Window not added to iLoadingPlayer!"));
|
sl@0
|
689 |
else if(err == KErrNotReady)
|
sl@0
|
690 |
myAppUi->LogError(KNullDesC, _L("Controller not been opened!"));
|
sl@0
|
691 |
else if(err)
|
sl@0
|
692 |
User::Panic(_L("SetVideoSize2"), err);
|
sl@0
|
693 |
#endif
|
sl@0
|
694 |
iVideoPane->SetVideoUseRect(VideoPaneRect());
|
sl@0
|
695 |
}
|
sl@0
|
696 |
|
sl@0
|
697 |
/**
|
sl@0
|
698 |
@return The rect of the video pane, relative to the view.
|
sl@0
|
699 |
*/
|
sl@0
|
700 |
TRect CTestAppView::VideoPaneRect() const
|
sl@0
|
701 |
{
|
sl@0
|
702 |
TRect result = Rect();
|
sl@0
|
703 |
|
sl@0
|
704 |
// Make the video screen rect 10% smaller than the whole app window
|
sl@0
|
705 |
result.Shrink(result.Width()/10, result.Height()/10);
|
sl@0
|
706 |
return result;
|
sl@0
|
707 |
}
|
sl@0
|
708 |
|
sl@0
|
709 |
void CTestAppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
sl@0
|
710 |
{
|
sl@0
|
711 |
// call base class to dispatch any possible child events first
|
sl@0
|
712 |
// except we don't want to enter into a loop if this method has alraedy been
|
sl@0
|
713 |
// called from the video child control....
|
sl@0
|
714 |
if (!iVideoPane->IsVideoPanePointerEvent())
|
sl@0
|
715 |
CCoeControl::HandlePointerEventL(aPointerEvent);
|
sl@0
|
716 |
|
sl@0
|
717 |
if(aPointerEvent.iType == TPointerEvent::EButton1Down)
|
sl@0
|
718 |
{
|
sl@0
|
719 |
// get the position (we may need to get the parent's if event came from video child control)
|
sl@0
|
720 |
iPointerDownPos = iVideoPane->IsVideoPanePointerEvent() ? aPointerEvent.iParentPosition : aPointerEvent.iPosition;
|
sl@0
|
721 |
TTime now;
|
sl@0
|
722 |
now.UniversalTime();
|
sl@0
|
723 |
#if 0
|
sl@0
|
724 |
if(now.MicroSecondsFrom(iPointerDownTime) < KTapTimeOut) // If quick double-tap
|
sl@0
|
725 |
{
|
sl@0
|
726 |
IgnoreEventsUntilNextPointerUp();
|
sl@0
|
727 |
ToggleViewSize();
|
sl@0
|
728 |
}
|
sl@0
|
729 |
#endif
|
sl@0
|
730 |
iPointerDownTime.UniversalTime();
|
sl@0
|
731 |
}
|
sl@0
|
732 |
else if(aPointerEvent.iType == TPointerEvent::EDrag)
|
sl@0
|
733 |
{
|
sl@0
|
734 |
// Set new position relative to the amount of movement with pointer down event
|
sl@0
|
735 |
TPoint newPos = (iVideoPane->IsVideoPanePointerEvent() ? aPointerEvent.iParentPosition : aPointerEvent.iPosition) - iPointerDownPos;
|
sl@0
|
736 |
if(newPos != TPoint())
|
sl@0
|
737 |
SetPosition(Position()+newPos);
|
sl@0
|
738 |
}
|
sl@0
|
739 |
}
|
sl@0
|
740 |
|
sl@0
|
741 |
TKeyResponse CTestAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
|
sl@0
|
742 |
{
|
sl@0
|
743 |
if(aType == EEventKey)
|
sl@0
|
744 |
{
|
sl@0
|
745 |
switch(aKeyEvent.iCode)
|
sl@0
|
746 |
{
|
sl@0
|
747 |
case EKeyEscape:
|
sl@0
|
748 |
// To avoid linking with eikcore.lib
|
sl@0
|
749 |
//if(iEikonEnv->QueryWinL(_L("Exit?"), _L("Sure you want to exit?")))
|
sl@0
|
750 |
{
|
sl@0
|
751 |
iEikonEnv->EikAppUi()->HandleCommandL(EEikCmdExit);
|
sl@0
|
752 |
return EKeyWasConsumed;
|
sl@0
|
753 |
}
|
sl@0
|
754 |
case EKeyLeftArrow:
|
sl@0
|
755 |
PlayPrevious();
|
sl@0
|
756 |
return EKeyWasConsumed;
|
sl@0
|
757 |
case EKeyRightArrow:
|
sl@0
|
758 |
PlayNext();
|
sl@0
|
759 |
return EKeyWasConsumed;
|
sl@0
|
760 |
case EKeySpace:
|
sl@0
|
761 |
if (iIsPlaying)
|
sl@0
|
762 |
PauseVideo();
|
sl@0
|
763 |
else
|
sl@0
|
764 |
PlayVideo();
|
sl@0
|
765 |
|
sl@0
|
766 |
return EKeyWasConsumed;
|
sl@0
|
767 |
case EKeyEnter:
|
sl@0
|
768 |
iRunMode = ETestCmdStill;
|
sl@0
|
769 |
return EKeyWasConsumed;
|
sl@0
|
770 |
case EKeyTab:
|
sl@0
|
771 |
return EKeyWasConsumed;
|
sl@0
|
772 |
default:
|
sl@0
|
773 |
break;
|
sl@0
|
774 |
}
|
sl@0
|
775 |
}
|
sl@0
|
776 |
|
sl@0
|
777 |
return EKeyWasNotConsumed;
|
sl@0
|
778 |
}
|
sl@0
|
779 |
|
sl@0
|
780 |
void CTestAppView::Draw(const TRect& /*aRect*/) const
|
sl@0
|
781 |
{
|
sl@0
|
782 |
CWindowGc& gc = SystemGc();
|
sl@0
|
783 |
|
sl@0
|
784 |
// Fill the window solid
|
sl@0
|
785 |
gc.SetDrawMode(CGraphicsContext::EDrawModePEN);
|
sl@0
|
786 |
gc.SetBrushStyle(CGraphicsContext::ENullBrush);
|
sl@0
|
787 |
gc.DrawBitmapMasked(Rect(), iBkgrdImage, iBkgrdImage->SizeInPixels(), iBkgrdMask, EFalse);
|
sl@0
|
788 |
}
|
sl@0
|
789 |
|
sl@0
|
790 |
void CTestAppView::HandleControlEventL(CCoeControl */*aControl*/, TCoeEvent /*aEventType*/)
|
sl@0
|
791 |
{
|
sl@0
|
792 |
return;
|
sl@0
|
793 |
}
|
sl@0
|
794 |
|
sl@0
|
795 |
// Enable video
|
sl@0
|
796 |
void CTestAppView::EnableVideo(CVideoPlayerUtility2*& aPlayer)
|
sl@0
|
797 |
{
|
sl@0
|
798 |
if(iCurrentPlayer)
|
sl@0
|
799 |
{
|
sl@0
|
800 |
iCurrentPlayer->RemoveDisplayWindow(TheWindow());
|
sl@0
|
801 |
iCurrentPlayer->Close();
|
sl@0
|
802 |
delete iCurrentPlayer;
|
sl@0
|
803 |
}
|
sl@0
|
804 |
|
sl@0
|
805 |
iCurrentPlayer = aPlayer;
|
sl@0
|
806 |
aPlayer = NULL; // Take ownership
|
sl@0
|
807 |
const TSize oldSize = iNativeVideoSize;
|
sl@0
|
808 |
iCurrentPlayer->VideoFrameSizeL(iNativeVideoSize);
|
sl@0
|
809 |
SetVideoSize(*iCurrentPlayer);
|
sl@0
|
810 |
if (oldSize!=iNativeVideoSize)
|
sl@0
|
811 |
SizeChanged();
|
sl@0
|
812 |
|
sl@0
|
813 |
#if 0
|
sl@0
|
814 |
// Was getting a crash at startup on the emulator...not sure why.
|
sl@0
|
815 |
// Not currently a requirement.
|
sl@0
|
816 |
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
|
sl@0
|
817 |
if (iCurrentPlayer->SubtitlesAvailable())
|
sl@0
|
818 |
{
|
sl@0
|
819 |
iCurrentPlayer->EnableSubtitlesL();
|
sl@0
|
820 |
iVideoPane->EnableSubtitle(iCurrentPlayer);
|
sl@0
|
821 |
}
|
sl@0
|
822 |
#endif
|
sl@0
|
823 |
#endif
|
sl@0
|
824 |
PlayVideo();
|
sl@0
|
825 |
}
|
sl@0
|
826 |
|
sl@0
|
827 |
// Disable video
|
sl@0
|
828 |
void CTestAppView::DisableVideo()
|
sl@0
|
829 |
{
|
sl@0
|
830 |
iVideoPane->BlackoutPane();
|
sl@0
|
831 |
PauseVideo(); // Stop playing
|
sl@0
|
832 |
|
sl@0
|
833 |
if(iCurrentPlayer)
|
sl@0
|
834 |
{
|
sl@0
|
835 |
iCurrentPlayer->RemoveDisplayWindow(TheWindow());
|
sl@0
|
836 |
iCurrentPlayer->Close();
|
sl@0
|
837 |
delete iCurrentPlayer;
|
sl@0
|
838 |
}
|
sl@0
|
839 |
iVideoPane->EnableSubtitle(NULL);
|
sl@0
|
840 |
iCurrentPlayer = NULL;
|
sl@0
|
841 |
iNativeVideoSize = TSize();
|
sl@0
|
842 |
}
|
sl@0
|
843 |
|
sl@0
|
844 |
void CTestAppView::SetRunMode (TUint32 aMode)
|
sl@0
|
845 |
{
|
sl@0
|
846 |
iRunMode = aMode;
|
sl@0
|
847 |
}
|
sl@0
|
848 |
|
sl@0
|
849 |
void CTestAppView::PlayVideo()
|
sl@0
|
850 |
{
|
sl@0
|
851 |
if(iCurrentPlayer && !iIsPlaying)
|
sl@0
|
852 |
{
|
sl@0
|
853 |
iCurrentPlayer->Play();
|
sl@0
|
854 |
iIsPlaying = ETrue;
|
sl@0
|
855 |
}
|
sl@0
|
856 |
else
|
sl@0
|
857 |
iIsPlaying = EFalse; // Can't play if there's no player
|
sl@0
|
858 |
|
sl@0
|
859 |
UpdateButtonState();
|
sl@0
|
860 |
DrawNow();
|
sl@0
|
861 |
}
|
sl@0
|
862 |
|
sl@0
|
863 |
void CTestAppView::PauseVideo()
|
sl@0
|
864 |
{
|
sl@0
|
865 |
if(iCurrentPlayer && iIsPlaying)
|
sl@0
|
866 |
{
|
sl@0
|
867 |
TRAPD(err, iCurrentPlayer->PauseL());
|
sl@0
|
868 |
if(err)
|
sl@0
|
869 |
iCurrentPlayer->Stop();
|
sl@0
|
870 |
}
|
sl@0
|
871 |
|
sl@0
|
872 |
iIsPlaying = EFalse;
|
sl@0
|
873 |
UpdateButtonState();
|
sl@0
|
874 |
DrawNow();
|
sl@0
|
875 |
}
|
sl@0
|
876 |
|
sl@0
|
877 |
void CTestAppView::StopVideo()
|
sl@0
|
878 |
{
|
sl@0
|
879 |
if(iCurrentPlayer && iIsPlaying)
|
sl@0
|
880 |
{
|
sl@0
|
881 |
iCurrentPlayer->Stop();
|
sl@0
|
882 |
iIsPlaying = EFalse;
|
sl@0
|
883 |
}
|
sl@0
|
884 |
else
|
sl@0
|
885 |
iIsPlaying = ETrue; // Can't play if there's no player
|
sl@0
|
886 |
|
sl@0
|
887 |
UpdateButtonState();
|
sl@0
|
888 |
DrawNow();
|
sl@0
|
889 |
}
|
sl@0
|
890 |
|
sl@0
|
891 |
void CTestAppView::PlayComplete(TInt /*aError*/)
|
sl@0
|
892 |
{
|
sl@0
|
893 |
iIsPlaying = EFalse;
|
sl@0
|
894 |
UpdateButtonState();
|
sl@0
|
895 |
DrawNow();
|
sl@0
|
896 |
}
|
sl@0
|
897 |
|
sl@0
|
898 |
void CTestAppView::PlayPrevious()
|
sl@0
|
899 |
{
|
sl@0
|
900 |
CTUiAndVideoAppUi* myAppUi = dynamic_cast<CTUiAndVideoAppUi *>(iCoeEnv->AppUi());
|
sl@0
|
901 |
if (myAppUi->PlayPreviousFileL() != KErrNone)
|
sl@0
|
902 |
{
|
sl@0
|
903 |
// To avoid linking with eikcore.lib
|
sl@0
|
904 |
//EikonEnv->InfoMsg(_L("First clip"));
|
sl@0
|
905 |
}
|
sl@0
|
906 |
}
|
sl@0
|
907 |
|
sl@0
|
908 |
void CTestAppView::PlayNext()
|
sl@0
|
909 |
{
|
sl@0
|
910 |
CTUiAndVideoAppUi* myAppUi = dynamic_cast<CTUiAndVideoAppUi*>(iCoeEnv->AppUi());
|
sl@0
|
911 |
if (myAppUi->PlayNextFileL() != KErrNone)
|
sl@0
|
912 |
{
|
sl@0
|
913 |
// To avoid linking with eikcore.lib
|
sl@0
|
914 |
//iEikonEnv->InfoMsg(_L("Last clip"));
|
sl@0
|
915 |
}
|
sl@0
|
916 |
}
|
sl@0
|
917 |
|
sl@0
|
918 |
void CTestAppView::UpdateButtonState()
|
sl@0
|
919 |
{
|
sl@0
|
920 |
}
|
sl@0
|
921 |
|
sl@0
|
922 |
/**
|
sl@0
|
923 |
Calculate and set the position of the video UI. If iAutoPosition is zero then this
|
sl@0
|
924 |
method is a no-op.
|
sl@0
|
925 |
*/
|
sl@0
|
926 |
void CTestAppView::SetPos(TPoint* aPos)
|
sl@0
|
927 |
{
|
sl@0
|
928 |
if (!aPos)
|
sl@0
|
929 |
{
|
sl@0
|
930 |
TRect screenRect = iCoeEnv->ScreenDevice()->SizeInPixels();
|
sl@0
|
931 |
|
sl@0
|
932 |
TSize currentSize = Size();
|
sl@0
|
933 |
TPoint currentPos = Position();
|
sl@0
|
934 |
|
sl@0
|
935 |
switch (iRunMode)
|
sl@0
|
936 |
{
|
sl@0
|
937 |
case (ETestCmdBounce):
|
sl@0
|
938 |
{
|
sl@0
|
939 |
if ((currentPos.iX + (currentSize.iWidth >> 1)) > screenRect.iBr.iX)
|
sl@0
|
940 |
iDirection.iX = -1;
|
sl@0
|
941 |
|
sl@0
|
942 |
if ((currentPos.iY + (currentSize.iHeight >> 1)) > screenRect.iBr.iY)
|
sl@0
|
943 |
iDirection.iY = -1;
|
sl@0
|
944 |
|
sl@0
|
945 |
if ((currentPos.iX + (currentSize.iWidth >> 1)) < 0)
|
sl@0
|
946 |
iDirection.iX = 1;
|
sl@0
|
947 |
|
sl@0
|
948 |
if ((currentPos.iY + (currentSize.iHeight >> 1)) < 0)
|
sl@0
|
949 |
iDirection.iY = 1;
|
sl@0
|
950 |
|
sl@0
|
951 |
iVidPos.iX += iIncrement.iX* iDirection.iX;
|
sl@0
|
952 |
iVidPos.iY += iIncrement.iY * iDirection.iY;
|
sl@0
|
953 |
break;
|
sl@0
|
954 |
}
|
sl@0
|
955 |
case (ETestCmdJump):
|
sl@0
|
956 |
{
|
sl@0
|
957 |
iVidPos.iX = Math::Random() % 100;//(screenRect.iBr.iX + (currentSize.iWidth >> 1));
|
sl@0
|
958 |
iVidPos.iY = Math::Random() % 100;//(screenRect.iBr.iY + (currentSize.iHeight >> 1));
|
sl@0
|
959 |
break;
|
sl@0
|
960 |
}
|
sl@0
|
961 |
default:
|
sl@0
|
962 |
{} // Do nothing.
|
sl@0
|
963 |
|
sl@0
|
964 |
}
|
sl@0
|
965 |
}
|
sl@0
|
966 |
else
|
sl@0
|
967 |
{
|
sl@0
|
968 |
iVidPos = *aPos;
|
sl@0
|
969 |
}
|
sl@0
|
970 |
|
sl@0
|
971 |
SetPosition(iVidPos);
|
sl@0
|
972 |
}
|
sl@0
|
973 |
|
sl@0
|
974 |
//************************************************************************************************************
|
sl@0
|
975 |
//** CVideoPane class - place 'video' window.
|
sl@0
|
976 |
//************************************************************************************************************
|
sl@0
|
977 |
|
sl@0
|
978 |
/**
|
sl@0
|
979 |
This controll is used so that the video is not rendered onto transparency.
|
sl@0
|
980 |
*/
|
sl@0
|
981 |
CVideoPane::~CVideoPane()
|
sl@0
|
982 |
{
|
sl@0
|
983 |
}
|
sl@0
|
984 |
|
sl@0
|
985 |
CVideoPane::CVideoPane()
|
sl@0
|
986 |
{
|
sl@0
|
987 |
}
|
sl@0
|
988 |
|
sl@0
|
989 |
void CVideoPane::ConstructL(CCoeControl& aParent)
|
sl@0
|
990 |
{
|
sl@0
|
991 |
CreateWindowL(&aParent);
|
sl@0
|
992 |
EnableDragEvents();
|
sl@0
|
993 |
Window().SetPointerGrab(ETrue);
|
sl@0
|
994 |
}
|
sl@0
|
995 |
|
sl@0
|
996 |
void CVideoPane::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
sl@0
|
997 |
{
|
sl@0
|
998 |
// we need to set this flag to true, which is checked in the parent to avoid loops
|
sl@0
|
999 |
iIsVideoPanePointerEvent = ETrue;
|
sl@0
|
1000 |
TRAPD(err, Parent()->HandlePointerEventL(aPointerEvent));
|
sl@0
|
1001 |
iIsVideoPanePointerEvent = EFalse;
|
sl@0
|
1002 |
User::LeaveIfError(err);
|
sl@0
|
1003 |
}
|
sl@0
|
1004 |
|
sl@0
|
1005 |
|
sl@0
|
1006 |
void CVideoPane::BlackoutPane()
|
sl@0
|
1007 |
{
|
sl@0
|
1008 |
iVideoUseRect = TRect(); // reset
|
sl@0
|
1009 |
}
|
sl@0
|
1010 |
|
sl@0
|
1011 |
void CVideoPane::SetVideoUseRect(const TRect& aRect)
|
sl@0
|
1012 |
{
|
sl@0
|
1013 |
iVideoUseRect = aRect;
|
sl@0
|
1014 |
iVideoUseRect.Move(-Position()); // Compensate for the fact that the pane is window owning
|
sl@0
|
1015 |
}
|
sl@0
|
1016 |
|
sl@0
|
1017 |
void CVideoPane::SizeChanged()
|
sl@0
|
1018 |
{
|
sl@0
|
1019 |
CCoeControl::SizeChanged();
|
sl@0
|
1020 |
iVideoUseRect = TRect(); // reset
|
sl@0
|
1021 |
}
|
sl@0
|
1022 |
|
sl@0
|
1023 |
TBool CVideoPane::IsVideoPanePointerEvent()
|
sl@0
|
1024 |
{
|
sl@0
|
1025 |
return iIsVideoPanePointerEvent;
|
sl@0
|
1026 |
}
|
sl@0
|
1027 |
|
sl@0
|
1028 |
void CVideoPane::EnableSubtitle(CVideoPlayerUtility2* aSubtitlePlayer)
|
sl@0
|
1029 |
{
|
sl@0
|
1030 |
iSubtitlePlayer = aSubtitlePlayer;
|
sl@0
|
1031 |
}
|
sl@0
|
1032 |
|
sl@0
|
1033 |
void CVideoPane::Draw(const TRect& aRect) const
|
sl@0
|
1034 |
{
|
sl@0
|
1035 |
(void)aRect; //to remove warning if SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT not defined
|
sl@0
|
1036 |
CWindowGc& gc=SystemGc();
|
sl@0
|
1037 |
#ifdef _DEBUG
|
sl@0
|
1038 |
gc.SetBrushColor(KRgbRed);
|
sl@0
|
1039 |
#else
|
sl@0
|
1040 |
gc.SetBrushColor(KRgbBlack);
|
sl@0
|
1041 |
#endif
|
sl@0
|
1042 |
DrawUtils::ClearBetweenRects(gc, Rect(), iVideoUseRect);
|
sl@0
|
1043 |
|
sl@0
|
1044 |
#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
|
sl@0
|
1045 |
if (iSubtitlePlayer)
|
sl@0
|
1046 |
iSubtitlePlayer->RedrawSubtitle(Window(), aRect);
|
sl@0
|
1047 |
#endif
|
sl@0
|
1048 |
}
|