33
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* Source file for the main class of the ConsolePlayer test app.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include "consoleplayer.h"
|
|
20 |
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <e32debug.h>
|
|
23 |
#include <f32file.h>
|
|
24 |
#include <bldvariant.hrh>
|
|
25 |
|
|
26 |
#include "MmfPlayerWindow.h"
|
|
27 |
#include "ExternalPlayer.h"
|
|
28 |
|
|
29 |
#ifdef FF_OPENMAX_AL
|
|
30 |
#include "opmaxplayerwindow.h"
|
|
31 |
#endif
|
|
32 |
|
|
33 |
const TInt KFontSize = 15;
|
|
34 |
|
|
35 |
const TInt KOrdinalPositionConfigurationCount = 7;
|
|
36 |
const TInt KPlayerCount = 5;
|
|
37 |
|
|
38 |
enum TPlayerNames
|
|
39 |
{
|
|
40 |
EVideoPlayer,
|
|
41 |
EVideoPlayer2,
|
|
42 |
EVideoPlayer3,
|
|
43 |
EExternalPlayer,
|
|
44 |
EExternalPlayer2
|
|
45 |
};
|
|
46 |
|
|
47 |
// entries are sorted with foreground windows first
|
|
48 |
const TPlayerNames KOrdinalPositions[KOrdinalPositionConfigurationCount][KPlayerCount] =
|
|
49 |
{
|
|
50 |
{EVideoPlayer3, EVideoPlayer2, EExternalPlayer, EExternalPlayer2, EVideoPlayer},
|
|
51 |
{EVideoPlayer2, EVideoPlayer3, EExternalPlayer2, EExternalPlayer, EVideoPlayer},
|
|
52 |
{EExternalPlayer, EExternalPlayer2, EVideoPlayer3, EVideoPlayer2, EVideoPlayer},
|
|
53 |
{EVideoPlayer3, EExternalPlayer2, EVideoPlayer2, EExternalPlayer, EVideoPlayer},
|
|
54 |
{EVideoPlayer3, EVideoPlayer2, EVideoPlayer, EExternalPlayer, EExternalPlayer2},
|
|
55 |
{EExternalPlayer, EExternalPlayer2, EVideoPlayer, EVideoPlayer3, EVideoPlayer2},
|
|
56 |
{EVideoPlayer, EVideoPlayer3, EVideoPlayer2, EExternalPlayer, EExternalPlayer2}
|
|
57 |
};
|
|
58 |
|
|
59 |
// Key map
|
|
60 |
// This section maps the options to keys for each page of options.
|
|
61 |
|
|
62 |
const TInt KKeyMapPageCount = 9;
|
|
63 |
|
|
64 |
const TInt KWindow2Page = 5;
|
|
65 |
const TInt KWindow3Page = 6;
|
|
66 |
const TInt KExternalPlayerPage = 7;
|
|
67 |
const TInt KExternalPlayer2Page = 8;
|
|
68 |
const TInt KAllPlayersPage = 9;
|
|
69 |
|
|
70 |
const TOperationsPage KKeyMap[KKeyMapPageCount] =
|
|
71 |
{
|
|
72 |
{STR("Standard controls"),
|
|
73 |
5, // default softkey index
|
|
74 |
{
|
|
75 |
// Enter
|
|
76 |
{STR("Pause/Resume"), EOperation_PauseResume},
|
|
77 |
// Up / Down / Left / Right
|
|
78 |
{STR("Seek back 5 seconds"), EOperation_SeekBack},
|
|
79 |
{STR("Seek forward 5 seconds"), EOperation_SeekForward},
|
|
80 |
{STR("Seek to start of clip"), EOperation_SeekStart},
|
|
81 |
{STR("Seek to end minus 5 secs"), EOperation_SeekEnd},
|
|
82 |
// 0 - 9
|
|
83 |
{STR("Help text on/off"), KOperation_ToggleHelpVisibility},
|
|
84 |
{STR("Go to next options page"), KOperation_NextOptionPage},
|
|
85 |
{STR("Stop/Play"), EOperation_StopPlay},
|
|
86 |
{STR("Obscure entire screen"), EOperation_ObscureWindow},
|
|
87 |
{STR("Toggle help transparency"), KOperation_ToggleHelpTransparency},
|
|
88 |
{STR("Change video window size"), EOperation_ChangeWindowSize},
|
|
89 |
{STR("Panic this process"), EOperation_AbnormalTermination},
|
|
90 |
{STR(""), KOperation_None},
|
|
91 |
{STR(""), KOperation_None},
|
|
92 |
{STR(""), KOperation_None},
|
|
93 |
// *, #
|
|
94 |
{STR("Change display mode"), EOperation_ChangeDisplayMode},
|
|
95 |
{STR("Exit"), KOperation_Exit}
|
|
96 |
}
|
|
97 |
},
|
|
98 |
{STR("Video controls"),
|
|
99 |
7, // default softkey index
|
|
100 |
{
|
|
101 |
// Enter
|
|
102 |
{STR("Pause/Resume"), EOperation_PauseResume},
|
|
103 |
// Up / Down / Left / Right
|
|
104 |
{STR("Increase height scale"), EOperation_IncreaseHeightScale},
|
|
105 |
{STR("Decrease height scale"), EOperation_DecreaseHeightScale},
|
|
106 |
{STR("Increase width scale"), EOperation_IncreaseWidthScale},
|
|
107 |
{STR("Decrease width scale"), EOperation_DecreaseWidthScale},
|
|
108 |
// 0 - 9
|
|
109 |
{STR("Help text on/off"), KOperation_ToggleHelpVisibility},
|
|
110 |
{STR("Go to next options page"), KOperation_NextOptionPage},
|
|
111 |
{STR("Change rotation angle"), EOperation_Rotate},
|
|
112 |
{STR("Change autoscale mode"), EOperation_Autoscale},
|
|
113 |
{STR("Change clipping rectangle"), EOperation_ClipRectangle},
|
|
114 |
{STR("Change extent rectangle"), EOperation_Extent},
|
|
115 |
{STR(""), KOperation_None},
|
|
116 |
{STR(""), KOperation_None},
|
|
117 |
{STR(""), KOperation_None},
|
|
118 |
{STR("Reset to defaults"), EOperation_ResetToDefaults},
|
|
119 |
// *, #
|
|
120 |
{STR("Change display mode"), EOperation_ChangeDisplayMode},
|
|
121 |
{STR("Exit"), KOperation_Exit}
|
|
122 |
}
|
|
123 |
},
|
|
124 |
{STR("Trick play"),
|
|
125 |
5, // default softkey index
|
|
126 |
{
|
|
127 |
// Enter
|
|
128 |
{STR("Pause/Resume"), EOperation_PauseResume},
|
|
129 |
// Up / Down / Left / Right
|
|
130 |
{STR("Frame step forward"), EOperation_FrameStepForward},
|
|
131 |
{STR("Frame step backward"), EOperation_FrameStepBackward},
|
|
132 |
{STR("Decrease play velocity"), EOperation_DecreasePlayVelocity},
|
|
133 |
{STR("Increase play velocity"), EOperation_IncreasePlayVelocity},
|
|
134 |
// 0 - 9
|
|
135 |
{STR("Help text on/off"), KOperation_ToggleHelpVisibility},
|
|
136 |
{STR("Go to next options page"), KOperation_NextOptionPage},
|
|
137 |
{STR(""), KOperation_None},
|
|
138 |
{STR(""), KOperation_None},
|
|
139 |
{STR(""), KOperation_None},
|
|
140 |
{STR(""), KOperation_None},
|
|
141 |
{STR(""), KOperation_None},
|
|
142 |
{STR(""), KOperation_None},
|
|
143 |
{STR(""), KOperation_None},
|
|
144 |
{STR("Reset to defaults"), EOperation_ResetToDefaults},
|
|
145 |
// *, #
|
|
146 |
{STR("Change display mode"), EOperation_ChangeDisplayMode},
|
|
147 |
{STR("Exit"), KOperation_Exit}
|
|
148 |
}
|
|
149 |
},
|
|
150 |
{STR("Audio controls"),
|
|
151 |
0, // default softkey index
|
|
152 |
{
|
|
153 |
// Enter
|
|
154 |
{STR("Pause/Resume"), EOperation_PauseResume},
|
|
155 |
// Up / Down / Left / Right
|
|
156 |
{STR("Increase volume 10%"), EOperation_IncreaseVolume},
|
|
157 |
{STR("Decrease volume 10%"), EOperation_DecreaseVolume},
|
|
158 |
{STR("Balance left"), EOperation_BalanceLeft},
|
|
159 |
{STR("Balance right"), EOperation_BalanceRight},
|
|
160 |
// 0 - 9
|
|
161 |
{STR("Help text on/off"), KOperation_ToggleHelpVisibility},
|
|
162 |
{STR("Go to next options page"), KOperation_NextOptionPage},
|
|
163 |
{STR("Maximum volume"), EOperation_MaximumVolume},
|
|
164 |
{STR("Mute"), EOperation_Mute},
|
|
165 |
{STR("Balance maximum left"), EOperation_BalanceMaxLeft},
|
|
166 |
{STR("Balance maximum right"), EOperation_BalanceMaxRight},
|
|
167 |
{STR(""), KOperation_None},
|
|
168 |
{STR(""), KOperation_None},
|
|
169 |
{STR(""), KOperation_None},
|
|
170 |
{STR("Reset to defaults"), EOperation_ResetToDefaults},
|
|
171 |
// *, #
|
|
172 |
{STR("Change display mode"), EOperation_ChangeDisplayMode},
|
|
173 |
{STR("Exit"), KOperation_Exit}
|
|
174 |
}
|
|
175 |
},
|
|
176 |
{STR("Video window #2 (same process)"),
|
|
177 |
7, // default softkey index
|
|
178 |
{
|
|
179 |
// Enter
|
|
180 |
{STR("Pause/Resume"), EOperation_PauseResume},
|
|
181 |
// Up / Down / Left / Right
|
|
182 |
{STR("Move window up"), EOperation_MoveWindowUp},
|
|
183 |
{STR("Move window down"), EOperation_MoveWindowDown},
|
|
184 |
{STR("Move window left"), EOperation_MoveWindowLeft},
|
|
185 |
{STR("Move window right"), EOperation_MoveWindowRight},
|
|
186 |
// 0 - 9
|
|
187 |
{STR("Help text on/off"), KOperation_ToggleHelpVisibility},
|
|
188 |
{STR("Go to next options page"), KOperation_NextOptionPage},
|
|
189 |
{STR("Toggle window on/off"), EOperation_ToggleSecondVideo},
|
|
190 |
{STR("Drag window"), EOperation_DragWindow},
|
|
191 |
{STR("Toggle window transparency"), EOperation_ToggleWindowTransparency},
|
|
192 |
{STR("Change video window size"), EOperation_ChangeWindowSize},
|
|
193 |
{STR("Change autoscale mode"), EOperation_Autoscale},
|
|
194 |
{STR(""), KOperation_None},
|
|
195 |
{STR(""), KOperation_None},
|
|
196 |
{STR("Reset to defaults"), EOperation_ResetToDefaults},
|
|
197 |
// *, #
|
|
198 |
{STR("Change display mode"), EOperation_ChangeDisplayMode},
|
|
199 |
{STR("Exit"), KOperation_Exit}
|
|
200 |
}
|
|
201 |
},
|
|
202 |
{STR("Video window #3 (same process)"),
|
|
203 |
7, // default softkey index
|
|
204 |
{
|
|
205 |
// Enter
|
|
206 |
{STR("Pause/Resume"), EOperation_PauseResume},
|
|
207 |
// Up / Down / Left / Right
|
|
208 |
{STR("Move window up"), EOperation_MoveWindowUp},
|
|
209 |
{STR("Move window down"), EOperation_MoveWindowDown},
|
|
210 |
{STR("Move window left"), EOperation_MoveWindowLeft},
|
|
211 |
{STR("Move window right"), EOperation_MoveWindowRight},
|
|
212 |
// 0 - 9
|
|
213 |
{STR("Help text on/off"), KOperation_ToggleHelpVisibility},
|
|
214 |
{STR("Go to next options page"), KOperation_NextOptionPage},
|
|
215 |
{STR("Toggle window on/off"), EOperation_ToggleThirdVideo},
|
|
216 |
{STR("Drag window"), EOperation_DragWindow},
|
|
217 |
{STR("Toggle window transparency"), EOperation_ToggleWindowTransparency},
|
|
218 |
{STR("Change video window size"), EOperation_ChangeWindowSize},
|
|
219 |
{STR("Change autoscale mode"), EOperation_Autoscale},
|
|
220 |
{STR(""), KOperation_None},
|
|
221 |
{STR(""), KOperation_None},
|
|
222 |
{STR("Reset to defaults"), EOperation_ResetToDefaults},
|
|
223 |
// *, #
|
|
224 |
{STR("Change display mode"), EOperation_ChangeDisplayMode},
|
|
225 |
{STR("Exit"), KOperation_Exit}
|
|
226 |
}
|
|
227 |
},
|
|
228 |
{STR("Video window #4 (another process)"),
|
|
229 |
7, // default softkey index
|
|
230 |
{
|
|
231 |
// Enter
|
|
232 |
{STR("Pause/Resume"), EOperation_PauseResume},
|
|
233 |
// Up / Down / Left / Right
|
|
234 |
{STR("Move window up"), EOperation_MoveWindowUp},
|
|
235 |
{STR("Move window down"), EOperation_MoveWindowDown},
|
|
236 |
{STR("Move window left"), EOperation_MoveWindowLeft},
|
|
237 |
{STR("Move window right"), EOperation_MoveWindowRight},
|
|
238 |
// 0 - 9
|
|
239 |
{STR("Help text on/off"), KOperation_ToggleHelpVisibility},
|
|
240 |
{STR("Go to next options page"), KOperation_NextOptionPage},
|
|
241 |
{STR("Toggle window on/off"), EOperation_ToggleExternalPlayer},
|
|
242 |
{STR("Drag window"), EOperation_DragWindow},
|
|
243 |
{STR("Toggle window transparency"), EOperation_ToggleWindowTransparency},
|
|
244 |
{STR("Change video window size"), EOperation_ChangeWindowSize},
|
|
245 |
{STR("Change autoscale mode"), EOperation_Autoscale},
|
|
246 |
{STR(""), KOperation_None},
|
|
247 |
{STR(""), KOperation_None},
|
|
248 |
{STR("Reset to defaults"), EOperation_ResetToDefaults},
|
|
249 |
// *, #
|
|
250 |
{STR("Change display mode"), EOperation_ChangeDisplayMode},
|
|
251 |
{STR("Exit"), KOperation_Exit}
|
|
252 |
}
|
|
253 |
},
|
|
254 |
{STR("Video window #5 (another process)"),
|
|
255 |
7, // default softkey index
|
|
256 |
{
|
|
257 |
// Enter
|
|
258 |
{STR("Pause/Resume"), EOperation_PauseResume},
|
|
259 |
// Up / Down / Left / Right
|
|
260 |
{STR("Move window up"), EOperation_MoveWindowUp},
|
|
261 |
{STR("Move window down"), EOperation_MoveWindowDown},
|
|
262 |
{STR("Move window left"), EOperation_MoveWindowLeft},
|
|
263 |
{STR("Move window right"), EOperation_MoveWindowRight},
|
|
264 |
// 0 - 9
|
|
265 |
{STR("Help text on/off"), KOperation_ToggleHelpVisibility},
|
|
266 |
{STR("Go to next options page"), KOperation_NextOptionPage},
|
|
267 |
{STR("Toggle window on/off"), EOperation_ToggleExternalPlayer2},
|
|
268 |
{STR("Drag window"), EOperation_DragWindow},
|
|
269 |
{STR("Toggle window transparency"), EOperation_ToggleWindowTransparency},
|
|
270 |
{STR("Change video window size"), EOperation_ChangeWindowSize},
|
|
271 |
{STR("Change autoscale mode"), EOperation_Autoscale},
|
|
272 |
{STR(""), KOperation_None},
|
|
273 |
{STR(""), KOperation_None},
|
|
274 |
{STR("Reset to defaults"), EOperation_ResetToDefaults},
|
|
275 |
// *, #
|
|
276 |
{STR("Change display mode"), EOperation_ChangeDisplayMode},
|
|
277 |
{STR("Exit"), KOperation_Exit}
|
|
278 |
}
|
|
279 |
},
|
|
280 |
{STR("Control all windows"),
|
|
281 |
7, // default softkey index
|
|
282 |
{
|
|
283 |
// Enter
|
|
284 |
{STR("Pause/Resume"), EOperation_PauseResume},
|
|
285 |
// Up / Down / Left / Right
|
|
286 |
{STR("Seek back 5 seconds"), EOperation_SeekBack},
|
|
287 |
{STR("Seek forward 5 seconds"), EOperation_SeekForward},
|
|
288 |
{STR("Seek to start of clip"), EOperation_SeekStart},
|
|
289 |
{STR("Seek to end minus 5 secs"), EOperation_SeekEnd},
|
|
290 |
// 0 - 9
|
|
291 |
{STR("Help text on/off"), KOperation_ToggleHelpVisibility},
|
|
292 |
{STR("Go to next options page"), KOperation_NextOptionPage},
|
|
293 |
{STR("Create all windows"), EOperation_LaunchAllWindows},
|
|
294 |
{STR("Toggle ordinal positions"), EOperation_ToggleOrdinalPositions},
|
|
295 |
{STR("Pause all"), EOperation_Pause},
|
|
296 |
{STR("Resume all"), EOperation_Resume},
|
|
297 |
{STR("Stop/Play all"), EOperation_StopPlay},
|
|
298 |
{STR(""), KOperation_None},
|
|
299 |
{STR(""), KOperation_None},
|
|
300 |
{STR("Reset to defaults"), EOperation_ResetToDefaults},
|
|
301 |
// *, #
|
|
302 |
{STR("Change display mode"), EOperation_ChangeDisplayMode},
|
|
303 |
{STR("Exit"), KOperation_Exit}
|
|
304 |
}
|
|
305 |
}
|
|
306 |
};
|
|
307 |
|
|
308 |
|
|
309 |
// Console player implementation
|
|
310 |
|
|
311 |
void CConsolePlayer::ExecuteL()
|
|
312 |
{
|
|
313 |
CConsolePlayer* self = new(ELeave) CConsolePlayer;
|
|
314 |
CleanupStack::PushL( self );
|
|
315 |
self->InitL();
|
|
316 |
self->Main();
|
|
317 |
CleanupStack::PopAndDestroy( self );
|
|
318 |
}
|
|
319 |
|
|
320 |
CConsolePlayer::CConsolePlayer() :
|
|
321 |
CTestAppBase( KFontSize ),
|
|
322 |
iLastError( KErrNone ),
|
|
323 |
iVideoWindowTextMode( 1 ),
|
|
324 |
iFinalResult( 0 )
|
|
325 |
{
|
|
326 |
}
|
|
327 |
|
|
328 |
CConsolePlayer::~CConsolePlayer()
|
|
329 |
{
|
|
330 |
Cancel();
|
|
331 |
|
|
332 |
if( iGc && iFullScreenWindow )
|
|
333 |
{
|
|
334 |
iGc->Activate(*iFullScreenWindow);
|
|
335 |
|
|
336 |
iFullScreenWindow->Invalidate();
|
|
337 |
iFullScreenWindow->BeginRedraw();
|
|
338 |
|
|
339 |
iGc->Reset();
|
|
340 |
|
|
341 |
iGc->UseFont(iFont);
|
|
342 |
iGc->SetBrushColor(KRgbDarkBlue);
|
|
343 |
|
|
344 |
iGc->Clear();
|
|
345 |
|
|
346 |
if( iFinalResult == KErrNone )
|
|
347 |
{
|
|
348 |
// KRgbWhite seems to be having problems (0xffffff) in some emulators,
|
|
349 |
// but 0xfefefe is working, so use that instead of white.
|
|
350 |
iGc->SetPenColor(0xfefefe);
|
|
351 |
}
|
|
352 |
else
|
|
353 |
{
|
|
354 |
iGc->SetPenColor(KRgbRed);
|
|
355 |
}
|
|
356 |
|
|
357 |
iBuffer.Format( _L("CONSOLEPLAYER EXIT, result = %i"), iFinalResult );
|
|
358 |
iGc->DrawText( iBuffer, TPoint(5, 20) );
|
|
359 |
|
|
360 |
iFullScreenWindow->EndRedraw();
|
|
361 |
|
|
362 |
iGc->Deactivate();
|
|
363 |
|
|
364 |
iFullScreenWindow->SetVisible( ETrue );
|
|
365 |
|
|
366 |
WaitForAnyKey();
|
|
367 |
}
|
|
368 |
|
|
369 |
delete iExternalPlayer;
|
|
370 |
delete iExternalPlayer2;
|
|
371 |
delete iVideoPlayer;
|
|
372 |
delete iVideoPlayer2;
|
|
373 |
delete iVideoPlayer3;
|
|
374 |
delete iTimerCallback;
|
|
375 |
delete iFullScreenWindow;
|
|
376 |
}
|
|
377 |
|
|
378 |
void CConsolePlayer::InitL()
|
|
379 |
{
|
|
380 |
BaseConstructL( KKeyMap, KKeyMapPageCount );
|
|
381 |
|
|
382 |
iFullScreenWindow = new(ELeave) RWindow( iWs );
|
|
383 |
User::LeaveIfError( iFullScreenWindow->Construct( *iWindowGroup, KNullWsHandle ) );
|
|
384 |
iFullScreenWindow->SetExtent( TPoint(0,0), iDisplaySize );
|
|
385 |
iFullScreenWindow->SetNonTransparent();
|
|
386 |
iFullScreenWindow->SetBackgroundColor(KRgbBlack);
|
|
387 |
iFullScreenWindow->SetVisible(false);
|
|
388 |
iFullScreenWindow->Activate();
|
|
389 |
|
|
390 |
iGc->Activate(*iFullScreenWindow);
|
|
391 |
|
|
392 |
iFullScreenWindow->BeginRedraw();
|
|
393 |
|
|
394 |
iGc->Reset();
|
|
395 |
iGc->UseFont(iFont);
|
|
396 |
iGc->SetBrushStyle(CWindowGc::ESolidBrush);
|
|
397 |
iGc->SetBrushColor(KRgbBlack);
|
|
398 |
iGc->Clear();
|
|
399 |
|
|
400 |
iFullScreenWindow->EndRedraw();
|
|
401 |
|
|
402 |
iGc->Deactivate();
|
|
403 |
}
|
|
404 |
|
|
405 |
void CConsolePlayer::Main()
|
|
406 |
{
|
|
407 |
TRAPD( err, MainL() );
|
|
408 |
|
|
409 |
RDebug::Printf( "CONSOLEPLAYER Completed, err=%i", err );
|
|
410 |
}
|
|
411 |
|
|
412 |
void CConsolePlayer::DoSelectAction( TUint aActionMask,
|
|
413 |
bool aPresentPerformanceModeOption,
|
|
414 |
TActionToPerform& aAction,
|
|
415 |
bool& aPerformanceMode )
|
|
416 |
{
|
|
417 |
RPointerArray<TDesC> operations;
|
|
418 |
|
|
419 |
TInt sameAsMainPlayerIndex = -2;
|
|
420 |
TInt playLocalFileIndex = -2;
|
|
421 |
TInt playLocalFilePerformanceIndex = -2;
|
|
422 |
TInt playUrlIndex = -2;
|
|
423 |
TInt playUrlPerformanceIndex = -2;
|
|
424 |
|
|
425 |
if( aActionMask & EAction_SameAsMainPlayer )
|
|
426 |
{
|
|
427 |
_LIT( KSameAsMainPlayer, "Same as main player" );
|
|
428 |
sameAsMainPlayerIndex = operations.Count();
|
|
429 |
operations.Append( &KSameAsMainPlayer );
|
|
430 |
}
|
|
431 |
|
|
432 |
if( aActionMask & EAction_PlayLocalFile )
|
|
433 |
{
|
|
434 |
_LIT( KPlayLocalFile, "Play local file" );
|
|
435 |
playLocalFileIndex = operations.Count();
|
|
436 |
operations.Append( &KPlayLocalFile );
|
|
437 |
|
|
438 |
if( aPresentPerformanceModeOption )
|
|
439 |
{
|
|
440 |
_LIT( KPlayLocalFilePerformance, "Play local file (performance mode)" );
|
|
441 |
playLocalFilePerformanceIndex = operations.Count();
|
|
442 |
operations.Append( &KPlayLocalFilePerformance );
|
|
443 |
}
|
|
444 |
}
|
|
445 |
|
|
446 |
if( aActionMask & EAction_PlayUrl )
|
|
447 |
{
|
|
448 |
_LIT( KPlayUrl, "Play URL from c:\\data\\urls.txt" );
|
|
449 |
playUrlIndex = operations.Count();
|
|
450 |
operations.Append( &KPlayUrl );
|
|
451 |
|
|
452 |
if( aPresentPerformanceModeOption )
|
|
453 |
{
|
|
454 |
_LIT( KPlayUrlPerformance, "Play URL from c:\\data\\urls.txt (performance mode)" );
|
|
455 |
playUrlPerformanceIndex = operations.Count();
|
|
456 |
operations.Append( &KPlayUrlPerformance );
|
|
457 |
}
|
|
458 |
}
|
|
459 |
|
|
460 |
_LIT( KExit, "Exit" );
|
|
461 |
operations.Append( &KExit );
|
|
462 |
|
|
463 |
TInt index = 0;
|
|
464 |
|
|
465 |
if( operations.Count() > 1 )
|
|
466 |
{
|
|
467 |
index = SelectFromListL( TPoint(0,0), iDisplaySize, _L("Select operation to perform:"), operations );
|
|
468 |
}
|
|
469 |
|
|
470 |
if( index == sameAsMainPlayerIndex )
|
|
471 |
{
|
|
472 |
aAction = EAction_SameAsMainPlayer;
|
|
473 |
}
|
|
474 |
else if( index == playLocalFileIndex )
|
|
475 |
{
|
|
476 |
aAction = EAction_PlayLocalFile;
|
|
477 |
aPerformanceMode = false;
|
|
478 |
}
|
|
479 |
else if( index == playLocalFilePerformanceIndex )
|
|
480 |
{
|
|
481 |
aAction = EAction_PlayLocalFile;
|
|
482 |
aPerformanceMode = true;
|
|
483 |
}
|
|
484 |
else if( index == playUrlIndex )
|
|
485 |
{
|
|
486 |
aAction = EAction_PlayUrl;
|
|
487 |
aPerformanceMode = false;
|
|
488 |
}
|
|
489 |
else if( index == playUrlPerformanceIndex )
|
|
490 |
{
|
|
491 |
aAction = EAction_PlayUrl;
|
|
492 |
aPerformanceMode = true;
|
|
493 |
}
|
|
494 |
else
|
|
495 |
{
|
|
496 |
aAction = EAction_None;
|
|
497 |
}
|
|
498 |
|
|
499 |
operations.Close();
|
|
500 |
}
|
|
501 |
|
|
502 |
bool CConsolePlayer::DoSelectApi( TUint aApiMask,
|
|
503 |
TApiToUse& aApi )
|
|
504 |
{
|
|
505 |
RPointerArray<TDesC> apiList;
|
|
506 |
|
|
507 |
TInt videoPlayerIndex = -2;
|
|
508 |
TInt omxAlIndex = -2;
|
|
509 |
|
|
510 |
if( aApiMask & EApi_VideoPlayer )
|
|
511 |
{
|
|
512 |
_LIT( KVideoPlayer, "Video player" );
|
|
513 |
videoPlayerIndex = apiList.Count();
|
|
514 |
apiList.Append( &KVideoPlayer );
|
|
515 |
}
|
|
516 |
|
|
517 |
if( aApiMask & EApi_OpenMaxAl )
|
|
518 |
{
|
|
519 |
_LIT( KOmxAl, "OpenMAX AL" );
|
|
520 |
omxAlIndex = apiList.Count();
|
|
521 |
apiList.Append( &KOmxAl );
|
|
522 |
}
|
|
523 |
|
|
524 |
TInt index = 0;
|
|
525 |
|
|
526 |
if( apiList.Count() > 1 )
|
|
527 |
{
|
|
528 |
index = SelectFromListL( TPoint(0,0), iDisplaySize, _L("Select API to use:"), apiList );
|
|
529 |
}
|
|
530 |
|
|
531 |
bool selected = true;
|
|
532 |
|
|
533 |
if( index == videoPlayerIndex )
|
|
534 |
{
|
|
535 |
aApi = EApi_VideoPlayer;
|
|
536 |
}
|
|
537 |
else if( index == omxAlIndex )
|
|
538 |
{
|
|
539 |
aApi = EApi_OpenMaxAl;
|
|
540 |
}
|
|
541 |
else
|
|
542 |
{
|
|
543 |
selected = false;
|
|
544 |
}
|
|
545 |
|
|
546 |
apiList.Close();
|
|
547 |
|
|
548 |
return selected;
|
|
549 |
}
|
|
550 |
|
|
551 |
void CConsolePlayer::SelectAction( TUint aActionMask,
|
|
552 |
TUint aApiMask,
|
|
553 |
bool aPresentPerformanceModeOption,
|
|
554 |
TActionToPerform& aAction,
|
|
555 |
TApiToUse& aApi,
|
|
556 |
bool& aPerformanceMode,
|
|
557 |
TFileName& aLocation )
|
|
558 |
{
|
|
559 |
bool done = false;
|
|
560 |
|
|
561 |
while( !done )
|
|
562 |
{
|
|
563 |
DoSelectAction( aActionMask, aPresentPerformanceModeOption, aAction, aPerformanceMode );
|
|
564 |
|
|
565 |
switch( aAction )
|
|
566 |
{
|
|
567 |
case EAction_None:
|
|
568 |
case EAction_SameAsMainPlayer:
|
|
569 |
|
|
570 |
done = true;
|
|
571 |
break;
|
|
572 |
|
|
573 |
case EAction_PlayLocalFile:
|
|
574 |
|
|
575 |
while( !done && DoSelectApi( aApiMask, aApi ) )
|
|
576 |
{
|
|
577 |
done = SelectFileWithHistoryL( TPoint(0,0), iDisplaySize, aLocation, KHistoryFilename, KMaxHistoryEntries );
|
|
578 |
}
|
|
579 |
break;
|
|
580 |
|
|
581 |
case EAction_PlayUrl:
|
|
582 |
|
|
583 |
while( !done && DoSelectApi( aApiMask, aApi ) )
|
|
584 |
{
|
|
585 |
done = SelectUrlL( aLocation );
|
|
586 |
}
|
|
587 |
break;
|
|
588 |
}
|
|
589 |
}
|
|
590 |
}
|
|
591 |
|
|
592 |
void CConsolePlayer::MainL()
|
|
593 |
{
|
|
594 |
bool performanceMode;
|
|
595 |
TFileName location;
|
|
596 |
|
|
597 |
TUint actionMask = (EAction_PlayLocalFile | EAction_PlayUrl);
|
|
598 |
|
|
599 |
TUint apiMask = EApi_VideoPlayer;
|
|
600 |
|
|
601 |
#ifdef FF_OPENMAX_AL
|
|
602 |
apiMask |= EApi_OpenMaxAl;
|
|
603 |
#endif
|
|
604 |
|
|
605 |
bool done = false;
|
|
606 |
|
|
607 |
while( !done )
|
|
608 |
{
|
|
609 |
SelectAction( actionMask, apiMask, true, iMainPlayerAction, iMainPlayerApi, performanceMode, location );
|
|
610 |
|
|
611 |
switch( iMainPlayerAction )
|
|
612 |
{
|
|
613 |
case EAction_None:
|
|
614 |
|
|
615 |
// Do nothing. Exit program.
|
|
616 |
done = true;
|
|
617 |
break;
|
|
618 |
|
|
619 |
case EAction_PlayLocalFile:
|
|
620 |
case EAction_PlayUrl:
|
|
621 |
{
|
|
622 |
CPlayerWindow::TAutoscaleMode autoscale = CPlayerWindow::EDoNotAutoscale;
|
|
623 |
|
|
624 |
if( performanceMode )
|
|
625 |
{
|
|
626 |
// turn off text
|
|
627 |
iVideoWindowTextMode = 0;
|
|
628 |
|
|
629 |
// stretch video to full window
|
|
630 |
autoscale = CPlayerWindow::EStretch;
|
|
631 |
|
|
632 |
// do not use timer in performance mode
|
|
633 |
}
|
|
634 |
else
|
|
635 |
{
|
|
636 |
iTimerCallback = new(ELeave) CTimerCallback( *this );
|
|
637 |
}
|
|
638 |
|
|
639 |
// The first video player window is full screen.
|
|
640 |
iVideoPlayer = PlayerWindowNewL( iMainPlayerApi,
|
|
641 |
TPoint(0,0),
|
|
642 |
iDisplaySize,
|
|
643 |
false, // not transparent
|
|
644 |
KRgbDarkBlue,
|
|
645 |
true );
|
|
646 |
|
|
647 |
iActivePlayer = iVideoPlayer;
|
|
648 |
|
|
649 |
if( iMainPlayerAction == EAction_PlayLocalFile )
|
|
650 |
{
|
|
651 |
// RDebug::Printf only supports 8-bit strings, but RawPrint can handle 16-bit descriptors.
|
|
652 |
RDebug::Printf( "CONSOLEPLAYER file:" );
|
|
653 |
RDebug::RawPrint( location );
|
|
654 |
|
|
655 |
iVideoPlayer->StartWithFilenameL(location, autoscale, this);
|
|
656 |
}
|
|
657 |
else
|
|
658 |
{
|
|
659 |
// RDebug::Printf only supports 8-bit strings, but RawPrint can handle 16-bit descriptors.
|
|
660 |
RDebug::Printf( "CONSOLEPLAYER URL:" );
|
|
661 |
RDebug::RawPrint( location );
|
|
662 |
|
|
663 |
iVideoPlayer->StartWithUrlL(location, autoscale, this);
|
|
664 |
}
|
|
665 |
|
|
666 |
done = true;
|
|
667 |
CActiveScheduler::Start();
|
|
668 |
}
|
|
669 |
break;
|
|
670 |
|
|
671 |
}
|
|
672 |
}
|
|
673 |
}
|
|
674 |
|
|
675 |
bool CConsolePlayer::SelectUrlL( TDes& aUrl )
|
|
676 |
{
|
|
677 |
RPointerArray<HBufC> urlList;
|
|
678 |
TInt err = ReadFile( KUrlListFilename, urlList );
|
|
679 |
|
|
680 |
bool selected = false;
|
|
681 |
|
|
682 |
if( err == KErrNone )
|
|
683 |
{
|
|
684 |
TInt index = SelectFromListL( TPoint(0,0), iDisplaySize, _L("Select URL:"), urlList );
|
|
685 |
|
|
686 |
if( index >= 0 )
|
|
687 |
{
|
|
688 |
selected = true;
|
|
689 |
aUrl.Copy( urlList[index]->Des() );
|
|
690 |
}
|
|
691 |
}
|
|
692 |
|
|
693 |
urlList.ResetAndDestroy();
|
|
694 |
|
|
695 |
return selected;
|
|
696 |
}
|
|
697 |
|
|
698 |
MPlayerCommands* CConsolePlayer::CurrentPlayer()
|
|
699 |
{
|
|
700 |
MPlayerCommands* player = NULL;
|
|
701 |
|
|
702 |
switch( CurrentPageNumber() )
|
|
703 |
{
|
|
704 |
case KWindow2Page:
|
|
705 |
player = iVideoPlayer2;
|
|
706 |
break;
|
|
707 |
case KWindow3Page:
|
|
708 |
player = iVideoPlayer3;
|
|
709 |
break;
|
|
710 |
case KExternalPlayerPage:
|
|
711 |
player = iExternalPlayer;
|
|
712 |
break;
|
|
713 |
case KExternalPlayer2Page:
|
|
714 |
player = iExternalPlayer2;
|
|
715 |
break;
|
|
716 |
case KAllPlayersPage:
|
|
717 |
player = this; // means to route command to all players
|
|
718 |
break;
|
|
719 |
default:
|
|
720 |
// By default, route other commands to the main player.
|
|
721 |
player = iVideoPlayer;
|
|
722 |
break;
|
|
723 |
}
|
|
724 |
|
|
725 |
return player;
|
|
726 |
}
|
|
727 |
|
|
728 |
void CConsolePlayer::SoftkeyFunctionUpdated()
|
|
729 |
{
|
|
730 |
MPlayerCommands* currentPlayer = CurrentPlayer();
|
|
731 |
|
|
732 |
if( currentPlayer != iActivePlayer )
|
|
733 |
{
|
|
734 |
if( iActivePlayer != NULL )
|
|
735 |
{
|
|
736 |
iActivePlayer->ExecuteOperation( EOperation_ClearBorderAroundWindow );
|
|
737 |
}
|
|
738 |
|
|
739 |
iActivePlayer = currentPlayer;
|
|
740 |
|
|
741 |
DrawBorderAroundActiveWindows();
|
|
742 |
}
|
|
743 |
|
|
744 |
UpdateVideoWindow();
|
|
745 |
}
|
|
746 |
|
|
747 |
void CConsolePlayer::DrawBorderAroundActiveWindows()
|
|
748 |
{
|
|
749 |
if( (iActivePlayer != NULL) && (iActivePlayer != iVideoPlayer) )
|
|
750 |
{
|
|
751 |
iActivePlayer->ExecuteOperation( EOperation_DrawWhiteBorderAroundWindow );
|
|
752 |
}
|
|
753 |
}
|
|
754 |
|
|
755 |
bool CConsolePlayer::ConsumeKeyEvent( TInt /*aKeyCode*/ )
|
|
756 |
{
|
|
757 |
return false;
|
|
758 |
}
|
|
759 |
|
|
760 |
void CConsolePlayer::UpdateVideoWindow()
|
|
761 |
{
|
|
762 |
iGc->Activate(iVideoPlayer->Window());
|
|
763 |
|
|
764 |
iVideoPlayer->Window().Invalidate();
|
|
765 |
iVideoPlayer->Window().BeginRedraw();
|
|
766 |
|
|
767 |
iGc->Reset();
|
|
768 |
iGc->SetBrushColor(KRgbTransparent);
|
|
769 |
iGc->Clear();
|
|
770 |
|
|
771 |
iGc->SetPenColor(KRgbCyan);
|
|
772 |
|
|
773 |
if( iVideoWindowTextMode > 0 )
|
|
774 |
{
|
|
775 |
iGc->UseFont(iFont);
|
|
776 |
|
|
777 |
if( iSelectedOptionText.Length() > 0 )
|
|
778 |
{
|
|
779 |
// POPUP WINDOW (AFTER OPTION IS SELECTED)
|
|
780 |
|
|
781 |
iGc->SetBrushStyle(CWindowGc::ESolidBrush);
|
|
782 |
iGc->SetBrushColor(KRgbBlue);
|
|
783 |
|
|
784 |
const TInt KSelectionWindowWidth = iFont->TextWidthInPixels(iSelectedOptionText)+10;
|
|
785 |
const TInt KSelectionWindowHeight = KFontSize+10;
|
|
786 |
const TInt KOffsetFromBottom = 20;
|
|
787 |
|
|
788 |
TRect box(iDisplaySize.iWidth/2-KSelectionWindowWidth/2,
|
|
789 |
iDisplaySize.iHeight-KOffsetFromBottom-KSelectionWindowHeight,
|
|
790 |
iDisplaySize.iWidth/2+KSelectionWindowWidth/2,
|
|
791 |
iDisplaySize.iHeight-KOffsetFromBottom);
|
|
792 |
iGc->DrawText( iSelectedOptionText, box, KFontSize+2, CWindowGc::ECenter);
|
|
793 |
|
|
794 |
iGc->SetBrushStyle(CWindowGc::ENullBrush);
|
|
795 |
iGc->SetBrushColor(KRgbTransparent);
|
|
796 |
}
|
|
797 |
|
|
798 |
// BASIC TEXT
|
|
799 |
|
|
800 |
TInt posInSec = iVideoPlayer->PositionInMs() / 1000;
|
|
801 |
|
|
802 |
TInt durationInSec = iVideoPlayer->DurationInMs() / 1000;
|
|
803 |
|
|
804 |
const TInt KColumn = 3;
|
|
805 |
const TInt KRowIncrement = KFontSize + 1;
|
|
806 |
TInt row = KRowIncrement;
|
|
807 |
|
|
808 |
iBuffer.Format( _L("Options page %i: "), CurrentPageNumber() );
|
|
809 |
iBuffer.Append( CurrentPageName() );
|
|
810 |
iGc->DrawText( iBuffer, TPoint(KColumn, row) );
|
|
811 |
row += KRowIncrement;
|
|
812 |
|
|
813 |
iBuffer.Copy( _L("Softkey: ") );
|
|
814 |
iBuffer.Append( CurrentSoftkeyName() );
|
|
815 |
iGc->DrawText( iBuffer, TPoint(KColumn, row) );
|
|
816 |
row += KRowIncrement;
|
|
817 |
|
|
818 |
iBuffer.Format( _L("Position: %i/%i secs "), posInSec, durationInSec );
|
|
819 |
switch( iVideoPlayer->PlayState() )
|
|
820 |
{
|
|
821 |
case CPlayerWindow::EPlaying:
|
|
822 |
iBuffer.Append( _L("<playing>") );
|
|
823 |
break;
|
|
824 |
case CPlayerWindow::EPaused:
|
|
825 |
iBuffer.Append( _L("<paused>") );
|
|
826 |
break;
|
|
827 |
case CPlayerWindow::EStopped:
|
|
828 |
iBuffer.Append( _L("<stopped>") );
|
|
829 |
break;
|
|
830 |
}
|
|
831 |
iGc->DrawText( iBuffer, TPoint(KColumn, row) );
|
|
832 |
row += KRowIncrement;
|
|
833 |
|
|
834 |
if( iLastError != KErrNone )
|
|
835 |
{
|
|
836 |
iGc->SetPenColor(KRgbRed);
|
|
837 |
}
|
|
838 |
|
|
839 |
iBuffer.Format ( _L("Last error: %i"), iLastError );
|
|
840 |
iGc->DrawText( iBuffer, TPoint(KColumn, row) );
|
|
841 |
row += KRowIncrement;
|
|
842 |
|
|
843 |
iGc->SetPenColor(KRgbCyan);
|
|
844 |
|
|
845 |
RDebug::Printf( "CONSOLEPLAYER position=%i", posInSec );
|
|
846 |
|
|
847 |
|
|
848 |
if( iVideoWindowTextMode > 1 )
|
|
849 |
{
|
|
850 |
// ADVANCED TEXT
|
|
851 |
|
|
852 |
// skip a row
|
|
853 |
row += KRowIncrement;
|
|
854 |
|
|
855 |
iGc->DrawText( iVideoPlayer->Filename(), TPoint(KColumn, row) );
|
|
856 |
row += KRowIncrement;
|
|
857 |
|
|
858 |
iBuffer.Format( _L("Display size: %ix%i"), iDisplaySize.iWidth, iDisplaySize.iHeight );
|
|
859 |
iGc->DrawText( iBuffer, TPoint(KColumn, row) );
|
|
860 |
row += KRowIncrement;
|
|
861 |
|
|
862 |
iBuffer.Format( _L("Video size: %ix%i"), iVideoPlayer->VideoSize().iWidth, iVideoPlayer->VideoSize().iHeight );
|
|
863 |
iGc->DrawText( iBuffer, TPoint(KColumn, row) );
|
|
864 |
row += KRowIncrement;
|
|
865 |
|
|
866 |
iVideoPlayer->WriteAdvancedText( *iGc, KColumn, row, KRowIncrement );
|
|
867 |
}
|
|
868 |
}
|
|
869 |
|
|
870 |
iVideoPlayer->Window().EndRedraw();
|
|
871 |
|
|
872 |
iGc->Deactivate();
|
|
873 |
|
|
874 |
iWs.Flush();
|
|
875 |
}
|
|
876 |
|
|
877 |
void CConsolePlayer::UpdateWindowOrdinalPositions()
|
|
878 |
{
|
|
879 |
TInt nextOrdinal = 0;
|
|
880 |
|
|
881 |
iSelectionWindow->SetOrdinalPosition( nextOrdinal );
|
|
882 |
nextOrdinal++;
|
|
883 |
|
|
884 |
iHelpWindow->SetOrdinalPosition( nextOrdinal );
|
|
885 |
nextOrdinal++;
|
|
886 |
|
|
887 |
iFullScreenWindow->SetOrdinalPosition( nextOrdinal );
|
|
888 |
nextOrdinal++;
|
|
889 |
|
|
890 |
for( TInt playerIndex = 0; playerIndex < KPlayerCount; playerIndex++ )
|
|
891 |
{
|
|
892 |
MPlayerCommands* player = NULL;
|
|
893 |
|
|
894 |
switch( KOrdinalPositions[iOrdinalIndex][playerIndex] )
|
|
895 |
{
|
|
896 |
case EVideoPlayer:
|
|
897 |
player = iVideoPlayer;
|
|
898 |
break;
|
|
899 |
case EVideoPlayer2:
|
|
900 |
player = iVideoPlayer2;
|
|
901 |
break;
|
|
902 |
case EVideoPlayer3:
|
|
903 |
player = iVideoPlayer3;
|
|
904 |
break;
|
|
905 |
case EExternalPlayer:
|
|
906 |
player = iExternalPlayer;
|
|
907 |
break;
|
|
908 |
case EExternalPlayer2:
|
|
909 |
player = iExternalPlayer2;
|
|
910 |
break;
|
|
911 |
}
|
|
912 |
|
|
913 |
if( player )
|
|
914 |
{
|
|
915 |
player->SetOrdinalPosition( nextOrdinal );
|
|
916 |
nextOrdinal++;
|
|
917 |
}
|
|
918 |
}
|
|
919 |
}
|
|
920 |
|
|
921 |
CPlayerWindow* CConsolePlayer::PlayerWindowNewL( TApiToUse aApi,
|
|
922 |
TPoint aTopLeft,
|
|
923 |
TSize aSize,
|
|
924 |
bool aTransparent,
|
|
925 |
TRgb aBackgroundColor,
|
|
926 |
bool aSuppressGraphicsContext )
|
|
927 |
{
|
|
928 |
CPlayerWindow* player = NULL;
|
|
929 |
|
|
930 |
switch( aApi )
|
|
931 |
{
|
|
932 |
case EApi_VideoPlayer:
|
|
933 |
|
|
934 |
player = CMmfPlayerWindow::NewL( iFs,
|
|
935 |
iWs,
|
|
936 |
*iScreenDevice,
|
|
937 |
*iWindowGroup,
|
|
938 |
aTopLeft,
|
|
939 |
aSize,
|
|
940 |
aTransparent,
|
|
941 |
aBackgroundColor,
|
|
942 |
aSuppressGraphicsContext );
|
|
943 |
break;
|
|
944 |
|
|
945 |
case EApi_OpenMaxAl:
|
|
946 |
#ifdef FF_OPENMAX_AL
|
|
947 |
|
|
948 |
player = COpMaxPlayerWindow::NewL( iFs,
|
|
949 |
iWs,
|
|
950 |
*iScreenDevice,
|
|
951 |
*iWindowGroup,
|
|
952 |
aTopLeft,
|
|
953 |
aSize,
|
|
954 |
aTransparent,
|
|
955 |
aBackgroundColor,
|
|
956 |
aSuppressGraphicsContext);
|
|
957 |
#endif
|
|
958 |
break;
|
|
959 |
}
|
|
960 |
|
|
961 |
return player;
|
|
962 |
}
|
|
963 |
|
|
964 |
void CConsolePlayer::EnableDragging()
|
|
965 |
{
|
|
966 |
iPlayerBeingDragged = CurrentPlayer();
|
|
967 |
|
|
968 |
if( iPlayerBeingDragged )
|
|
969 |
{
|
|
970 |
iPlayerBeingDragged->ExecuteOperation( EOperation_DrawRedBorderAroundWindow );
|
|
971 |
StartReceivingPointerEvents();
|
|
972 |
}
|
|
973 |
}
|
|
974 |
|
|
975 |
void CConsolePlayer::DisableDragging()
|
|
976 |
{
|
|
977 |
if( iPlayerBeingDragged )
|
|
978 |
{
|
|
979 |
// Stop routing pointer events to app.
|
|
980 |
StopReceivingPointerEvents();
|
|
981 |
|
|
982 |
if( iPlayerBeingDragged == CurrentPlayer() )
|
|
983 |
{
|
|
984 |
iPlayerBeingDragged->ExecuteOperation( EOperation_DrawWhiteBorderAroundWindow );
|
|
985 |
}
|
|
986 |
else
|
|
987 |
{
|
|
988 |
iPlayerBeingDragged->ExecuteOperation( EOperation_ClearBorderAroundWindow );
|
|
989 |
}
|
|
990 |
|
|
991 |
iPlayerBeingDragged = NULL;
|
|
992 |
}
|
|
993 |
}
|
|
994 |
|
|
995 |
TInt CConsolePlayer::CreateAnotherPlayer( CPlayerWindow** aPlayerWindow,
|
|
996 |
CExternalPlayer** aExternalPlayer,
|
|
997 |
const TDesC& aExternalPlayerExeName,
|
|
998 |
TSize aSize,
|
|
999 |
TPoint aTopLeft )
|
|
1000 |
{
|
|
1001 |
TInt err = KErrNone;
|
|
1002 |
|
|
1003 |
bool resumePlayer1 = false;
|
|
1004 |
bool resumePlayer2 = false;
|
|
1005 |
bool resumePlayer3 = false;
|
|
1006 |
bool resumeExternalPlayer1 = false;
|
|
1007 |
bool resumeExternalPlayer2 = false;
|
|
1008 |
|
|
1009 |
if( iVideoPlayer->PlayState() == CPlayerWindow::EPlaying )
|
|
1010 |
{
|
|
1011 |
iVideoPlayer->Pause();
|
|
1012 |
resumePlayer1 = true;
|
|
1013 |
}
|
|
1014 |
|
|
1015 |
if( iVideoPlayer2 && iVideoPlayer2->PlayState() == CPlayerWindow::EPlaying )
|
|
1016 |
{
|
|
1017 |
iVideoPlayer2->Pause();
|
|
1018 |
resumePlayer2 = true;
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
if( iVideoPlayer3 && iVideoPlayer3->PlayState() == CPlayerWindow::EPlaying )
|
|
1022 |
{
|
|
1023 |
iVideoPlayer3->Pause();
|
|
1024 |
resumePlayer3 = true;
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
if( iExternalPlayer )
|
|
1028 |
{
|
|
1029 |
iExternalPlayer->ExecuteOperation( EOperation_Pause );
|
|
1030 |
resumeExternalPlayer1 = true;
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
if( iExternalPlayer2 )
|
|
1034 |
{
|
|
1035 |
iExternalPlayer2->ExecuteOperation( EOperation_Pause );
|
|
1036 |
resumeExternalPlayer2 = true;
|
|
1037 |
}
|
|
1038 |
|
|
1039 |
TActionToPerform action;
|
|
1040 |
TApiToUse api;
|
|
1041 |
bool dummy;
|
|
1042 |
TFileName location;
|
|
1043 |
|
|
1044 |
TUint actionMask = (EAction_PlayLocalFile | EAction_PlayUrl | EAction_SameAsMainPlayer );
|
|
1045 |
|
|
1046 |
TUint apiMask = EApi_VideoPlayer;
|
|
1047 |
|
|
1048 |
SelectAction( actionMask, apiMask, false, action, api, dummy, location );
|
|
1049 |
|
|
1050 |
if( action == EAction_SameAsMainPlayer )
|
|
1051 |
{
|
|
1052 |
action = iMainPlayerAction;
|
|
1053 |
api = iMainPlayerApi;
|
|
1054 |
|
|
1055 |
if( action == EAction_PlayLocalFile )
|
|
1056 |
{
|
|
1057 |
location = iVideoPlayer->FullFilename();
|
|
1058 |
}
|
|
1059 |
else
|
|
1060 |
{
|
|
1061 |
location = iVideoPlayer->Url();
|
|
1062 |
}
|
|
1063 |
}
|
|
1064 |
|
|
1065 |
if( location.Length() > 0 )
|
|
1066 |
{
|
|
1067 |
if( aPlayerWindow != NULL )
|
|
1068 |
{
|
|
1069 |
// Create player as another window within this process.
|
|
1070 |
TRAP( err, (*aPlayerWindow) = PlayerWindowNewL( api,
|
|
1071 |
aTopLeft,
|
|
1072 |
aSize,
|
|
1073 |
true, // transparent
|
|
1074 |
KRgbTransparent,
|
|
1075 |
false ) );
|
|
1076 |
if( (*aPlayerWindow ) != NULL )
|
|
1077 |
{
|
|
1078 |
if( action == EAction_PlayLocalFile )
|
|
1079 |
{
|
|
1080 |
TRAP( err, (*aPlayerWindow)->StartWithFilenameL( location, CPlayerWindow::EBestFit) );
|
|
1081 |
}
|
|
1082 |
else
|
|
1083 |
{
|
|
1084 |
TRAP( err, (*aPlayerWindow)->StartWithUrlL( location, CPlayerWindow::EBestFit) );
|
|
1085 |
}
|
|
1086 |
|
|
1087 |
if( err != KErrNone )
|
|
1088 |
{
|
|
1089 |
delete (*aPlayerWindow);
|
|
1090 |
aPlayerWindow = NULL;
|
|
1091 |
}
|
|
1092 |
}
|
|
1093 |
}
|
|
1094 |
else
|
|
1095 |
{
|
|
1096 |
// Launch player within another process.
|
|
1097 |
(*aExternalPlayer) = new CExternalPlayer( iWs );
|
|
1098 |
|
|
1099 |
if( (*aExternalPlayer) == NULL )
|
|
1100 |
{
|
|
1101 |
err = KErrNoMemory;
|
|
1102 |
}
|
|
1103 |
else if( action == EAction_PlayLocalFile )
|
|
1104 |
{
|
|
1105 |
err = (*aExternalPlayer)->Launch( aExternalPlayerExeName,
|
|
1106 |
*iWindowGroup,
|
|
1107 |
location,
|
|
1108 |
true,
|
|
1109 |
aTopLeft,
|
|
1110 |
aSize );
|
|
1111 |
}
|
|
1112 |
else
|
|
1113 |
{
|
|
1114 |
err = (*aExternalPlayer)->Launch( aExternalPlayerExeName,
|
|
1115 |
*iWindowGroup,
|
|
1116 |
location,
|
|
1117 |
false,
|
|
1118 |
aTopLeft,
|
|
1119 |
aSize );
|
|
1120 |
}
|
|
1121 |
}
|
|
1122 |
|
|
1123 |
UpdateWindowOrdinalPositions();
|
|
1124 |
}
|
|
1125 |
|
|
1126 |
if( resumePlayer1 )
|
|
1127 |
{
|
|
1128 |
iVideoPlayer->Play();
|
|
1129 |
}
|
|
1130 |
|
|
1131 |
if( resumePlayer2 )
|
|
1132 |
{
|
|
1133 |
iVideoPlayer2->Play();
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
if( resumePlayer3 )
|
|
1137 |
{
|
|
1138 |
iVideoPlayer3->Play();
|
|
1139 |
}
|
|
1140 |
|
|
1141 |
if( resumeExternalPlayer1 )
|
|
1142 |
{
|
|
1143 |
iExternalPlayer->ExecuteOperation( EOperation_Resume );
|
|
1144 |
}
|
|
1145 |
|
|
1146 |
if( resumeExternalPlayer2 )
|
|
1147 |
{
|
|
1148 |
iExternalPlayer2->ExecuteOperation( EOperation_Resume );
|
|
1149 |
}
|
|
1150 |
|
|
1151 |
return err;
|
|
1152 |
}
|
|
1153 |
|
|
1154 |
TInt CConsolePlayer::ExecuteOperation( TInt aOperation )
|
|
1155 |
{
|
|
1156 |
SendOperationToAllPlayers( aOperation );
|
|
1157 |
return KErrNone;
|
|
1158 |
}
|
|
1159 |
|
|
1160 |
void CConsolePlayer::MoveWindow( TPoint /*aNewCenter*/ )
|
|
1161 |
{
|
|
1162 |
// Not used.
|
|
1163 |
}
|
|
1164 |
|
|
1165 |
void CConsolePlayer::SetOrdinalPosition( TInt /*aPosition*/ )
|
|
1166 |
{
|
|
1167 |
// Not used.
|
|
1168 |
}
|
|
1169 |
|
|
1170 |
void CConsolePlayer::SendOperationToAllPlayers( TInt aOperation )
|
|
1171 |
{
|
|
1172 |
iVideoPlayer->ExecuteOperation(aOperation);
|
|
1173 |
if( iVideoPlayer2 )
|
|
1174 |
{
|
|
1175 |
iVideoPlayer2->ExecuteOperation(aOperation);
|
|
1176 |
}
|
|
1177 |
if( iVideoPlayer3 )
|
|
1178 |
{
|
|
1179 |
iVideoPlayer3->ExecuteOperation(aOperation);
|
|
1180 |
}
|
|
1181 |
if( iExternalPlayer )
|
|
1182 |
{
|
|
1183 |
iExternalPlayer->ExecuteOperation(aOperation);
|
|
1184 |
}
|
|
1185 |
if( iExternalPlayer2 )
|
|
1186 |
{
|
|
1187 |
iExternalPlayer2->ExecuteOperation(aOperation);
|
|
1188 |
}
|
|
1189 |
}
|
|
1190 |
|
|
1191 |
void CConsolePlayer::ExecuteOperation( TInt aOperation, const TDesC& aOperationText )
|
|
1192 |
{
|
|
1193 |
iSelectedOptionText.Copy( aOperationText );
|
|
1194 |
iSelectedOptionTextCounter = 2;
|
|
1195 |
|
|
1196 |
RDebug::Printf( "CONSOLE PLAYER executing operation:" );
|
|
1197 |
RDebug::RawPrint( iSelectedOptionText );
|
|
1198 |
|
|
1199 |
if( iPlayerBeingDragged != NULL )
|
|
1200 |
{
|
|
1201 |
DisableDragging();
|
|
1202 |
}
|
|
1203 |
|
|
1204 |
iLastError = KErrNone;
|
|
1205 |
|
|
1206 |
switch( aOperation )
|
|
1207 |
{
|
|
1208 |
case EOperation_ChangeDisplayMode:
|
|
1209 |
{
|
|
1210 |
// Change video window text mode.
|
|
1211 |
iVideoWindowTextMode = (iVideoWindowTextMode+1) % 3;
|
|
1212 |
break;
|
|
1213 |
}
|
|
1214 |
case EOperation_ToggleSecondVideo:
|
|
1215 |
{
|
|
1216 |
if( iVideoPlayer2 )
|
|
1217 |
{
|
|
1218 |
delete iVideoPlayer2;
|
|
1219 |
iVideoPlayer2 = NULL;
|
|
1220 |
iActivePlayer = NULL;
|
|
1221 |
}
|
|
1222 |
else
|
|
1223 |
{
|
|
1224 |
iLastError = CreateAnotherPlayer(&iVideoPlayer2,
|
|
1225 |
NULL,
|
|
1226 |
KNullDesC,
|
|
1227 |
TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2),
|
|
1228 |
TPoint(0,iDisplaySize.iHeight/2));
|
|
1229 |
|
|
1230 |
iActivePlayer = iVideoPlayer2;
|
|
1231 |
EnableDragging();
|
|
1232 |
}
|
|
1233 |
break;
|
|
1234 |
}
|
|
1235 |
case EOperation_ToggleThirdVideo:
|
|
1236 |
{
|
|
1237 |
if( iVideoPlayer3 )
|
|
1238 |
{
|
|
1239 |
delete iVideoPlayer3;
|
|
1240 |
iVideoPlayer3 = NULL;
|
|
1241 |
iActivePlayer = NULL;
|
|
1242 |
}
|
|
1243 |
else
|
|
1244 |
{
|
|
1245 |
iLastError = CreateAnotherPlayer(&iVideoPlayer3,
|
|
1246 |
NULL,
|
|
1247 |
KNullDesC,
|
|
1248 |
TSize(iDisplaySize.iWidth/3,iDisplaySize.iHeight/3),
|
|
1249 |
TPoint(0,2*iDisplaySize.iHeight/3));
|
|
1250 |
|
|
1251 |
iActivePlayer = iVideoPlayer3;
|
|
1252 |
EnableDragging();
|
|
1253 |
}
|
|
1254 |
break;
|
|
1255 |
}
|
|
1256 |
case EOperation_DragWindow:
|
|
1257 |
{
|
|
1258 |
EnableDragging();
|
|
1259 |
iSelectedOptionTextCounter = 1000;
|
|
1260 |
break;
|
|
1261 |
}
|
|
1262 |
case EOperation_ToggleOrdinalPositions:
|
|
1263 |
{
|
|
1264 |
iOrdinalIndex = (iOrdinalIndex+1) % KOrdinalPositionConfigurationCount;
|
|
1265 |
UpdateWindowOrdinalPositions();
|
|
1266 |
|
|
1267 |
iSelectedOptionTextCounter = 6;
|
|
1268 |
iSelectedOptionText.Format(_L("Ordinals: %i %i %i %i %i"),
|
|
1269 |
KOrdinalPositions[iOrdinalIndex][0] + 1,
|
|
1270 |
KOrdinalPositions[iOrdinalIndex][1] + 1,
|
|
1271 |
KOrdinalPositions[iOrdinalIndex][2] + 1,
|
|
1272 |
KOrdinalPositions[iOrdinalIndex][3] + 1,
|
|
1273 |
KOrdinalPositions[iOrdinalIndex][4] + 1 );
|
|
1274 |
break;
|
|
1275 |
}
|
|
1276 |
case EOperation_AbnormalTermination:
|
|
1277 |
{
|
|
1278 |
User::Panic( _L("Abnormal termination"), 123 );
|
|
1279 |
break;
|
|
1280 |
}
|
|
1281 |
case EOperation_ToggleExternalPlayer:
|
|
1282 |
{
|
|
1283 |
if( iExternalPlayer )
|
|
1284 |
{
|
|
1285 |
delete iExternalPlayer;
|
|
1286 |
iExternalPlayer = NULL;
|
|
1287 |
iActivePlayer = NULL;
|
|
1288 |
}
|
|
1289 |
else
|
|
1290 |
{
|
|
1291 |
iLastError = CreateAnotherPlayer(NULL,
|
|
1292 |
&iExternalPlayer,
|
|
1293 |
KExternalPlayerExe,
|
|
1294 |
TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2),
|
|
1295 |
TPoint(iDisplaySize.iWidth/2, 0));
|
|
1296 |
iActivePlayer = iExternalPlayer;
|
|
1297 |
EnableDragging();
|
|
1298 |
}
|
|
1299 |
break;
|
|
1300 |
}
|
|
1301 |
case EOperation_ToggleExternalPlayer2:
|
|
1302 |
{
|
|
1303 |
if( iExternalPlayer2 )
|
|
1304 |
{
|
|
1305 |
delete iExternalPlayer2;
|
|
1306 |
iExternalPlayer2 = NULL;
|
|
1307 |
iActivePlayer = NULL;
|
|
1308 |
}
|
|
1309 |
else
|
|
1310 |
{
|
|
1311 |
iLastError = CreateAnotherPlayer(NULL,
|
|
1312 |
&iExternalPlayer2,
|
|
1313 |
KExternalPlayerExe2,
|
|
1314 |
TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2),
|
|
1315 |
TPoint(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2));
|
|
1316 |
iActivePlayer = iExternalPlayer2;
|
|
1317 |
EnableDragging();
|
|
1318 |
}
|
|
1319 |
break;
|
|
1320 |
}
|
|
1321 |
case EOperation_LaunchAllWindows:
|
|
1322 |
{
|
|
1323 |
if( iVideoPlayer->FullFilename().Length() > 0 )
|
|
1324 |
{
|
|
1325 |
if( iVideoPlayer2 == NULL )
|
|
1326 |
{
|
|
1327 |
iVideoPlayer2 = PlayerWindowNewL( iMainPlayerApi,
|
|
1328 |
TPoint(0,iDisplaySize.iHeight/2),
|
|
1329 |
TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2),
|
|
1330 |
true, // transparent
|
|
1331 |
KRgbTransparent,
|
|
1332 |
false );
|
|
1333 |
|
|
1334 |
iVideoPlayer2->StartWithFilenameL( iVideoPlayer->FullFilename(), CPlayerWindow::EBestFit);
|
|
1335 |
}
|
|
1336 |
|
|
1337 |
if( iVideoPlayer3 == NULL )
|
|
1338 |
{
|
|
1339 |
iVideoPlayer3 = PlayerWindowNewL( iMainPlayerApi,
|
|
1340 |
TPoint(0,2*iDisplaySize.iHeight/3),
|
|
1341 |
TSize(iDisplaySize.iWidth/3,iDisplaySize.iHeight/3),
|
|
1342 |
true, // transparent
|
|
1343 |
KRgbTransparent,
|
|
1344 |
false );
|
|
1345 |
|
|
1346 |
iVideoPlayer3->StartWithFilenameL( iVideoPlayer->FullFilename(), CPlayerWindow::EBestFit);
|
|
1347 |
}
|
|
1348 |
|
|
1349 |
if( iExternalPlayer == NULL )
|
|
1350 |
{
|
|
1351 |
iExternalPlayer = new CExternalPlayer( iWs );
|
|
1352 |
|
|
1353 |
iExternalPlayer->Launch( KExternalPlayerExe,
|
|
1354 |
*iWindowGroup,
|
|
1355 |
iVideoPlayer->FullFilename(),
|
|
1356 |
true,
|
|
1357 |
TPoint(iDisplaySize.iWidth/2, 0),
|
|
1358 |
TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2) );
|
|
1359 |
}
|
|
1360 |
|
|
1361 |
/* TODO: FIGURE OUT HOW TO LAUNCH TWO EXTERNAL WINDOWS
|
|
1362 |
if( iExternalPlayer2 == NULL )
|
|
1363 |
{
|
|
1364 |
iExternalPlayer2 = new CExternalPlayer();
|
|
1365 |
|
|
1366 |
iExternalPlayer2->Launch( KExternalPlayerExe2,
|
|
1367 |
*iWindowGroup,
|
|
1368 |
iVideoPlayer->FullFilename(),
|
|
1369 |
true,
|
|
1370 |
TPoint(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2),
|
|
1371 |
TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2) );
|
|
1372 |
|
|
1373 |
}
|
|
1374 |
*/
|
|
1375 |
|
|
1376 |
UpdateWindowOrdinalPositions();
|
|
1377 |
|
|
1378 |
DrawBorderAroundActiveWindows();
|
|
1379 |
}
|
|
1380 |
break;
|
|
1381 |
}
|
|
1382 |
case EOperation_ObscureWindow:
|
|
1383 |
{
|
|
1384 |
iObscured = !iObscured;
|
|
1385 |
iFullScreenWindow->SetVisible( iObscured );
|
|
1386 |
break;
|
|
1387 |
}
|
|
1388 |
default:
|
|
1389 |
{
|
|
1390 |
// Route the operation to the appropriate player window.
|
|
1391 |
MPlayerCommands* player = CurrentPlayer();
|
|
1392 |
if( player )
|
|
1393 |
{
|
|
1394 |
iLastError = player->ExecuteOperation( aOperation );
|
|
1395 |
}
|
|
1396 |
else
|
|
1397 |
{
|
|
1398 |
// Do not show the operation text.
|
|
1399 |
iSelectedOptionText.SetLength(0);
|
|
1400 |
}
|
|
1401 |
break;
|
|
1402 |
}
|
|
1403 |
}
|
|
1404 |
|
|
1405 |
UpdateVideoWindow();
|
|
1406 |
|
|
1407 |
if( iLastError != KErrNone )
|
|
1408 |
{
|
|
1409 |
RDebug::Printf( "CONSOLEPLAYER error=%i", iLastError );
|
|
1410 |
}
|
|
1411 |
}
|
|
1412 |
|
|
1413 |
void CConsolePlayer::HandlePointerEvent( const TAdvancedPointerEvent& aEvent )
|
|
1414 |
{
|
|
1415 |
TTestAppPointerEvent pointerEvent = CharacterizePointerEvent( aEvent );
|
|
1416 |
|
|
1417 |
if( pointerEvent == EPointerEvent_Select )
|
|
1418 |
{
|
|
1419 |
DisableDragging();
|
|
1420 |
iSelectedOptionText.Copy( _L("Drag disabled") );
|
|
1421 |
iSelectedOptionTextCounter = 3;
|
|
1422 |
UpdateVideoWindow();
|
|
1423 |
}
|
|
1424 |
else
|
|
1425 |
{
|
|
1426 |
MPlayerCommands* player = CurrentPlayer();
|
|
1427 |
if( player )
|
|
1428 |
{
|
|
1429 |
player->MoveWindow( aEvent.iParentPosition );
|
|
1430 |
}
|
|
1431 |
|
|
1432 |
UpdateVideoWindow();
|
|
1433 |
}
|
|
1434 |
}
|
|
1435 |
|
|
1436 |
void CConsolePlayer::PlayInitiated()
|
|
1437 |
{
|
|
1438 |
RDebug::Printf( "CONSOLEPLAYER PlayInitiated" );
|
|
1439 |
|
|
1440 |
UpdateWindowOrdinalPositions();
|
|
1441 |
|
|
1442 |
if( iTimerCallback )
|
|
1443 |
{
|
|
1444 |
iTimerCallback->Start( 1000000 ); // 1 second
|
|
1445 |
}
|
|
1446 |
|
|
1447 |
// Display this text at startup.
|
|
1448 |
iSelectedOptionText.Copy( _L("Press '0' during playback for help") );
|
|
1449 |
iSelectedOptionTextCounter = 5;
|
|
1450 |
|
|
1451 |
StartMonitoringWindowEvents();
|
|
1452 |
}
|
|
1453 |
|
|
1454 |
void CConsolePlayer::PlayStateChanged()
|
|
1455 |
{
|
|
1456 |
UpdateVideoWindow();
|
|
1457 |
}
|
|
1458 |
|
|
1459 |
void CConsolePlayer::Error(TInt aError)
|
|
1460 |
{
|
|
1461 |
RDebug::Printf( "CONSOLEPLAYER error=%i", aError );
|
|
1462 |
CActiveScheduler::Stop();
|
|
1463 |
|
|
1464 |
iFinalResult = aError;
|
|
1465 |
}
|
|
1466 |
|
|
1467 |
void CConsolePlayer::TimerCallback()
|
|
1468 |
{
|
|
1469 |
if( iSelectedOptionText.Length() > 0 )
|
|
1470 |
{
|
|
1471 |
iSelectedOptionTextCounter--;
|
|
1472 |
|
|
1473 |
if( iSelectedOptionTextCounter == 0 )
|
|
1474 |
{
|
|
1475 |
iSelectedOptionText.SetLength(0);
|
|
1476 |
}
|
|
1477 |
}
|
|
1478 |
|
|
1479 |
if( iVideoWindowTextMode > 0 )
|
|
1480 |
{
|
|
1481 |
UpdateVideoWindow();
|
|
1482 |
}
|
|
1483 |
}
|
|
1484 |
|
|
1485 |
GLDEF_C TInt E32Main()
|
|
1486 |
{
|
|
1487 |
__UHEAP_MARK;
|
|
1488 |
|
|
1489 |
CActiveScheduler* scheduler = new CActiveScheduler;
|
|
1490 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
1491 |
if( scheduler != NULL && cleanup != NULL )
|
|
1492 |
{
|
|
1493 |
CActiveScheduler::Install( scheduler );
|
|
1494 |
TRAP_IGNORE( CConsolePlayer::ExecuteL() );
|
|
1495 |
}
|
|
1496 |
delete cleanup;
|
|
1497 |
delete scheduler;
|
|
1498 |
REComSession::FinalClose();
|
|
1499 |
__UHEAP_MARKEND;
|
|
1500 |
return 0;
|
|
1501 |
}
|
|
1502 |
|