30
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Implementation of VideoPlayerEngine
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
55
|
18 |
// Version : %version: da1mmcf#43 %
|
30
|
19 |
|
|
20 |
|
34
|
21 |
#include <QApplication>
|
30
|
22 |
|
|
23 |
#include <hbinstance.h>
|
|
24 |
#include <xqpluginloader.h>
|
|
25 |
#include <xqplugininfo.h>
|
|
26 |
#include <xqserviceutil.h>
|
35
|
27 |
#include <hbview.h>
|
40
|
28 |
#include <hbapplication.h>
|
|
29 |
#include <hbactivitymanager.h>
|
55
|
30 |
#include <hbnotificationdialog.h>
|
30
|
31 |
|
|
32 |
#include "videoplayerengine.h"
|
40
|
33 |
#include "videoactivitystate.h"
|
44
|
34 |
#include "videoplaybackwrapper.h"
|
30
|
35 |
#include "videoservices.h"
|
35
|
36 |
#include "mpxvideo_debug.h"
|
30
|
37 |
|
|
38 |
// -------------------------------------------------------------------------------------------------
|
44
|
39 |
// VideoPlayerEngine()
|
30
|
40 |
// -------------------------------------------------------------------------------------------------
|
|
41 |
//
|
44
|
42 |
VideoPlayerEngine::VideoPlayerEngine( bool isService )
|
30
|
43 |
: mIsService( isService )
|
36
|
44 |
, mEmbedded( false )
|
|
45 |
, mDelayedLoadDone( false )
|
38
|
46 |
, mIsPlayService( false )
|
30
|
47 |
, mCurrentViewPlugin( 0 )
|
|
48 |
, mPlaybackViewPlugin( 0 )
|
|
49 |
, mCollectionViewPlugin( 0 )
|
|
50 |
, mFileDetailsViewPlugin( 0 )
|
|
51 |
, mPlaybackWrapper( 0 )
|
36
|
52 |
, mVideoServices( 0 )
|
30
|
53 |
{
|
44
|
54 |
MPX_DEBUG(_L("VideoPlayerEngine::VideoPlayerEngine()"));
|
30
|
55 |
}
|
|
56 |
|
|
57 |
// -------------------------------------------------------------------------------------------------
|
44
|
58 |
// ~VideoPlayerEngine()
|
30
|
59 |
// -------------------------------------------------------------------------------------------------
|
|
60 |
//
|
44
|
61 |
VideoPlayerEngine::~VideoPlayerEngine()
|
30
|
62 |
{
|
44
|
63 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::~VideoPlayerEngine()"));
|
|
64 |
|
30
|
65 |
if ( mVideoServices )
|
|
66 |
{
|
|
67 |
mVideoServices->decreaseReferenceCount();
|
|
68 |
mVideoServices = 0;
|
|
69 |
}
|
|
70 |
|
44
|
71 |
if ( mCollectionViewPlugin )
|
30
|
72 |
{
|
|
73 |
mCollectionViewPlugin->destroyView();
|
44
|
74 |
delete mCollectionViewPlugin;
|
|
75 |
mCollectionViewPlugin = 0;
|
30
|
76 |
}
|
|
77 |
|
44
|
78 |
if ( mPlaybackViewPlugin )
|
30
|
79 |
{
|
|
80 |
mPlaybackViewPlugin->destroyView();
|
44
|
81 |
delete mPlaybackViewPlugin;
|
|
82 |
mPlaybackViewPlugin = 0;
|
30
|
83 |
}
|
|
84 |
|
44
|
85 |
if ( mFileDetailsViewPlugin )
|
30
|
86 |
{
|
|
87 |
mFileDetailsViewPlugin->destroyView();
|
44
|
88 |
delete mFileDetailsViewPlugin;
|
|
89 |
mFileDetailsViewPlugin = 0;
|
30
|
90 |
}
|
|
91 |
|
|
92 |
delete mPlaybackWrapper;
|
|
93 |
|
44
|
94 |
// disconnect all signals
|
30
|
95 |
disconnect();
|
|
96 |
}
|
|
97 |
|
|
98 |
// -------------------------------------------------------------------------------------------------
|
|
99 |
// initialize()
|
|
100 |
// -------------------------------------------------------------------------------------------------
|
|
101 |
//
|
44
|
102 |
void VideoPlayerEngine::initialize()
|
30
|
103 |
{
|
44
|
104 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::initialize()"));
|
|
105 |
|
30
|
106 |
//
|
44
|
107 |
// Clean up VideoPlayerEngine when qApp try to quit
|
30
|
108 |
//
|
|
109 |
connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( handleQuit() ) );
|
|
110 |
|
|
111 |
//
|
|
112 |
// Create playback wrapper
|
|
113 |
//
|
44
|
114 |
if ( ! mPlaybackWrapper )
|
30
|
115 |
{
|
44
|
116 |
mPlaybackWrapper = new VideoPlaybackWrapper();
|
30
|
117 |
connect( mPlaybackWrapper,
|
|
118 |
SIGNAL( handlePlaybackView( int ) ),
|
|
119 |
this,
|
|
120 |
SLOT( handleCommand( int ) ) );
|
|
121 |
}
|
|
122 |
|
|
123 |
QList<XQPluginInfo> impls;
|
|
124 |
XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls);
|
44
|
125 |
|
40
|
126 |
if ( mIsService )
|
30
|
127 |
{
|
44
|
128 |
if ( ! mVideoServices )
|
40
|
129 |
{
|
|
130 |
mVideoServices = VideoServices::instance(this);
|
|
131 |
connect( mVideoServices, SIGNAL(activated(int)), this, SLOT(handleCommand(int)));
|
|
132 |
}
|
44
|
133 |
|
40
|
134 |
if ( isPlayServiceInvoked() )
|
|
135 |
{
|
44
|
136 |
createPlaybackView();
|
40
|
137 |
}
|
|
138 |
else
|
|
139 |
{
|
44
|
140 |
loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
|
|
141 |
|
|
142 |
//
|
40
|
143 |
// Browse service will activate view once the category to be opened is informed from highway
|
|
144 |
// since the category is not known at this point, we do not activate view for it here
|
44
|
145 |
//
|
|
146 |
if ( ! (XQServiceUtil::interfaceName().contains("IVideoBrowse") ) )
|
40
|
147 |
{
|
44
|
148 |
activateView( MpxHbVideoCommon::CollectionView );
|
40
|
149 |
}
|
|
150 |
}
|
36
|
151 |
}
|
|
152 |
else
|
38
|
153 |
{
|
44
|
154 |
//
|
|
155 |
// check latest plugin type from activity manager data and create + activate it
|
40
|
156 |
// CollectionView (default) and playbackview are the ones that are accepted
|
44
|
157 |
//
|
40
|
158 |
MpxHbVideoCommon::MpxHbVideoViewType viewType = MpxHbVideoCommon::CollectionView;
|
44
|
159 |
int typeGotten = VideoActivityState::instance().getActivityData( KEY_VIEWPLUGIN_TYPE ).toInt();
|
|
160 |
|
|
161 |
if ( typeGotten == MpxHbVideoCommon::PlaybackView )
|
38
|
162 |
{
|
44
|
163 |
createPlaybackView();
|
40
|
164 |
viewType = MpxHbVideoCommon::MpxHbVideoViewType(typeGotten);
|
44
|
165 |
QVariant data = VideoActivityState::instance().getActivityData( KEY_LAST_PLAYED_CLIP );
|
49
|
166 |
int error = mPlaybackWrapper->replayMedia( data.toString() );
|
|
167 |
|
|
168 |
// if replay fails, then activate collection view instead
|
|
169 |
if ( error != KErrNone )
|
|
170 |
{
|
|
171 |
loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
|
|
172 |
activateView( MpxHbVideoCommon::CollectionView );
|
|
173 |
}
|
38
|
174 |
}
|
41
|
175 |
else
|
|
176 |
{
|
44
|
177 |
loadPluginAndCreateView( viewType );
|
|
178 |
activateView( viewType );
|
41
|
179 |
}
|
36
|
180 |
}
|
44
|
181 |
|
30
|
182 |
}
|
|
183 |
|
|
184 |
// -------------------------------------------------------------------------------------------------
|
|
185 |
// handleCommand()
|
|
186 |
// -------------------------------------------------------------------------------------------------
|
|
187 |
//
|
44
|
188 |
void VideoPlayerEngine::handleCommand( int commandCode )
|
30
|
189 |
{
|
44
|
190 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::handleCommand()"),
|
36
|
191 |
_L("commandCode = %d"), commandCode );
|
44
|
192 |
|
30
|
193 |
switch ( commandCode )
|
|
194 |
{
|
|
195 |
case MpxHbVideoCommon::ActivateCollectionView:
|
|
196 |
{
|
|
197 |
if ( mCurrentViewPlugin != mCollectionViewPlugin )
|
44
|
198 |
{
|
30
|
199 |
activateView( MpxHbVideoCommon::CollectionView );
|
|
200 |
}
|
|
201 |
break;
|
|
202 |
}
|
|
203 |
case MpxHbVideoCommon::ActivatePlaybackView:
|
|
204 |
{
|
|
205 |
if ( mCurrentViewPlugin != mPlaybackViewPlugin )
|
44
|
206 |
{
|
|
207 |
activateView( MpxHbVideoCommon::PlaybackView );
|
30
|
208 |
}
|
|
209 |
break;
|
|
210 |
}
|
|
211 |
case MpxHbVideoCommon::ActivateVideoDetailsView:
|
|
212 |
{
|
|
213 |
if ( mCurrentViewPlugin != mFileDetailsViewPlugin )
|
37
|
214 |
{
|
44
|
215 |
activateView( MpxHbVideoCommon::VideoDetailsView );
|
30
|
216 |
}
|
|
217 |
break;
|
|
218 |
}
|
35
|
219 |
case MpxHbVideoCommon::DoDelayedLoad:
|
30
|
220 |
{
|
37
|
221 |
if ( ! mDelayedLoadDone )
|
|
222 |
{
|
|
223 |
doDelayedLoad();
|
|
224 |
}
|
35
|
225 |
break;
|
|
226 |
}
|
44
|
227 |
|
30
|
228 |
default:
|
|
229 |
{
|
|
230 |
break;
|
|
231 |
}
|
44
|
232 |
}
|
30
|
233 |
}
|
|
234 |
|
|
235 |
// -------------------------------------------------------------------------------------------------
|
49
|
236 |
// viewReadySlot()
|
|
237 |
// -------------------------------------------------------------------------------------------------
|
|
238 |
//
|
|
239 |
void VideoPlayerEngine::viewReadySlot()
|
|
240 |
{
|
|
241 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::viewReady()"));
|
|
242 |
emit applicationReady();
|
|
243 |
// since we need to emit applicationReady only once at startup,
|
|
244 |
// disconnect the viewReady -signal from this object
|
|
245 |
disconnect(hbInstance->allMainWindows().value(0), SIGNAL(viewReady()),
|
|
246 |
this, SLOT(viewReadySlot()));
|
|
247 |
}
|
|
248 |
|
|
249 |
// -------------------------------------------------------------------------------------------------
|
35
|
250 |
// doDelayedLoad()
|
|
251 |
// -------------------------------------------------------------------------------------------------
|
|
252 |
//
|
44
|
253 |
void VideoPlayerEngine::doDelayedLoad()
|
35
|
254 |
{
|
44
|
255 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::doDelayedLoad()"));
|
|
256 |
|
40
|
257 |
createMissingViews();
|
44
|
258 |
|
37
|
259 |
mDelayedLoadDone = true;
|
35
|
260 |
}
|
|
261 |
|
|
262 |
// -------------------------------------------------------------------------------------------------
|
40
|
263 |
// createPlaybackView()
|
36
|
264 |
// -------------------------------------------------------------------------------------------------
|
|
265 |
//
|
44
|
266 |
void VideoPlayerEngine::createPlaybackView()
|
36
|
267 |
{
|
40
|
268 |
mPlaybackWrapper->lateInit();
|
44
|
269 |
|
40
|
270 |
if ( ! mPlaybackViewPlugin )
|
|
271 |
{
|
|
272 |
loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
|
|
273 |
}
|
|
274 |
}
|
|
275 |
|
|
276 |
// -------------------------------------------------------------------------------------------------
|
|
277 |
// createMissingViews()
|
|
278 |
// -------------------------------------------------------------------------------------------------
|
|
279 |
//
|
44
|
280 |
void VideoPlayerEngine::createMissingViews()
|
40
|
281 |
{
|
44
|
282 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::createMissingViews()"));
|
|
283 |
|
37
|
284 |
//
|
|
285 |
// delayed initialization of some uiengine member variables
|
|
286 |
// to help application startup time & improve playback start time
|
|
287 |
//
|
40
|
288 |
createPlaybackView();
|
36
|
289 |
|
44
|
290 |
if ( ! mFileDetailsViewPlugin )
|
36
|
291 |
{
|
|
292 |
loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );
|
37
|
293 |
}
|
44
|
294 |
|
|
295 |
if ( ! mCollectionViewPlugin )
|
40
|
296 |
{
|
|
297 |
loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
|
|
298 |
}
|
36
|
299 |
}
|
|
300 |
|
|
301 |
|
|
302 |
// -------------------------------------------------------------------------------------------------
|
30
|
303 |
// activateView()
|
|
304 |
// activate view based on view type.
|
|
305 |
// -------------------------------------------------------------------------------------------------
|
|
306 |
//
|
44
|
307 |
void VideoPlayerEngine::activateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
|
30
|
308 |
{
|
44
|
309 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::activateView() "),
|
36
|
310 |
_L("viewType = %d"), viewType );
|
44
|
311 |
|
30
|
312 |
disconnectView();
|
44
|
313 |
|
30
|
314 |
if ( mCurrentViewPlugin )
|
|
315 |
{
|
|
316 |
mCurrentViewPlugin->deactivateView();
|
|
317 |
mCurrentViewPlugin = NULL;
|
|
318 |
}
|
|
319 |
|
39
|
320 |
switch ( viewType )
|
30
|
321 |
{
|
39
|
322 |
case MpxHbVideoCommon::CollectionView:
|
36
|
323 |
{
|
39
|
324 |
if ( shouldExit() )
|
37
|
325 |
{
|
55
|
326 |
serviceQuit();
|
37
|
327 |
}
|
39
|
328 |
else if ( shouldActivateCollectionView() )
|
|
329 |
{
|
|
330 |
if ( ! mCollectionViewPlugin )
|
|
331 |
{
|
|
332 |
loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
|
44
|
333 |
}
|
39
|
334 |
mCurrentViewPlugin = mCollectionViewPlugin;
|
44
|
335 |
setCurrentView();
|
39
|
336 |
}
|
44
|
337 |
|
|
338 |
break;
|
36
|
339 |
}
|
39
|
340 |
case MpxHbVideoCommon::PlaybackView:
|
|
341 |
{
|
|
342 |
if ( ! mPlaybackViewPlugin )
|
|
343 |
{
|
|
344 |
loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
|
|
345 |
}
|
44
|
346 |
|
39
|
347 |
mCurrentViewPlugin = mPlaybackViewPlugin;
|
44
|
348 |
setCurrentView();
|
|
349 |
|
|
350 |
break;
|
39
|
351 |
}
|
|
352 |
case MpxHbVideoCommon::VideoDetailsView:
|
|
353 |
{
|
|
354 |
if ( ! mFileDetailsViewPlugin )
|
|
355 |
{
|
44
|
356 |
loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );
|
39
|
357 |
}
|
44
|
358 |
|
39
|
359 |
mCurrentViewPlugin = mFileDetailsViewPlugin;
|
44
|
360 |
setCurrentView();
|
|
361 |
|
|
362 |
break;
|
|
363 |
}
|
|
364 |
}
|
30
|
365 |
}
|
|
366 |
|
|
367 |
// -------------------------------------------------------------------------------------------------
|
36
|
368 |
// loadPluginAndCreateView()
|
30
|
369 |
// -------------------------------------------------------------------------------------------------
|
|
370 |
//
|
44
|
371 |
void VideoPlayerEngine::loadPluginAndCreateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
|
30
|
372 |
{
|
44
|
373 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::loadPluginAndCreateView() "),
|
36
|
374 |
_L("viewType = %d"), viewType );
|
44
|
375 |
|
30
|
376 |
int viewTypeUid( 0 );
|
|
377 |
|
44
|
378 |
if ( viewType == MpxHbVideoCommon::CollectionView )
|
30
|
379 |
{
|
|
380 |
viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllCollectionUid;
|
|
381 |
}
|
44
|
382 |
else if ( viewType == MpxHbVideoCommon::PlaybackView )
|
30
|
383 |
{
|
|
384 |
viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllPlaybackUid;
|
|
385 |
}
|
37
|
386 |
else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
|
30
|
387 |
{
|
|
388 |
viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllFileDetailsUid;
|
|
389 |
}
|
|
390 |
|
|
391 |
if ( viewTypeUid )
|
|
392 |
{
|
44
|
393 |
//
|
37
|
394 |
// load corresponding plug-in
|
|
395 |
//
|
30
|
396 |
XQPluginLoader pluginLoader( viewTypeUid );
|
|
397 |
QObject* instance = pluginLoader.instance();
|
|
398 |
|
|
399 |
if ( instance )
|
|
400 |
{
|
36
|
401 |
MpxViewPlugin *currentViewPlugin = NULL;
|
|
402 |
|
44
|
403 |
if ( viewType == MpxHbVideoCommon::CollectionView )
|
30
|
404 |
{
|
|
405 |
mCollectionViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
|
36
|
406 |
currentViewPlugin = mCollectionViewPlugin;
|
30
|
407 |
}
|
|
408 |
else if ( viewType == MpxHbVideoCommon::PlaybackView )
|
|
409 |
{
|
|
410 |
mPlaybackViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
|
36
|
411 |
currentViewPlugin = mPlaybackViewPlugin;
|
30
|
412 |
}
|
|
413 |
else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
|
|
414 |
{
|
|
415 |
mFileDetailsViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
|
36
|
416 |
currentViewPlugin = mFileDetailsViewPlugin;
|
30
|
417 |
}
|
36
|
418 |
else
|
|
419 |
{
|
44
|
420 |
MPX_DEBUG(_L("VideoPlayerEngine::loadPluginAndCreateView() : plugin not FOUND ! "));
|
36
|
421 |
}
|
44
|
422 |
|
37
|
423 |
//
|
|
424 |
// create corresponding view
|
|
425 |
//
|
44
|
426 |
if ( currentViewPlugin )
|
36
|
427 |
{
|
|
428 |
QGraphicsWidget *view = currentViewPlugin->getView();
|
44
|
429 |
|
36
|
430 |
if ( ! view )
|
|
431 |
{
|
44
|
432 |
MPX_DEBUG(_L("VideoPlayerEngine::loadPluginAndCreateView() : create view "));
|
|
433 |
|
36
|
434 |
currentViewPlugin->createView();
|
|
435 |
hbInstance->allMainWindows().value(0)->addView( currentViewPlugin->getView() );
|
|
436 |
}
|
|
437 |
else
|
|
438 |
{
|
44
|
439 |
MPX_DEBUG(_L("VideoPlayerEngine::loadPluginAndCreateView() : view has already been created! "));
|
36
|
440 |
}
|
|
441 |
}
|
|
442 |
else
|
|
443 |
{
|
44
|
444 |
MPX_DEBUG(_L("VideoPlayerEngine::loadPluginAndCreateView() : currentViewPlugin is NULL! "));
|
|
445 |
}
|
30
|
446 |
}
|
|
447 |
}
|
|
448 |
}
|
|
449 |
|
|
450 |
// -------------------------------------------------------------------------------------------------
|
|
451 |
// connectView()
|
|
452 |
// connect application to view by setting up the signals and slots.
|
|
453 |
// -------------------------------------------------------------------------------------------------
|
|
454 |
//
|
44
|
455 |
void VideoPlayerEngine::connectView()
|
30
|
456 |
{
|
44
|
457 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::connectView()"));
|
|
458 |
|
30
|
459 |
connect( mCurrentViewPlugin,
|
|
460 |
SIGNAL( command( int ) ),
|
|
461 |
this,
|
|
462 |
SLOT( handleCommand( int ) ) );
|
|
463 |
}
|
|
464 |
|
|
465 |
// -------------------------------------------------------------------------------------------------
|
|
466 |
// disconnectView()
|
|
467 |
// connect application to view by setting up the signals and slots.
|
|
468 |
// -------------------------------------------------------------------------------------------------
|
|
469 |
//
|
44
|
470 |
void VideoPlayerEngine::disconnectView()
|
30
|
471 |
{
|
44
|
472 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::disconnectView()"));
|
|
473 |
|
30
|
474 |
if ( mCurrentViewPlugin )
|
|
475 |
{
|
|
476 |
disconnect( mCurrentViewPlugin,
|
|
477 |
SIGNAL( command( int ) ),
|
|
478 |
this,
|
44
|
479 |
SLOT( handleCommand( int ) ) );
|
30
|
480 |
}
|
|
481 |
}
|
|
482 |
|
|
483 |
// -------------------------------------------------------------------------------------------------
|
|
484 |
// handleQuit()
|
|
485 |
// -------------------------------------------------------------------------------------------------
|
|
486 |
//
|
44
|
487 |
void VideoPlayerEngine::handleQuit()
|
30
|
488 |
{
|
44
|
489 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::handleQuit()"));
|
|
490 |
|
|
491 |
if ( ! mIsService )
|
40
|
492 |
{
|
|
493 |
VideoActivityState &localActivity(VideoActivityState::instance());
|
44
|
494 |
|
40
|
495 |
QVariant data = QVariant();
|
|
496 |
HbActivityManager *actManager = qobject_cast<HbApplication*>(qApp)->activityManager();
|
44
|
497 |
|
40
|
498 |
//
|
44
|
499 |
// deactivate is the final point for current plugin to save it's activity data into
|
41
|
500 |
// VideoActivityState before they are saved to to activity manager
|
|
501 |
//
|
44
|
502 |
mCurrentViewPlugin->deactivateView();
|
|
503 |
|
41
|
504 |
//
|
40
|
505 |
// get and save recent view type: either playback or collection view plugins are currently used.
|
|
506 |
// activity will not be saved from the details plugin
|
|
507 |
//
|
|
508 |
int viewType = MpxHbVideoCommon::CollectionView;
|
44
|
509 |
|
|
510 |
if ( mCurrentViewPlugin == mPlaybackViewPlugin )
|
40
|
511 |
{
|
41
|
512 |
// for playback view, the state preservation and restoration should only be done
|
|
513 |
// for loacl clips (non-streaming) - so set KEY_VIEWPLUGIN_TYPE to PlaybackView only
|
|
514 |
// for local clips. Otherwise the default value CollectionView should be set.
|
|
515 |
//
|
44
|
516 |
QVariant playdata = VideoActivityState::instance().getActivityData( KEY_LAST_LOCAL_PLAYBACK );
|
|
517 |
|
41
|
518 |
if ( playdata.toBool() )
|
|
519 |
{
|
|
520 |
viewType = MpxHbVideoCommon::PlaybackView;
|
44
|
521 |
}
|
40
|
522 |
}
|
44
|
523 |
|
41
|
524 |
data = viewType;
|
44
|
525 |
localActivity.setActivityData( data, KEY_VIEWPLUGIN_TYPE );
|
|
526 |
|
40
|
527 |
// save data to activity manager
|
44
|
528 |
actManager->addActivity( ACTIVITY_VIDEOPLAYER_MAINVIEW,
|
|
529 |
localActivity.getActivityData(),
|
|
530 |
QVariantHash() );
|
40
|
531 |
}
|
44
|
532 |
|
30
|
533 |
delete this;
|
|
534 |
}
|
|
535 |
|
|
536 |
|
|
537 |
// -------------------------------------------------------------------------------------------------
|
|
538 |
// playMedia()
|
|
539 |
// -------------------------------------------------------------------------------------------------
|
|
540 |
//
|
44
|
541 |
void VideoPlayerEngine::playMedia( QString filePath )
|
30
|
542 |
{
|
44
|
543 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::playMedia()"),
|
|
544 |
_L("filePath = %s"), filePath.data() );
|
|
545 |
|
50
|
546 |
int result = mPlaybackWrapper->playMedia( filePath );
|
|
547 |
|
|
548 |
if ( result != KErrNone )
|
|
549 |
{
|
|
550 |
handlePlaybackFailure(result);
|
|
551 |
}
|
|
552 |
}
|
|
553 |
|
|
554 |
// -------------------------------------------------------------------------------------------------
|
|
555 |
// playURI()
|
|
556 |
// -------------------------------------------------------------------------------------------------
|
|
557 |
//
|
|
558 |
void VideoPlayerEngine::playURI( QString uri )
|
|
559 |
{
|
|
560 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::playURI()"),
|
|
561 |
_L("uri = %s"), uri.data() );
|
|
562 |
|
|
563 |
int result = mPlaybackWrapper->playURI( uri );
|
|
564 |
|
|
565 |
if ( result != KErrNone )
|
|
566 |
{
|
|
567 |
handlePlaybackFailure(result);
|
|
568 |
}
|
30
|
569 |
}
|
|
570 |
|
|
571 |
// -------------------------------------------------------------------------------------------------
|
36
|
572 |
// playMedia()
|
|
573 |
// -------------------------------------------------------------------------------------------------
|
|
574 |
//
|
44
|
575 |
void VideoPlayerEngine::playMedia( RFile file )
|
36
|
576 |
{
|
44
|
577 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::playMedia( RFile )"));
|
|
578 |
|
50
|
579 |
int result = mPlaybackWrapper->playMedia( file );
|
|
580 |
|
|
581 |
if ( result != KErrNone )
|
|
582 |
{
|
|
583 |
handlePlaybackFailure(result);
|
|
584 |
}
|
36
|
585 |
}
|
|
586 |
|
|
587 |
// -------------------------------------------------------------------------------------------------
|
30
|
588 |
// setEmbedded()
|
|
589 |
// -------------------------------------------------------------------------------------------------
|
|
590 |
//
|
44
|
591 |
void VideoPlayerEngine::setEmbedded()
|
30
|
592 |
{
|
44
|
593 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::setEmbedded()"));
|
|
594 |
|
30
|
595 |
mEmbedded = true;
|
|
596 |
}
|
|
597 |
|
36
|
598 |
// -------------------------------------------------------------------------------------------------
|
|
599 |
// setCurrentView()
|
|
600 |
// -------------------------------------------------------------------------------------------------
|
|
601 |
//
|
44
|
602 |
void VideoPlayerEngine::setCurrentView()
|
36
|
603 |
{
|
44
|
604 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::setCurrentView()"));
|
|
605 |
|
36
|
606 |
if ( mCurrentViewPlugin )
|
|
607 |
{
|
|
608 |
//
|
|
609 |
// set current view
|
|
610 |
//
|
44
|
611 |
hbInstance->allMainWindows().value(0)->setCurrentView(
|
36
|
612 |
qobject_cast<HbView*>( mCurrentViewPlugin->getView() ), false );
|
|
613 |
|
|
614 |
//
|
|
615 |
// connect view
|
|
616 |
//
|
|
617 |
connectView();
|
|
618 |
|
44
|
619 |
//
|
36
|
620 |
// activate view
|
|
621 |
//
|
|
622 |
mCurrentViewPlugin->activateView();
|
|
623 |
}
|
|
624 |
}
|
|
625 |
|
38
|
626 |
// -------------------------------------------------------------------------------------------------
|
|
627 |
// isPlayServiceInvoked()
|
|
628 |
// -------------------------------------------------------------------------------------------------
|
|
629 |
//
|
44
|
630 |
bool VideoPlayerEngine::isPlayServiceInvoked()
|
38
|
631 |
{
|
44
|
632 |
MPX_ENTER_EXIT(_L("VideoPlayerEngine::isPlayServiceInvoked()"));
|
|
633 |
|
|
634 |
bool result = false;
|
|
635 |
|
38
|
636 |
if ( mIsService )
|
|
637 |
{
|
|
638 |
QString intface = XQServiceUtil::interfaceName();
|
44
|
639 |
MPX_DEBUG(_L("VideoPlayerEngine::isPlayServiceInvoked() : interfaceName(%s)"), intface.data() );
|
|
640 |
|
38
|
641 |
if ( intface.contains("IVideoView") ||
|
50
|
642 |
intface.contains("IFileView") ||
|
|
643 |
intface.contains("IUriView"))
|
38
|
644 |
{
|
|
645 |
result = true;
|
|
646 |
mIsPlayService = true;
|
|
647 |
}
|
|
648 |
}
|
44
|
649 |
|
|
650 |
MPX_DEBUG(_L("VideoPlayerEngine::isPlayServiceInvoked() return %d"), result);
|
38
|
651 |
return result;
|
|
652 |
}
|
36
|
653 |
|
39
|
654 |
// -------------------------------------------------------------------------------------------------
|
|
655 |
// shouldExit()
|
|
656 |
// -------------------------------------------------------------------------------------------------
|
|
657 |
//
|
44
|
658 |
bool VideoPlayerEngine::shouldExit()
|
|
659 |
{
|
39
|
660 |
bool result = false;
|
44
|
661 |
|
39
|
662 |
if ( mIsPlayService ) // play or view service
|
|
663 |
{
|
44
|
664 |
result = true;
|
39
|
665 |
}
|
44
|
666 |
|
|
667 |
MPX_DEBUG(_L("VideoPlayerEngine::shouldExit() return %d"), result);
|
|
668 |
|
39
|
669 |
return result;
|
|
670 |
}
|
|
671 |
|
|
672 |
|
|
673 |
// -------------------------------------------------------------------------------------------------
|
|
674 |
// shouldActivateCollectionView()
|
|
675 |
// -------------------------------------------------------------------------------------------------
|
|
676 |
//
|
44
|
677 |
bool VideoPlayerEngine::shouldActivateCollectionView()
|
|
678 |
{
|
|
679 |
bool result = true;
|
|
680 |
|
|
681 |
//
|
39
|
682 |
// the only case where collection view should NOT be activated is ...
|
44
|
683 |
// if we are in service and that service is fetch and if fetch is selected,
|
39
|
684 |
// in all other cases collection view should be activated
|
44
|
685 |
//
|
39
|
686 |
if ( mIsService &&
|
|
687 |
mVideoServices->currentService() == VideoServices::EUriFetcher &&
|
|
688 |
mVideoServices->mFetchSelected )
|
|
689 |
{
|
44
|
690 |
result = false;
|
|
691 |
}
|
|
692 |
|
|
693 |
MPX_DEBUG(_L("VideoPlayerEngine::shouldActivateCollectionView() return %d"), result);
|
|
694 |
|
39
|
695 |
return result;
|
|
696 |
}
|
|
697 |
|
50
|
698 |
|
|
699 |
// -------------------------------------------------------------------------------------------------
|
|
700 |
// handlePlaybackFailure()
|
|
701 |
// -------------------------------------------------------------------------------------------------
|
|
702 |
//
|
|
703 |
void VideoPlayerEngine::handlePlaybackFailure(int errorCode)
|
|
704 |
{
|
|
705 |
MPX_DEBUG(_L("VideoPlayerEngine::handlePlaybackFailure()"));
|
|
706 |
|
|
707 |
if ( mIsPlayService )
|
|
708 |
{
|
55
|
709 |
HbNotificationDialog* dlg = new HbNotificationDialog();
|
|
710 |
|
|
711 |
connect( dlg, SIGNAL( aboutToClose() ), this, SLOT( serviceQuit() ) );
|
50
|
712 |
|
|
713 |
switch ( errorCode )
|
|
714 |
{
|
|
715 |
case KErrNotSupported:
|
|
716 |
case KErrUnknown:
|
|
717 |
case KErrCorrupt:
|
|
718 |
case KErrTooBig:
|
|
719 |
{
|
|
720 |
dlg->setTitle( hbTrId( "txt_videos_info_invalid_clip_operation_canceled" ) );
|
|
721 |
break;
|
|
722 |
}
|
|
723 |
case KErrArgument:
|
|
724 |
case KErrBadName:
|
|
725 |
{
|
|
726 |
dlg->setTitle( hbTrId( "txt_videos_info_unable_to_connect_invalid_url" ) );
|
|
727 |
break;
|
|
728 |
}
|
|
729 |
case KErrNotFound:
|
|
730 |
{
|
|
731 |
dlg->setTitle( hbTrId( "txt_videos_info_file_not_found" ) );
|
|
732 |
break;
|
|
733 |
}
|
|
734 |
default:
|
|
735 |
{
|
|
736 |
const QString textToShow = mPlaybackWrapper->resloveErrorString(errorCode);
|
|
737 |
dlg->setTitle(textToShow);
|
|
738 |
break;
|
|
739 |
}
|
|
740 |
}
|
|
741 |
|
|
742 |
dlg->show();
|
55
|
743 |
|
50
|
744 |
}
|
|
745 |
}
|
55
|
746 |
|
|
747 |
|
|
748 |
// -------------------------------------------------------------------------------------------------
|
|
749 |
// serviceQuit()
|
|
750 |
// -------------------------------------------------------------------------------------------------
|
|
751 |
//
|
|
752 |
void VideoPlayerEngine::serviceQuit()
|
|
753 |
{
|
|
754 |
MPX_DEBUG(_L("VideoPlayerEngine::serviceQuit()"));
|
|
755 |
|
|
756 |
qApp->quit();
|
|
757 |
XQServiceUtil::toBackground( false );
|
|
758 |
}
|
|
759 |
|
|
760 |
|
30
|
761 |
// End of file
|