13 * |
13 * |
14 * Description: Implementation of VideoPlayerEngine |
14 * Description: Implementation of VideoPlayerEngine |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // Version : %version: da1mmcf#31 % |
18 // Version : %version: 33 % |
19 |
19 |
20 |
20 |
21 #include <QApplication> |
21 #include <QApplication> |
22 |
22 |
23 #include <hbinstance.h> |
23 #include <hbinstance.h> |
24 #include <xqpluginloader.h> |
24 #include <xqpluginloader.h> |
25 #include <xqplugininfo.h> |
25 #include <xqplugininfo.h> |
26 #include <xqserviceutil.h> |
26 #include <xqserviceutil.h> |
27 #include <hbview.h> |
27 #include <hbview.h> |
|
28 #include <hbapplication.h> |
|
29 #include <hbactivitymanager.h> |
28 |
30 |
29 #include "videoplayerengine.h" |
31 #include "videoplayerengine.h" |
|
32 #include "videoactivitystate.h" |
30 #include "mpxvideoplaybackwrapper.h" |
33 #include "mpxvideoplaybackwrapper.h" |
31 #include "videoservices.h" |
34 #include "videoservices.h" |
32 #include "mpxvideo_debug.h" |
35 #include "mpxvideo_debug.h" |
33 |
36 |
34 // ------------------------------------------------------------------------------------------------- |
37 // ------------------------------------------------------------------------------------------------- |
65 } |
68 } |
66 |
69 |
67 if ( mCollectionViewPlugin ) |
70 if ( mCollectionViewPlugin ) |
68 { |
71 { |
69 mCollectionViewPlugin->destroyView(); |
72 mCollectionViewPlugin->destroyView(); |
|
73 delete mCollectionViewPlugin; |
|
74 mCollectionViewPlugin = 0; |
70 } |
75 } |
71 |
76 |
72 if ( mPlaybackViewPlugin ) |
77 if ( mPlaybackViewPlugin ) |
73 { |
78 { |
74 mPlaybackViewPlugin->destroyView(); |
79 mPlaybackViewPlugin->destroyView(); |
|
80 delete mPlaybackViewPlugin; |
|
81 mPlaybackViewPlugin = 0; |
75 } |
82 } |
76 |
83 |
77 if ( mFileDetailsViewPlugin ) |
84 if ( mFileDetailsViewPlugin ) |
78 { |
85 { |
79 mFileDetailsViewPlugin->destroyView(); |
86 mFileDetailsViewPlugin->destroyView(); |
|
87 delete mFileDetailsViewPlugin; |
|
88 mFileDetailsViewPlugin = 0; |
80 } |
89 } |
81 |
90 |
82 delete mPlaybackWrapper; |
91 delete mPlaybackWrapper; |
83 |
92 |
84 // disconnect all signals |
93 // disconnect all signals |
108 SIGNAL( handlePlaybackView( int ) ), |
117 SIGNAL( handlePlaybackView( int ) ), |
109 this, |
118 this, |
110 SLOT( handleCommand( int ) ) ); |
119 SLOT( handleCommand( int ) ) ); |
111 } |
120 } |
112 |
121 |
113 // |
|
114 // Get VideoServices instance |
|
115 // |
|
116 if ( mIsService && ! mVideoServices ) |
|
117 { |
|
118 mVideoServices = VideoServices::instance(this); |
|
119 connect( mVideoServices, SIGNAL(activated(int)), this, SLOT(handleCommand(int))); |
|
120 } |
|
121 |
|
122 QList<XQPluginInfo> impls; |
122 QList<XQPluginInfo> impls; |
123 XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls); |
123 XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls); |
124 |
124 |
125 if ( isPlayServiceInvoked() ) |
125 if ( mIsService ) |
126 { |
126 { |
127 createPlayAndDetailsViews(); |
127 if(!mVideoServices) |
|
128 { |
|
129 mVideoServices = VideoServices::instance(this); |
|
130 connect( mVideoServices, SIGNAL(activated(int)), this, SLOT(handleCommand(int))); |
|
131 } |
|
132 if ( isPlayServiceInvoked() ) |
|
133 { |
|
134 createPlaybackView(); |
|
135 } |
|
136 else |
|
137 { |
|
138 loadPluginAndCreateView( MpxHbVideoCommon::CollectionView ); |
|
139 |
|
140 // Browse service will activate view once the category to be opened is informed from highway |
|
141 // since the category is not known at this point, we do not activate view for it here |
|
142 if(!(XQServiceUtil::interfaceName().contains("IVideoBrowse"))) |
|
143 { |
|
144 activateView( MpxHbVideoCommon::CollectionView ); |
|
145 } |
|
146 } |
128 } |
147 } |
129 else |
148 else |
130 { |
149 { |
131 loadPluginAndCreateView( MpxHbVideoCommon::CollectionView ); |
150 // check latest plugin type from activity manager data and create + activate it |
132 |
151 // CollectionView (default) and playbackview are the ones that are accepted |
133 if((mIsService && !(XQServiceUtil::interfaceName().contains("IVideoBrowse"))) || !mIsService) |
152 MpxHbVideoCommon::MpxHbVideoViewType viewType = MpxHbVideoCommon::CollectionView; |
134 { |
153 int typeGotten = VideoActivityState::instance().getActivityData(VideoActivityData::KEY_VIEWPLUGIN_TYPE).toInt(); |
135 //Browse service will activate view once the category to be opened is informed from highway |
154 if(typeGotten == MpxHbVideoCommon::CollectionView || typeGotten == MpxHbVideoCommon::PlaybackView) |
136 activateView( MpxHbVideoCommon::CollectionView ); |
155 { |
137 } |
156 viewType = MpxHbVideoCommon::MpxHbVideoViewType(typeGotten); |
|
157 } |
|
158 loadPluginAndCreateView( viewType ); |
|
159 activateView( viewType ); |
138 } |
160 } |
139 |
161 |
140 } |
162 } |
141 |
163 |
142 // ------------------------------------------------------------------------------------------------- |
164 // ------------------------------------------------------------------------------------------------- |
196 // |
218 // |
197 void QVideoPlayerEngine::doDelayedLoad() |
219 void QVideoPlayerEngine::doDelayedLoad() |
198 { |
220 { |
199 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::doDelayedLoad()")); |
221 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::doDelayedLoad()")); |
200 |
222 |
201 createPlayAndDetailsViews(); |
223 createMissingViews(); |
202 |
224 |
203 mDelayedLoadDone = true; |
225 mDelayedLoadDone = true; |
204 } |
226 } |
205 |
227 |
206 // ------------------------------------------------------------------------------------------------- |
228 // ------------------------------------------------------------------------------------------------- |
207 // createPlayAndDetailsViews() |
229 // createPlaybackView() |
208 // ------------------------------------------------------------------------------------------------- |
230 // ------------------------------------------------------------------------------------------------- |
209 // |
231 // |
210 void QVideoPlayerEngine::createPlayAndDetailsViews() |
232 void QVideoPlayerEngine::createPlaybackView() |
211 { |
233 { |
212 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::createPlayAndDetailsViews()")); |
234 mPlaybackWrapper->lateInit(); |
|
235 |
|
236 if ( ! mPlaybackViewPlugin ) |
|
237 { |
|
238 loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView ); |
|
239 } |
|
240 } |
|
241 |
|
242 // ------------------------------------------------------------------------------------------------- |
|
243 // createMissingViews() |
|
244 // ------------------------------------------------------------------------------------------------- |
|
245 // |
|
246 void QVideoPlayerEngine::createMissingViews() |
|
247 { |
|
248 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::createMissingViews()")); |
213 |
249 |
214 // |
250 // |
215 // delayed initialization of some uiengine member variables |
251 // delayed initialization of some uiengine member variables |
216 // to help application startup time & improve playback start time |
252 // to help application startup time & improve playback start time |
217 // |
253 // |
218 mPlaybackWrapper->lateInit(); |
254 createPlaybackView(); |
219 |
255 |
220 if ( ! mPlaybackViewPlugin ) |
256 if(!mFileDetailsViewPlugin) |
221 { |
|
222 loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView ); |
|
223 } |
|
224 |
|
225 // details view need not be created for playback via serviceFW |
|
226 if ( ! mIsPlayService && |
|
227 ! mFileDetailsViewPlugin ) |
|
228 { |
257 { |
229 loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView ); |
258 loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView ); |
|
259 } |
|
260 if(!mCollectionViewPlugin) |
|
261 { |
|
262 loadPluginAndCreateView( MpxHbVideoCommon::CollectionView ); |
230 } |
263 } |
231 } |
264 } |
232 |
265 |
233 |
266 |
234 // ------------------------------------------------------------------------------------------------- |
267 // ------------------------------------------------------------------------------------------------- |
418 // ------------------------------------------------------------------------------------------------- |
451 // ------------------------------------------------------------------------------------------------- |
419 // |
452 // |
420 void QVideoPlayerEngine::handleQuit() |
453 void QVideoPlayerEngine::handleQuit() |
421 { |
454 { |
422 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleQuit()")); |
455 MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleQuit()")); |
423 |
456 |
|
457 if(!mIsService) |
|
458 { |
|
459 VideoActivityState &localActivity(VideoActivityState::instance()); |
|
460 |
|
461 QVariant data = QVariant(); |
|
462 HbActivityManager *actManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
463 |
|
464 // |
|
465 // get and save recent view type: either playback or collection view plugins are currently used. |
|
466 // activity will not be saved from the details plugin |
|
467 // |
|
468 int viewType = MpxHbVideoCommon::CollectionView; |
|
469 if(mCurrentViewPlugin == mPlaybackViewPlugin) |
|
470 { |
|
471 viewType = MpxHbVideoCommon::PlaybackView; |
|
472 } |
|
473 data = viewType; |
|
474 localActivity.setActivityData(data, VideoActivityData::KEY_VIEWPLUGIN_TYPE); |
|
475 |
|
476 // |
|
477 // deactivate is the final point for current plugin to save it's activity data into |
|
478 // VideoActivityState before they are saved to to activity manager |
|
479 // |
|
480 mCurrentViewPlugin->deactivateView(); |
|
481 |
|
482 // save data to activity manager |
|
483 actManager->addActivity(ACTIVITY_VIDEOPLAYER_MAINVIEW, |
|
484 localActivity.getActivityData(), |
|
485 QVariantHash()); |
|
486 } |
|
487 |
424 delete this; |
488 delete this; |
425 } |
489 } |
426 |
490 |
427 |
491 |
428 // ------------------------------------------------------------------------------------------------- |
492 // ------------------------------------------------------------------------------------------------- |