33 |
33 |
34 // ------------------------------------------------------------------------------------------------- |
34 // ------------------------------------------------------------------------------------------------- |
35 // QVideoPlayerEngine() |
35 // QVideoPlayerEngine() |
36 // ------------------------------------------------------------------------------------------------- |
36 // ------------------------------------------------------------------------------------------------- |
37 // |
37 // |
38 QVideoPlayerEngine::QVideoPlayerEngine(bool isService) |
38 QVideoPlayerEngine::QVideoPlayerEngine( bool isService ) |
39 : mIsService( isService ) |
39 : mIsService( isService ) |
40 , mEmbedded(false) |
40 , mEmbedded( false ) |
41 , mDelayedLoadDone(false) |
41 , mDelayedLoadDone( false ) |
42 , mCurrentViewPlugin( 0 ) |
42 , mCurrentViewPlugin( 0 ) |
43 , mPlaybackViewPlugin( 0 ) |
43 , mPlaybackViewPlugin( 0 ) |
44 , mCollectionViewPlugin( 0 ) |
44 , mCollectionViewPlugin( 0 ) |
45 , mFileDetailsViewPlugin( 0 ) |
45 , mFileDetailsViewPlugin( 0 ) |
46 , mPlaybackWrapper( 0 ) |
46 , mPlaybackWrapper( 0 ) |
47 , mVideoServices(0) |
47 , mVideoServices( 0 ) |
48 { |
48 { |
|
49 MPX_DEBUG(_L("QVideoPlayerEngine::QVideoPlayerEngine()")); |
49 } |
50 } |
50 |
51 |
51 // ------------------------------------------------------------------------------------------------- |
52 // ------------------------------------------------------------------------------------------------- |
52 // ~QVideoPlayerEngine() |
53 // ~QVideoPlayerEngine() |
53 // ------------------------------------------------------------------------------------------------- |
54 // ------------------------------------------------------------------------------------------------- |
118 |
120 |
119 QList<XQPluginInfo> impls; |
121 QList<XQPluginInfo> impls; |
120 XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls); |
122 XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls); |
121 |
123 |
122 // |
124 // |
123 // Pre-load collectionview and playbackview plugins |
125 // Pre-load collection plugin and create collection view |
124 // |
126 // |
125 loadPlugin( MpxHbVideoCommon::CollectionView ); |
127 loadPluginAndCreateView( MpxHbVideoCommon::CollectionView ); |
126 |
|
127 if ( mCollectionViewPlugin ) |
|
128 { |
|
129 mCollectionViewPlugin->createView(); |
|
130 hbInstance->allMainWindows().value(0)->addView( mCollectionViewPlugin->getView() ); |
|
131 } |
|
132 |
128 |
133 // |
129 // |
134 // default view in the app is the collection view. |
130 // if app is opened via serviceFW create remaining views |
135 // |
131 // otherwise activate default view i.e. the collection view. |
136 if(!mIsService) |
132 // |
137 { |
133 if( mIsService ) |
|
134 { |
|
135 createPlayAndDetailsViews(); |
|
136 } |
|
137 else |
|
138 { |
138 activateView( MpxHbVideoCommon::CollectionView ); |
139 activateView( MpxHbVideoCommon::CollectionView ); |
139 } |
140 } |
140 |
141 |
141 // delayed initialization of some uiengine member variables |
142 // delayed initialization of some uiengine member variables |
142 // to help application startup time & improve playback start time |
143 // to help application startup time & improve playback start time |
143 // |
144 // |
144 mPlaybackWrapper->lateInit(); |
145 mPlaybackWrapper->lateInit(); |
|
146 } |
|
147 |
|
148 // ------------------------------------------------------------------------------------------------- |
|
149 // handleCommand() |
|
150 // ------------------------------------------------------------------------------------------------- |
|
151 // |
|
152 void QVideoPlayerEngine::handleCommand( int commandCode ) |
|
153 { |
|
154 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleCommand()"), |
|
155 _L("commandCode = %d"), commandCode ); |
145 |
156 |
146 } |
|
147 |
|
148 // ------------------------------------------------------------------------------------------------- |
|
149 // handleCommand() |
|
150 // ------------------------------------------------------------------------------------------------- |
|
151 // |
|
152 void QVideoPlayerEngine::handleCommand( int commandCode ) |
|
153 { |
|
154 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleCommand()")); |
|
155 |
|
156 switch ( commandCode ) |
157 switch ( commandCode ) |
157 { |
158 { |
158 case MpxHbVideoCommon::ActivateCollectionView: |
159 case MpxHbVideoCommon::ActivateCollectionView: |
159 { |
160 { |
160 if ( mCurrentViewPlugin != mCollectionViewPlugin ) |
161 if ( mCurrentViewPlugin != mCollectionViewPlugin ) |
199 // doDelayedLoad() |
200 // doDelayedLoad() |
200 // ------------------------------------------------------------------------------------------------- |
201 // ------------------------------------------------------------------------------------------------- |
201 // |
202 // |
202 void QVideoPlayerEngine::doDelayedLoad() |
203 void QVideoPlayerEngine::doDelayedLoad() |
203 { |
204 { |
204 if ( !mPlaybackViewPlugin ) |
205 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::doDelayedLoad()")); |
205 { |
206 |
206 loadPlugin( MpxHbVideoCommon::PlaybackView ); |
207 createPlayAndDetailsViews(); |
207 |
|
208 if ( mPlaybackViewPlugin ) |
|
209 { |
|
210 mPlaybackViewPlugin->createView(); |
|
211 hbInstance->allMainWindows().value(0)->addView( mPlaybackViewPlugin->getView() ); |
|
212 } |
|
213 } |
|
214 |
|
215 if ( !mFileDetailsViewPlugin ) |
|
216 { |
|
217 loadPlugin( MpxHbVideoCommon::VideoDetailsView ); |
|
218 |
|
219 if ( mFileDetailsViewPlugin ) |
|
220 { |
|
221 mFileDetailsViewPlugin->createView(); |
|
222 hbInstance->allMainWindows().value(0)->addView( mFileDetailsViewPlugin->getView() ); |
|
223 } |
|
224 } |
|
225 |
208 |
226 mDelayedLoadDone = true; |
209 mDelayedLoadDone = true; |
227 } |
210 } |
228 |
211 |
229 // ------------------------------------------------------------------------------------------------- |
212 // ------------------------------------------------------------------------------------------------- |
|
213 // createPlayAndDetailsViews() |
|
214 // ------------------------------------------------------------------------------------------------- |
|
215 // |
|
216 void QVideoPlayerEngine::createPlayAndDetailsViews() |
|
217 { |
|
218 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::createPlayAndDetailsViews()")); |
|
219 |
|
220 if ( ! mPlaybackViewPlugin ) |
|
221 { |
|
222 loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView ); |
|
223 } |
|
224 |
|
225 if ( ! mFileDetailsViewPlugin ) |
|
226 { |
|
227 loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView ); |
|
228 } |
|
229 } |
|
230 |
|
231 |
|
232 // ------------------------------------------------------------------------------------------------- |
230 // activateView() |
233 // activateView() |
231 // activate view based on view type. |
234 // activate view based on view type. |
232 // ------------------------------------------------------------------------------------------------- |
235 // ------------------------------------------------------------------------------------------------- |
233 // |
236 // |
234 void QVideoPlayerEngine::activateView( MpxHbVideoCommon::MpxHbVideoViewType viewType ) |
237 void QVideoPlayerEngine::activateView( MpxHbVideoCommon::MpxHbVideoViewType viewType ) |
235 { |
238 { |
236 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::activateView()")); |
239 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::activateView() "), |
237 |
240 _L("viewType = %d"), viewType ); |
|
241 |
238 disconnectView(); |
242 disconnectView(); |
239 |
243 |
240 if ( mCurrentViewPlugin ) |
244 if ( mCurrentViewPlugin ) |
241 { |
245 { |
242 mCurrentViewPlugin->deactivateView(); |
246 mCurrentViewPlugin->deactivateView(); |
243 mCurrentViewPlugin = NULL; |
247 mCurrentViewPlugin = NULL; |
244 } |
248 } |
245 |
249 |
246 if ( viewType == MpxHbVideoCommon::CollectionView && mCollectionViewPlugin ) |
250 if ( viewType == MpxHbVideoCommon::CollectionView && mCollectionViewPlugin ) |
247 { |
251 { |
248 if ( mIsService && (VideoServices::EPlayback == mVideoServices->currentService()) ) |
252 if ( mIsService && |
249 { |
253 ( mVideoServices->currentService() == VideoServices::EPlayback || |
250 qApp->quit(); |
254 mVideoServices->currentService() == VideoServices::EView ) ) |
251 XQServiceUtil::toBackground(false); |
255 { |
252 return; |
256 qApp->quit(); |
253 } |
257 XQServiceUtil::toBackground( false ); |
254 else |
258 } |
255 { |
259 else |
256 mCurrentViewPlugin = mCollectionViewPlugin; |
260 { |
257 } |
261 mCurrentViewPlugin = mCollectionViewPlugin; |
|
262 setCurrentView(); |
|
263 } |
258 } |
264 } |
259 else if ( viewType == MpxHbVideoCommon::PlaybackView ) |
265 else if ( viewType == MpxHbVideoCommon::PlaybackView ) |
260 { |
266 { |
261 if(!mPlaybackViewPlugin) |
267 if( ! mPlaybackViewPlugin ) |
262 { |
268 { |
263 loadPlugin( MpxHbVideoCommon::PlaybackView ); |
269 loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView ); |
264 if ( mPlaybackViewPlugin ) |
270 } |
265 { |
271 |
266 mPlaybackViewPlugin->createView(); |
272 mCurrentViewPlugin = mPlaybackViewPlugin; |
267 hbInstance->allMainWindows().value(0)->addView( mPlaybackViewPlugin->getView() ); |
273 setCurrentView(); |
268 } |
274 } |
269 else |
275 else if ( viewType == MpxHbVideoCommon::VideoDetailsView ) |
270 { |
276 { |
271 return; |
277 if( ! mFileDetailsViewPlugin ) |
272 } |
278 { |
|
279 loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView ); |
273 } |
280 } |
274 mCurrentViewPlugin = mPlaybackViewPlugin; |
281 |
275 } |
|
276 else if ( viewType == MpxHbVideoCommon::VideoDetailsView ) |
|
277 { |
|
278 if(!mFileDetailsViewPlugin) |
|
279 { |
|
280 loadPlugin( MpxHbVideoCommon::VideoDetailsView ); |
|
281 if ( mFileDetailsViewPlugin ) |
|
282 { |
|
283 mFileDetailsViewPlugin->createView(); |
|
284 hbInstance->allMainWindows().value(0)->addView( mFileDetailsViewPlugin->getView() ); |
|
285 } |
|
286 else |
|
287 { |
|
288 return; |
|
289 } |
|
290 } |
|
291 mCurrentViewPlugin = mFileDetailsViewPlugin; |
282 mCurrentViewPlugin = mFileDetailsViewPlugin; |
292 } |
283 setCurrentView(); |
293 else |
284 } |
294 { |
285 } |
295 // invalid plugin activation request, do nothing |
286 |
296 return; |
287 // ------------------------------------------------------------------------------------------------- |
297 } |
288 // loadPluginAndCreateView() |
298 |
289 // ------------------------------------------------------------------------------------------------- |
299 hbInstance->allMainWindows().value(0)->setCurrentView( static_cast<HbView*>( mCurrentViewPlugin->getView() ), false ); |
290 // |
300 connectView(); |
291 void QVideoPlayerEngine::loadPluginAndCreateView( MpxHbVideoCommon::MpxHbVideoViewType viewType ) |
301 mCurrentViewPlugin->activateView(); |
292 { |
302 } |
293 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::loadPluginAndCreateView() "), |
303 |
294 _L("viewType = %d"), viewType ); |
304 // ------------------------------------------------------------------------------------------------- |
|
305 // loadPlugin() |
|
306 // ------------------------------------------------------------------------------------------------- |
|
307 // |
|
308 void QVideoPlayerEngine::loadPlugin( MpxHbVideoCommon::MpxHbVideoViewType viewType ) |
|
309 { |
|
310 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::loadPlugin()")); |
|
311 |
295 |
312 int viewTypeUid( 0 ); |
296 int viewTypeUid( 0 ); |
313 |
297 |
314 if ( viewType == MpxHbVideoCommon::CollectionView ) |
298 if ( viewType == MpxHbVideoCommon::CollectionView ) |
315 { |
299 { |
324 viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllFileDetailsUid; |
308 viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllFileDetailsUid; |
325 } |
309 } |
326 |
310 |
327 if ( viewTypeUid ) |
311 if ( viewTypeUid ) |
328 { |
312 { |
329 // activate the collection view |
313 // |
|
314 // load corresponding plug-in |
|
315 // |
330 XQPluginLoader pluginLoader( viewTypeUid ); |
316 XQPluginLoader pluginLoader( viewTypeUid ); |
331 QObject* instance = pluginLoader.instance(); |
317 QObject* instance = pluginLoader.instance(); |
332 |
318 |
333 if ( instance ) |
319 if ( instance ) |
334 { |
320 { |
|
321 MpxViewPlugin *currentViewPlugin = NULL; |
|
322 |
335 if ( viewType == MpxHbVideoCommon::CollectionView ) |
323 if ( viewType == MpxHbVideoCommon::CollectionView ) |
336 { |
324 { |
337 mCollectionViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin(); |
325 mCollectionViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin(); |
|
326 currentViewPlugin = mCollectionViewPlugin; |
338 } |
327 } |
339 else if ( viewType == MpxHbVideoCommon::PlaybackView ) |
328 else if ( viewType == MpxHbVideoCommon::PlaybackView ) |
340 { |
329 { |
341 mPlaybackViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin(); |
330 mPlaybackViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin(); |
|
331 currentViewPlugin = mPlaybackViewPlugin; |
342 } |
332 } |
343 else if ( viewType == MpxHbVideoCommon::VideoDetailsView ) |
333 else if ( viewType == MpxHbVideoCommon::VideoDetailsView ) |
344 { |
334 { |
345 mFileDetailsViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin(); |
335 mFileDetailsViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin(); |
346 } |
336 currentViewPlugin = mFileDetailsViewPlugin; |
|
337 } |
|
338 else |
|
339 { |
|
340 MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : plugin not FOUND ! ")); |
|
341 } |
|
342 |
|
343 // |
|
344 // create corresponding view |
|
345 // |
|
346 if ( currentViewPlugin ) |
|
347 { |
|
348 QGraphicsWidget *view = currentViewPlugin->getView(); |
|
349 |
|
350 if ( ! view ) |
|
351 { |
|
352 MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : create view ")); |
|
353 |
|
354 currentViewPlugin->createView(); |
|
355 hbInstance->allMainWindows().value(0)->addView( currentViewPlugin->getView() ); |
|
356 } |
|
357 else |
|
358 { |
|
359 MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : view has already been created! ")); |
|
360 } |
|
361 } |
|
362 else |
|
363 { |
|
364 MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : currentViewPlugin is NULL ! ")); |
|
365 } |
347 } |
366 } |
348 } |
367 } |
349 } |
368 } |
350 |
369 |
351 // ------------------------------------------------------------------------------------------------- |
370 // ------------------------------------------------------------------------------------------------- |
397 // playMedia() |
416 // playMedia() |
398 // ------------------------------------------------------------------------------------------------- |
417 // ------------------------------------------------------------------------------------------------- |
399 // |
418 // |
400 void QVideoPlayerEngine::playMedia( QString filePath ) |
419 void QVideoPlayerEngine::playMedia( QString filePath ) |
401 { |
420 { |
402 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia()")); |
421 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia()"), |
|
422 _L("filePath = %s"), filePath.data() ); |
403 |
423 |
404 mPlaybackWrapper->playMedia( filePath ); |
424 mPlaybackWrapper->playMedia( filePath ); |
405 } |
425 } |
406 |
426 |
407 // ------------------------------------------------------------------------------------------------- |
427 // ------------------------------------------------------------------------------------------------- |
|
428 // playMedia() |
|
429 // ------------------------------------------------------------------------------------------------- |
|
430 // |
|
431 void QVideoPlayerEngine::playMedia( RFile file ) |
|
432 { |
|
433 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia( RFile )")); |
|
434 |
|
435 mPlaybackWrapper->playMedia( file ); |
|
436 } |
|
437 |
|
438 // ------------------------------------------------------------------------------------------------- |
408 // setEmbedded() |
439 // setEmbedded() |
409 // ------------------------------------------------------------------------------------------------- |
440 // ------------------------------------------------------------------------------------------------- |
410 // |
441 // |
411 void QVideoPlayerEngine::setEmbedded() |
442 void QVideoPlayerEngine::setEmbedded() |
412 { |
443 { |
413 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setEmbedded()")); |
444 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setEmbedded()")); |
414 |
445 |
415 mEmbedded = true; |
446 mEmbedded = true; |
416 } |
447 } |
417 |
448 |
|
449 // ------------------------------------------------------------------------------------------------- |
|
450 // setCurrentView() |
|
451 // ------------------------------------------------------------------------------------------------- |
|
452 // |
|
453 void QVideoPlayerEngine::setCurrentView() |
|
454 { |
|
455 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setCurrentView()")); |
|
456 |
|
457 if ( mCurrentViewPlugin ) |
|
458 { |
|
459 // |
|
460 // set current view |
|
461 // |
|
462 hbInstance->allMainWindows().value(0)->setCurrentView( |
|
463 qobject_cast<HbView*>( mCurrentViewPlugin->getView() ), false ); |
|
464 |
|
465 // |
|
466 // connect view |
|
467 // |
|
468 connectView(); |
|
469 |
|
470 // |
|
471 // activate view |
|
472 // |
|
473 mCurrentViewPlugin->activateView(); |
|
474 } |
|
475 } |
|
476 |
|
477 |
418 // End of file |
478 // End of file |