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 Video base playback view
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
41
|
18 |
// Version : %version: da1mmcf#43 %
|
30
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
// Include Files
|
|
23 |
|
|
24 |
|
|
25 |
|
34
|
26 |
#include <QTimer>
|
|
27 |
#include <QGraphicsSceneEvent>
|
30
|
28 |
|
|
29 |
#include <hbmenu.h>
|
|
30 |
#include <hbaction.h>
|
|
31 |
#include <hbinstance.h>
|
|
32 |
#include <hbnotificationdialog.h>
|
35
|
33 |
#include <hblabel.h>
|
40
|
34 |
#include <hbtapgesture.h>
|
|
35 |
#include <hbpangesture.h>
|
30
|
36 |
|
|
37 |
#include <textresolver.h>
|
|
38 |
#include <mmf/common/mmferrors.h>
|
34
|
39 |
#include <DRMHelper.h>
|
30
|
40 |
|
|
41 |
#include <mpxvideoplaybackdefs.h>
|
|
42 |
#include <mpxplaybackcommanddefs.h>
|
41
|
43 |
#include <mpxhbvideocommondefs.h>
|
30
|
44 |
|
|
45 |
#include "mpxvideo_debug.h"
|
|
46 |
#include "mpxvideoviewwrapper.h"
|
|
47 |
#include "mpxvideoplaybackuids.hrh"
|
|
48 |
#include "hbvideobaseplaybackview.h"
|
41
|
49 |
#include "videoactivitystate.h"
|
|
50 |
#include "mpxvideoplaybackviewfiledetails.h"
|
30
|
51 |
#include "mpxcommonvideoplaybackview.hrh"
|
|
52 |
|
|
53 |
|
|
54 |
// Member Functions
|
|
55 |
|
|
56 |
// -------------------------------------------------------------------------------------------------
|
|
57 |
// HbVideoBasePlaybackView::HbVideoBasePlaybackView()
|
|
58 |
// -------------------------------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
HbVideoBasePlaybackView::HbVideoBasePlaybackView()
|
|
61 |
: mVideoMpxWrapper( NULL )
|
|
62 |
, mTimerForClosingView( NULL )
|
|
63 |
, mActivated( false )
|
41
|
64 |
, mStayPaused ( false )
|
30
|
65 |
{
|
|
66 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::HbVideoBasePlaybackView()"));
|
|
67 |
}
|
|
68 |
|
|
69 |
// -------------------------------------------------------------------------------------------------
|
|
70 |
// HbVideoBasePlaybackView::initializeVideoPlaybackView()
|
|
71 |
// -------------------------------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
void HbVideoBasePlaybackView::initializeVideoPlaybackView()
|
|
74 |
{
|
40
|
75 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::initializeVideoPlaybackView()"));
|
|
76 |
|
30
|
77 |
//
|
|
78 |
// Need to set to control full screen including status pane area
|
|
79 |
//
|
|
80 |
setContentFullScreen();
|
|
81 |
|
|
82 |
mTimerForClosingView = new QTimer();
|
|
83 |
mTimerForClosingView->setSingleShot( true );
|
|
84 |
mTimerForClosingView->setInterval( 10 );
|
|
85 |
connect( mTimerForClosingView, SIGNAL( timeout() ), this, SIGNAL( activatePreviousView() ) );
|
41
|
86 |
|
|
87 |
//
|
|
88 |
// Read activity data ...
|
|
89 |
// If last playback was forced to terminate due to low memory (GOOM, etc.)
|
|
90 |
// then the clip needs to be restored to the last played position
|
|
91 |
// and the state needs to be paused, since forced termination can only occur for
|
|
92 |
// background apps - so if this happened Video Player must have been in background
|
|
93 |
// which implies paused state
|
|
94 |
//
|
|
95 |
int lastViewType = VideoActivityState::instance().getActivityData(KEY_VIEWPLUGIN_TYPE).toInt();
|
|
96 |
if ( lastViewType == MpxHbVideoCommon::PlaybackView )
|
|
97 |
{
|
|
98 |
QVariant data = VideoActivityState::instance().getActivityData(KEY_LAST_PLAY_POSITION_ID);
|
|
99 |
mLastPlayPosition = data.toInt();
|
|
100 |
|
|
101 |
mStayPaused = true;
|
|
102 |
}
|
30
|
103 |
}
|
|
104 |
|
|
105 |
// -------------------------------------------------------------------------------------------------
|
|
106 |
// HbVideoBasePlaybackView::~HbVideoBasePlaybackView()
|
|
107 |
// -------------------------------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
HbVideoBasePlaybackView::~HbVideoBasePlaybackView()
|
|
110 |
{
|
|
111 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::~HbVideoBasePlaybackView()"));
|
|
112 |
|
|
113 |
if ( mTimerForClosingView )
|
40
|
114 |
{
|
37
|
115 |
disconnect( mTimerForClosingView, SIGNAL( timeout() ), this, SIGNAL( activatePreviousView() ) );
|
40
|
116 |
|
30
|
117 |
if ( mTimerForClosingView->isActive() )
|
|
118 |
{
|
|
119 |
mTimerForClosingView->stop();
|
|
120 |
}
|
|
121 |
|
|
122 |
delete mTimerForClosingView;
|
|
123 |
mTimerForClosingView = NULL;
|
|
124 |
}
|
|
125 |
|
37
|
126 |
if ( mVideoMpxWrapper )
|
|
127 |
{
|
|
128 |
delete mVideoMpxWrapper;
|
|
129 |
mVideoMpxWrapper = NULL;
|
|
130 |
}
|
30
|
131 |
|
|
132 |
setParentItem( 0 );
|
|
133 |
}
|
|
134 |
|
|
135 |
// -------------------------------------------------------------------------------------------------
|
|
136 |
// HbVideoBasePlaybackView::handleActivateView()
|
|
137 |
// -------------------------------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
void HbVideoBasePlaybackView::handleActivateView()
|
|
140 |
{
|
|
141 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleActivateView()"));
|
38
|
142 |
|
41
|
143 |
MPX_TRAPD( err, mVideoMpxWrapper = CMPXVideoViewWrapper::NewL( this ) );
|
38
|
144 |
|
|
145 |
QCoreApplication::instance()->installEventFilter( this );
|
|
146 |
|
35
|
147 |
//
|
|
148 |
// Request the needed Media from the Playback Plugin
|
|
149 |
//
|
41
|
150 |
MPX_TRAP( err, mVideoMpxWrapper->RequestMediaL() );
|
40
|
151 |
|
30
|
152 |
menu()->close();
|
|
153 |
|
|
154 |
//
|
|
155 |
// Landscape orientation
|
40
|
156 |
// Workaround: Disable orientation transition effect
|
38
|
157 |
// since orbit couldn't emit the orientationChanged signal with transition effect
|
40
|
158 |
//
|
|
159 |
hbInstance->allMainWindows()[0]->setOrientation( Qt::Horizontal, false );
|
30
|
160 |
|
40
|
161 |
mActivated = true;
|
30
|
162 |
}
|
|
163 |
|
|
164 |
// -------------------------------------------------------------------------------------------------
|
|
165 |
// HbVideoBasePlaybackView::handleDeactivateView()
|
|
166 |
// -------------------------------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void HbVideoBasePlaybackView::handleDeactivateView()
|
|
169 |
{
|
|
170 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleDeactivateView()"));
|
|
171 |
|
41
|
172 |
saveActivityData();
|
|
173 |
|
40
|
174 |
mActivated = false;
|
|
175 |
|
38
|
176 |
QCoreApplication::instance()->removeEventFilter( this );
|
|
177 |
|
40
|
178 |
//
|
30
|
179 |
// Close the playback plugin to release all references to previous clip
|
|
180 |
//
|
|
181 |
MPX_TRAPD( err, mVideoMpxWrapper->HandleCommandL( EMPXPbvCmdClose ) );
|
|
182 |
|
|
183 |
if ( mVideoMpxWrapper )
|
|
184 |
{
|
|
185 |
delete mVideoMpxWrapper;
|
|
186 |
mVideoMpxWrapper = NULL;
|
|
187 |
}
|
|
188 |
|
|
189 |
//
|
|
190 |
// go back to device orientation
|
|
191 |
//
|
|
192 |
//hbInstance->allMainWindows()[0]->unsetOrientation();
|
|
193 |
}
|
|
194 |
|
|
195 |
// -------------------------------------------------------------------------------------------------
|
41
|
196 |
// HbVideoBasePlaybackView::saveActivityData()
|
|
197 |
// -------------------------------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
void HbVideoBasePlaybackView::saveActivityData()
|
|
200 |
{
|
|
201 |
MPX_DEBUG( _L("HbVideoBasePlaybackView::saveActivityData()") );
|
|
202 |
|
|
203 |
// save the activity data
|
|
204 |
QVariant data = QString( mVideoMpxWrapper->iFileDetails->mClipName );
|
|
205 |
VideoActivityState::instance().setActivityData(data, KEY_LAST_PLAYED_CLIP);
|
|
206 |
|
|
207 |
data = int( mVideoMpxWrapper->iPlayPosition );
|
|
208 |
VideoActivityState::instance().setActivityData(data, KEY_LAST_PLAY_POSITION_ID);
|
|
209 |
|
|
210 |
data = bool( mVideoMpxWrapper->iFileDetails->mPlaybackMode == EMPXVideoLocal );
|
|
211 |
VideoActivityState::instance().setActivityData(data, KEY_LAST_LOCAL_PLAYBACK);
|
|
212 |
}
|
|
213 |
|
|
214 |
// -------------------------------------------------------------------------------------------------
|
30
|
215 |
// HbVideoBasePlaybackView::handleClosePlaybackView()
|
|
216 |
// -------------------------------------------------------------------------------------------------
|
|
217 |
//
|
|
218 |
void HbVideoBasePlaybackView::handleClosePlaybackView()
|
|
219 |
{
|
|
220 |
MPX_DEBUG(
|
|
221 |
_L("HbVideoBasePlaybackView::handleClosePlaybackView()") );
|
|
222 |
|
36
|
223 |
if ( mVideoMpxWrapper && mVideoMpxWrapper->IsMultiItemPlaylist() )
|
30
|
224 |
{
|
|
225 |
TRAP_IGNORE( mVideoMpxWrapper->HandleCommandL( EMPXPbvCmdNextListItem ) );
|
|
226 |
}
|
|
227 |
else
|
|
228 |
{
|
|
229 |
closePlaybackView();
|
|
230 |
}
|
|
231 |
}
|
|
232 |
|
|
233 |
// -------------------------------------------------------------------------------------------------
|
|
234 |
// HbVideoBasePlaybackView::handlePluginError()
|
|
235 |
// -------------------------------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
void HbVideoBasePlaybackView::handlePluginError( int aError )
|
|
238 |
{
|
|
239 |
MPX_DEBUG(
|
|
240 |
_L("HbVideoBasePlaybackView::handlePluginError() aError = %d"), aError );
|
|
241 |
|
|
242 |
switch ( aError )
|
|
243 |
{
|
|
244 |
case KErrCancel:
|
|
245 |
{
|
|
246 |
handleClosePlaybackView();
|
|
247 |
break;
|
|
248 |
}
|
|
249 |
case KErrMMDRMNotAuthorized:
|
|
250 |
case KErrCANoRights:
|
|
251 |
case KErrCANoPermission:
|
|
252 |
{
|
36
|
253 |
showDialog( hbTrId( "txt_videos_info_license_has_expired_or_it_is_missi" ) );
|
30
|
254 |
break;
|
|
255 |
}
|
|
256 |
case KMPXVideoCallOngoingError:
|
|
257 |
{
|
36
|
258 |
showDialog( hbTrId( "txt_videos_info_video_playback_is_not_allowed_duri" ), false );
|
30
|
259 |
break;
|
|
260 |
}
|
|
261 |
default:
|
|
262 |
{
|
40
|
263 |
TRAP_IGNORE(
|
30
|
264 |
|
|
265 |
//
|
|
266 |
// TextResolver instance for error resolving.
|
|
267 |
//
|
|
268 |
CTextResolver* textresolver = CTextResolver::NewLC();
|
40
|
269 |
|
30
|
270 |
//
|
|
271 |
// Resolve the error text
|
|
272 |
//
|
|
273 |
TPtrC text;
|
|
274 |
text.Set( textresolver->ResolveErrorString( aError ) );
|
40
|
275 |
|
30
|
276 |
//
|
|
277 |
// convert to QString
|
|
278 |
//
|
|
279 |
const QString qString( (QChar*)text.Ptr(), text.Length() );
|
40
|
280 |
|
35
|
281 |
//
|
|
282 |
// clean up textresolver
|
|
283 |
//
|
30
|
284 |
CleanupStack::PopAndDestroy( textresolver );
|
35
|
285 |
|
|
286 |
//
|
|
287 |
// display error and close playback view
|
|
288 |
//
|
|
289 |
showDialog( qString );
|
30
|
290 |
);
|
|
291 |
}
|
|
292 |
}
|
|
293 |
}
|
|
294 |
|
|
295 |
// -------------------------------------------------------------------------------------------------
|
35
|
296 |
// HbVideoBasePlaybackView::showDialog
|
30
|
297 |
// -------------------------------------------------------------------------------------------------
|
|
298 |
//
|
35
|
299 |
void HbVideoBasePlaybackView::showDialog( const QString& qString, bool closeView )
|
30
|
300 |
{
|
35
|
301 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::showDialog( %s, %d )"), qString.data(), closeView );
|
40
|
302 |
|
35
|
303 |
//
|
40
|
304 |
// create pop-up dialog for error notes,
|
35
|
305 |
// set its position to the middle of the screen
|
|
306 |
// and make sure pop-up dialog gets deleted on close.
|
|
307 |
//
|
|
308 |
QRectF screenRect = hbInstance->allMainWindows()[0]->rect();
|
40
|
309 |
HbNotificationDialog* dlg = new HbNotificationDialog();
|
35
|
310 |
dlg->setAttribute( Qt::WA_DeleteOnClose );
|
40
|
311 |
dlg->setMinimumSize( QSizeF(200, 100) );
|
|
312 |
dlg->setPreferredPos( QPointF( screenRect.height()/2, screenRect.width()/2 ),
|
35
|
313 |
HbPopup::Center );
|
40
|
314 |
|
35
|
315 |
if ( closeView )
|
|
316 |
{
|
|
317 |
//
|
|
318 |
// connect aboutToClose() signal to handleClosePopupDialog() slot so that
|
|
319 |
// when pop-up dialog is closed, playback view is closed also
|
|
320 |
//
|
40
|
321 |
connect( dlg, SIGNAL( aboutToClose() ), this, SLOT( handleClosePopupDialog() ) );
|
35
|
322 |
}
|
40
|
323 |
|
35
|
324 |
//
|
|
325 |
// convert string to label so text alignment can be set
|
|
326 |
//
|
|
327 |
HbLabel *label = new HbLabel( qString );
|
|
328 |
label->setAlignment( Qt::AlignCenter );
|
40
|
329 |
|
35
|
330 |
//
|
|
331 |
// set label as content widget and show pop-up dialog
|
|
332 |
//
|
|
333 |
dlg->setContentWidget( label );
|
40
|
334 |
dlg->show();
|
30
|
335 |
}
|
|
336 |
|
|
337 |
// -------------------------------------------------------------------------------------------------
|
|
338 |
// HbVideoBasePlaybackView::doClosePlayer
|
|
339 |
// -------------------------------------------------------------------------------------------------
|
|
340 |
//
|
|
341 |
void HbVideoBasePlaybackView::doClosePlayer()
|
|
342 |
{
|
|
343 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::doClosePlayer()"));
|
|
344 |
|
|
345 |
handleDeactivateView();
|
|
346 |
|
|
347 |
qApp->quit();
|
|
348 |
}
|
|
349 |
|
|
350 |
// -------------------------------------------------------------------------------------------------
|
|
351 |
// HbVideoBasePlaybackView::issuePlayCommand
|
|
352 |
// -------------------------------------------------------------------------------------------------
|
|
353 |
//
|
|
354 |
void HbVideoBasePlaybackView::issuePlayCommand()
|
|
355 |
{
|
|
356 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::issuePlayCommand()"));
|
38
|
357 |
|
|
358 |
int err = KErrNone;
|
|
359 |
|
|
360 |
TRAP( err, mVideoMpxWrapper->CreateGeneralPlaybackCommandL( EPbCmdPlay ));
|
|
361 |
|
30
|
362 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::issuePlayCommand() error = %d"), err);
|
|
363 |
}
|
|
364 |
|
|
365 |
// -------------------------------------------------------------------------------------------------
|
|
366 |
// HbVideoBasePlaybackView::retrievePdlInformation
|
|
367 |
// -------------------------------------------------------------------------------------------------
|
|
368 |
//
|
|
369 |
void HbVideoBasePlaybackView::retrievePdlInformation()
|
|
370 |
{
|
|
371 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::retrievePdlInformation()"));
|
|
372 |
}
|
|
373 |
|
|
374 |
// -------------------------------------------------------------------------------------------------
|
|
375 |
// HbVideoBasePlaybackView::handleBufferingState
|
|
376 |
// -------------------------------------------------------------------------------------------------
|
|
377 |
//
|
|
378 |
void HbVideoBasePlaybackView::handleBufferingState()
|
|
379 |
{
|
|
380 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::handleBufferingState()"));
|
|
381 |
}
|
|
382 |
|
|
383 |
// -------------------------------------------------------------------------------------------------
|
|
384 |
// HbVideoBasePlaybackView::closePlaybackView()
|
|
385 |
// -------------------------------------------------------------------------------------------------
|
|
386 |
//
|
|
387 |
void HbVideoBasePlaybackView::closePlaybackView()
|
|
388 |
{
|
|
389 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::closePlaybackView()"));
|
|
390 |
|
40
|
391 |
mTimerForClosingView->start( 0 );
|
30
|
392 |
}
|
|
393 |
|
38
|
394 |
// ---------------------------------------------------------------------------
|
|
395 |
// HbVideoBasePlaybackView::eventFilter
|
|
396 |
// ---------------------------------------------------------------------------
|
30
|
397 |
//
|
38
|
398 |
bool HbVideoBasePlaybackView::eventFilter( QObject *object, QEvent *event )
|
30
|
399 |
{
|
38
|
400 |
Q_UNUSED( object );
|
30
|
401 |
|
38
|
402 |
switch ( event->type() )
|
30
|
403 |
{
|
38
|
404 |
case QEvent::ApplicationActivate:
|
|
405 |
{
|
|
406 |
if ( mActivated )
|
|
407 |
{
|
|
408 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::eventFilter foreground()") );
|
|
409 |
TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( true ) );
|
|
410 |
}
|
|
411 |
break;
|
|
412 |
}
|
|
413 |
case QEvent::ApplicationDeactivate:
|
|
414 |
{
|
|
415 |
if ( mActivated )
|
|
416 |
{
|
|
417 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::eventFilter background()") );
|
|
418 |
TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( false ) );
|
|
419 |
}
|
|
420 |
break;
|
|
421 |
}
|
30
|
422 |
}
|
|
423 |
|
38
|
424 |
return QObject::eventFilter( object, event );
|
30
|
425 |
}
|
|
426 |
|
|
427 |
// -------------------------------------------------------------------------------------------------
|
|
428 |
// HbVideoBasePlaybackView::getWindow()
|
|
429 |
// -------------------------------------------------------------------------------------------------
|
|
430 |
//
|
|
431 |
RWindow *HbVideoBasePlaybackView::getWindow()
|
|
432 |
{
|
|
433 |
return static_cast<RWindow*>( hbInstance->allMainWindows()[0]->effectiveWinId()->DrawableWindow() );
|
|
434 |
}
|
|
435 |
|
|
436 |
// -------------------------------------------------------------------------------------------------
|
35
|
437 |
// HbVideoBasePlaybackView::handleClosePopupDialog()
|
|
438 |
// -------------------------------------------------------------------------------------------------
|
|
439 |
//
|
|
440 |
void HbVideoBasePlaybackView::handleClosePopupDialog()
|
|
441 |
{
|
|
442 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::handleClosePopupDialog()") );
|
|
443 |
|
|
444 |
handleClosePlaybackView();
|
|
445 |
}
|
|
446 |
|
40
|
447 |
// -------------------------------------------------------------------------------------------------
|
|
448 |
// HbVideoBasePlaybackView::gestureEvent()
|
|
449 |
// -------------------------------------------------------------------------------------------------
|
|
450 |
//
|
|
451 |
void HbVideoBasePlaybackView::gestureEvent( QGestureEvent* event )
|
|
452 |
{
|
|
453 |
if ( HbTapGesture * gesture = static_cast<HbTapGesture *>( event->gesture( Qt::TapGesture ) ) )
|
|
454 |
{
|
|
455 |
if ( gesture->state() == Qt::GestureFinished && mActivated )
|
|
456 |
{
|
|
457 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::gestureEvent() tapGesture finished") );
|
|
458 |
|
|
459 |
emit tappedOnScreen();
|
|
460 |
}
|
|
461 |
}
|
|
462 |
else if ( HbPanGesture* gesture = static_cast<HbPanGesture*>( event->gesture( Qt::PanGesture ) ) )
|
|
463 |
{
|
|
464 |
if ( gesture->state() == Qt::GestureFinished && mActivated )
|
|
465 |
{
|
|
466 |
QPointF delta( gesture->sceneDelta() );
|
|
467 |
|
|
468 |
if ( delta.x() > 0 )
|
|
469 |
{
|
|
470 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::gestureEvent() right") );
|
|
471 |
|
|
472 |
emit pannedToRight();
|
|
473 |
}
|
|
474 |
else
|
|
475 |
{
|
|
476 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::gestureEvent() left") );
|
|
477 |
|
|
478 |
emit pannedToLeft();
|
|
479 |
}
|
|
480 |
}
|
|
481 |
}
|
|
482 |
}
|
|
483 |
|
30
|
484 |
// EOF
|