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 |
|
35
|
18 |
// Version : %version: da1mmcf#32 %
|
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 <hbgesture.h>
|
|
32 |
#include <hbinstance.h>
|
|
33 |
#include <hbnotificationdialog.h>
|
35
|
34 |
#include <hblabel.h>
|
30
|
35 |
|
|
36 |
#include <textresolver.h>
|
|
37 |
#include <mmf/common/mmferrors.h>
|
34
|
38 |
#include <DRMHelper.h>
|
30
|
39 |
|
|
40 |
#include <mpxvideoplaybackdefs.h>
|
|
41 |
#include <mpxplaybackcommanddefs.h>
|
|
42 |
|
|
43 |
#include "mpxvideo_debug.h"
|
|
44 |
#include "mpxvideoviewwrapper.h"
|
|
45 |
#include "mpxvideoplaybackuids.hrh"
|
|
46 |
#include "hbvideobaseplaybackview.h"
|
|
47 |
#include "mpxcommonvideoplaybackview.hrh"
|
|
48 |
|
|
49 |
|
|
50 |
// Member Functions
|
|
51 |
|
|
52 |
// -------------------------------------------------------------------------------------------------
|
|
53 |
// HbVideoBasePlaybackView::HbVideoBasePlaybackView()
|
|
54 |
// -------------------------------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
HbVideoBasePlaybackView::HbVideoBasePlaybackView()
|
|
57 |
: mVideoMpxWrapper( NULL )
|
|
58 |
, mTimerForClosingView( NULL )
|
|
59 |
, mActivated( false )
|
|
60 |
{
|
|
61 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::HbVideoBasePlaybackView()"));
|
|
62 |
}
|
|
63 |
|
|
64 |
// -------------------------------------------------------------------------------------------------
|
|
65 |
// HbVideoBasePlaybackView::initializeVideoPlaybackView()
|
|
66 |
// -------------------------------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
void HbVideoBasePlaybackView::initializeVideoPlaybackView()
|
|
69 |
{
|
35
|
70 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::initializeVideoPlaybackView()"));
|
|
71 |
|
30
|
72 |
//
|
|
73 |
// Need to set to control full screen including status pane area
|
|
74 |
//
|
|
75 |
setContentFullScreen();
|
|
76 |
|
|
77 |
mTimerForClosingView = new QTimer();
|
|
78 |
mTimerForClosingView->setSingleShot( true );
|
|
79 |
mTimerForClosingView->setInterval( 10 );
|
|
80 |
connect( mTimerForClosingView, SIGNAL( timeout() ), this, SIGNAL( activatePreviousView() ) );
|
|
81 |
}
|
|
82 |
|
|
83 |
// -------------------------------------------------------------------------------------------------
|
|
84 |
// HbVideoBasePlaybackView::~HbVideoBasePlaybackView()
|
|
85 |
// -------------------------------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
HbVideoBasePlaybackView::~HbVideoBasePlaybackView()
|
|
88 |
{
|
|
89 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::~HbVideoBasePlaybackView()"));
|
|
90 |
|
|
91 |
disconnect( mTimerForClosingView, SIGNAL( timeout() ), this, SIGNAL( activatePreviousView() ) );
|
|
92 |
|
|
93 |
if ( mTimerForClosingView )
|
|
94 |
{
|
|
95 |
if ( mTimerForClosingView->isActive() )
|
|
96 |
{
|
|
97 |
mTimerForClosingView->stop();
|
|
98 |
}
|
|
99 |
|
|
100 |
delete mTimerForClosingView;
|
|
101 |
mTimerForClosingView = NULL;
|
|
102 |
}
|
|
103 |
|
|
104 |
|
|
105 |
setParentItem( 0 );
|
|
106 |
}
|
|
107 |
|
|
108 |
// -------------------------------------------------------------------------------------------------
|
|
109 |
// HbVideoBasePlaybackView::handleActivateView()
|
|
110 |
// -------------------------------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
void HbVideoBasePlaybackView::handleActivateView()
|
|
113 |
{
|
|
114 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleActivateView()"));
|
35
|
115 |
|
|
116 |
TRAP_IGNORE( mVideoMpxWrapper = CMPXVideoViewWrapper::NewL( this ) );
|
|
117 |
|
|
118 |
//
|
|
119 |
// Request the needed Media from the Playback Plugin
|
|
120 |
//
|
|
121 |
TRAP_IGNORE( mVideoMpxWrapper->RequestMediaL() );
|
|
122 |
|
30
|
123 |
menu()->close();
|
|
124 |
|
|
125 |
hideItems( Hb::AllItems );
|
|
126 |
|
|
127 |
//
|
|
128 |
// Landscape orientation
|
|
129 |
//
|
35
|
130 |
hbInstance->allMainWindows()[0]->setOrientation( Qt::Horizontal );
|
30
|
131 |
|
35
|
132 |
mActivated = true;
|
|
133 |
|
30
|
134 |
}
|
|
135 |
|
|
136 |
// -------------------------------------------------------------------------------------------------
|
|
137 |
// HbVideoBasePlaybackView::handleDeactivateView()
|
|
138 |
// -------------------------------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
void HbVideoBasePlaybackView::handleDeactivateView()
|
|
141 |
{
|
|
142 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::handleDeactivateView()"));
|
|
143 |
|
|
144 |
mActivated = false;
|
|
145 |
|
|
146 |
//
|
|
147 |
// Close the playback plugin to release all references to previous clip
|
|
148 |
//
|
|
149 |
MPX_TRAPD( err, mVideoMpxWrapper->HandleCommandL( EMPXPbvCmdClose ) );
|
|
150 |
|
|
151 |
if ( mVideoMpxWrapper )
|
|
152 |
{
|
|
153 |
delete mVideoMpxWrapper;
|
|
154 |
mVideoMpxWrapper = NULL;
|
|
155 |
}
|
|
156 |
|
|
157 |
//
|
|
158 |
// go back to device orientation
|
|
159 |
//
|
|
160 |
//hbInstance->allMainWindows()[0]->unsetOrientation();
|
|
161 |
|
|
162 |
showItems( Hb::AllItems );
|
|
163 |
}
|
|
164 |
|
|
165 |
// -------------------------------------------------------------------------------------------------
|
|
166 |
// HbVideoBasePlaybackView::handleClosePlaybackView()
|
|
167 |
// -------------------------------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
void HbVideoBasePlaybackView::handleClosePlaybackView()
|
|
170 |
{
|
|
171 |
MPX_DEBUG(
|
|
172 |
_L("HbVideoBasePlaybackView::handleClosePlaybackView()") );
|
|
173 |
|
|
174 |
if ( mVideoMpxWrapper->IsMultiItemPlaylist() )
|
|
175 |
{
|
|
176 |
TRAP_IGNORE( mVideoMpxWrapper->HandleCommandL( EMPXPbvCmdNextListItem ) );
|
|
177 |
}
|
|
178 |
else
|
|
179 |
{
|
|
180 |
closePlaybackView();
|
|
181 |
}
|
|
182 |
}
|
|
183 |
|
|
184 |
// -------------------------------------------------------------------------------------------------
|
|
185 |
// HbVideoBasePlaybackView::handlePluginError()
|
|
186 |
// -------------------------------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
void HbVideoBasePlaybackView::handlePluginError( int aError )
|
|
189 |
{
|
|
190 |
MPX_DEBUG(
|
|
191 |
_L("HbVideoBasePlaybackView::handlePluginError() aError = %d"), aError );
|
|
192 |
|
|
193 |
switch ( aError )
|
|
194 |
{
|
|
195 |
case KErrCancel:
|
|
196 |
{
|
|
197 |
handleClosePlaybackView();
|
|
198 |
break;
|
|
199 |
}
|
|
200 |
case KErrMMDRMNotAuthorized:
|
|
201 |
case KErrCANoRights:
|
|
202 |
case KErrCANoPermission:
|
|
203 |
{
|
|
204 |
const QString qString = "License has expired or it is missing";
|
35
|
205 |
showDialog( qString );
|
30
|
206 |
break;
|
|
207 |
}
|
|
208 |
case KMPXVideoCallOngoingError:
|
|
209 |
{
|
35
|
210 |
const QString qString = "Video playback is not allowed during video call";
|
|
211 |
showDialog( qString, false );
|
30
|
212 |
break;
|
|
213 |
}
|
|
214 |
case KMPXVideoTvOutPlaybackNotAllowed:
|
|
215 |
{
|
|
216 |
const QString qString = "Protected clip, can not be played through TV-Out";
|
35
|
217 |
showDialog( qString, false );
|
30
|
218 |
break;
|
|
219 |
}
|
|
220 |
case KMPXVideoTvOutPlaybackNotAllowedClose:
|
|
221 |
{
|
|
222 |
const QString qString = "Protected clip, can not be played through TV-Out";
|
35
|
223 |
showDialog( qString );
|
30
|
224 |
break;
|
|
225 |
}
|
|
226 |
default:
|
|
227 |
{
|
|
228 |
TRAP_IGNORE(
|
|
229 |
|
|
230 |
//
|
|
231 |
// TextResolver instance for error resolving.
|
|
232 |
//
|
|
233 |
CTextResolver* textresolver = CTextResolver::NewLC();
|
|
234 |
|
|
235 |
//
|
|
236 |
// Resolve the error text
|
|
237 |
//
|
|
238 |
TPtrC text;
|
|
239 |
text.Set( textresolver->ResolveErrorString( aError ) );
|
|
240 |
|
|
241 |
//
|
|
242 |
// convert to QString
|
|
243 |
//
|
|
244 |
const QString qString( (QChar*)text.Ptr(), text.Length() );
|
35
|
245 |
|
|
246 |
//
|
|
247 |
// clean up textresolver
|
|
248 |
//
|
30
|
249 |
CleanupStack::PopAndDestroy( textresolver );
|
35
|
250 |
|
|
251 |
//
|
|
252 |
// display error and close playback view
|
|
253 |
//
|
|
254 |
showDialog( qString );
|
30
|
255 |
|
|
256 |
);
|
|
257 |
}
|
|
258 |
}
|
|
259 |
}
|
|
260 |
|
|
261 |
// -------------------------------------------------------------------------------------------------
|
35
|
262 |
// HbVideoBasePlaybackView::showDialog
|
30
|
263 |
// -------------------------------------------------------------------------------------------------
|
|
264 |
//
|
35
|
265 |
void HbVideoBasePlaybackView::showDialog( const QString& qString, bool closeView )
|
30
|
266 |
{
|
35
|
267 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::showDialog( %s, %d )"), qString.data(), closeView );
|
|
268 |
|
|
269 |
//
|
|
270 |
// create pop-up dialog for error notes,
|
|
271 |
// set its position to the middle of the screen
|
|
272 |
// and make sure pop-up dialog gets deleted on close.
|
|
273 |
//
|
|
274 |
QRectF screenRect = hbInstance->allMainWindows()[0]->rect();
|
|
275 |
HbNotificationDialog* dlg = new HbNotificationDialog();
|
|
276 |
dlg->setAttribute( Qt::WA_DeleteOnClose );
|
|
277 |
dlg->setMinimumSize( QSizeF(200, 100) );
|
|
278 |
dlg->setPreferredPos( QPointF( screenRect.height()/2, screenRect.width()/2 ),
|
|
279 |
HbPopup::Center );
|
|
280 |
|
|
281 |
if ( closeView )
|
|
282 |
{
|
|
283 |
//
|
|
284 |
// connect aboutToClose() signal to handleClosePopupDialog() slot so that
|
|
285 |
// when pop-up dialog is closed, playback view is closed also
|
|
286 |
//
|
|
287 |
connect( dlg, SIGNAL( aboutToClose() ), this, SLOT( handleClosePopupDialog() ) );
|
|
288 |
}
|
|
289 |
|
|
290 |
//
|
|
291 |
// convert string to label so text alignment can be set
|
|
292 |
//
|
|
293 |
HbLabel *label = new HbLabel( qString );
|
|
294 |
label->setAlignment( Qt::AlignCenter );
|
|
295 |
|
|
296 |
//
|
|
297 |
// set label as content widget and show pop-up dialog
|
|
298 |
//
|
|
299 |
dlg->setContentWidget( label );
|
|
300 |
dlg->show();
|
30
|
301 |
}
|
|
302 |
|
|
303 |
// -------------------------------------------------------------------------------------------------
|
|
304 |
// HbVideoBasePlaybackView::doClosePlayer
|
|
305 |
// -------------------------------------------------------------------------------------------------
|
|
306 |
//
|
|
307 |
void HbVideoBasePlaybackView::doClosePlayer()
|
|
308 |
{
|
|
309 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::doClosePlayer()"));
|
|
310 |
|
|
311 |
handleDeactivateView();
|
|
312 |
|
|
313 |
qApp->quit();
|
|
314 |
}
|
|
315 |
|
|
316 |
// -------------------------------------------------------------------------------------------------
|
|
317 |
// HbVideoBasePlaybackView::issuePlayCommand
|
|
318 |
// -------------------------------------------------------------------------------------------------
|
|
319 |
//
|
|
320 |
void HbVideoBasePlaybackView::issuePlayCommand()
|
|
321 |
{
|
|
322 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::issuePlayCommand()"));
|
|
323 |
TRAPD(err, mVideoMpxWrapper->CreateGeneralPlaybackCommandL( EPbCmdPlay ));
|
|
324 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::issuePlayCommand() error = %d"), err);
|
|
325 |
}
|
|
326 |
|
|
327 |
// -------------------------------------------------------------------------------------------------
|
|
328 |
// HbVideoBasePlaybackView::retrievePdlInformation
|
|
329 |
// -------------------------------------------------------------------------------------------------
|
|
330 |
//
|
|
331 |
void HbVideoBasePlaybackView::retrievePdlInformation()
|
|
332 |
{
|
|
333 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::retrievePdlInformation()"));
|
|
334 |
}
|
|
335 |
|
|
336 |
// -------------------------------------------------------------------------------------------------
|
|
337 |
// HbVideoBasePlaybackView::handleBufferingState
|
|
338 |
// -------------------------------------------------------------------------------------------------
|
|
339 |
//
|
|
340 |
void HbVideoBasePlaybackView::handleBufferingState()
|
|
341 |
{
|
|
342 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::handleBufferingState()"));
|
|
343 |
|
|
344 |
}
|
|
345 |
|
|
346 |
// -------------------------------------------------------------------------------------------------
|
|
347 |
// HbVideoBasePlaybackView::closePlaybackView()
|
|
348 |
// -------------------------------------------------------------------------------------------------
|
|
349 |
//
|
|
350 |
void HbVideoBasePlaybackView::closePlaybackView()
|
|
351 |
{
|
|
352 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::closePlaybackView()"));
|
|
353 |
|
|
354 |
mTimerForClosingView->start( 0 );
|
|
355 |
}
|
|
356 |
|
|
357 |
// -------------------------------------------------------------------------------------------------
|
|
358 |
// HbVideoBasePlaybackView::event()
|
|
359 |
// -------------------------------------------------------------------------------------------------
|
|
360 |
//
|
|
361 |
bool HbVideoBasePlaybackView::event( QEvent *event )
|
|
362 |
{
|
|
363 |
bool consumed = false;
|
|
364 |
|
|
365 |
if ( event->type() == QEvent::WindowActivate && mActivated )
|
|
366 |
{
|
|
367 |
TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( true ) );
|
|
368 |
}
|
|
369 |
else if ( event->type() == QEvent::WindowDeactivate && mActivated )
|
|
370 |
{
|
|
371 |
TRAP_IGNORE( mVideoMpxWrapper->IssueVideoAppForegroundCmdL( false ) );
|
|
372 |
}
|
|
373 |
else
|
|
374 |
{
|
|
375 |
consumed = QGraphicsWidget::event( event );
|
|
376 |
}
|
|
377 |
|
|
378 |
return consumed;
|
|
379 |
}
|
|
380 |
|
|
381 |
// -------------------------------------------------------------------------------------------------
|
|
382 |
// HbVideoBasePlaybackView::getWindow()
|
|
383 |
// -------------------------------------------------------------------------------------------------
|
|
384 |
//
|
|
385 |
RWindow *HbVideoBasePlaybackView::getWindow()
|
|
386 |
{
|
|
387 |
return static_cast<RWindow*>( hbInstance->allMainWindows()[0]->effectiveWinId()->DrawableWindow() );
|
|
388 |
}
|
|
389 |
|
|
390 |
// -------------------------------------------------------------------------------------------------
|
|
391 |
// HbVideoBasePlaybackView::mousePress
|
|
392 |
// -------------------------------------------------------------------------------------------------
|
|
393 |
//
|
|
394 |
void HbVideoBasePlaybackView::mousePressEvent( QGraphicsSceneMouseEvent *event )
|
|
395 |
{
|
|
396 |
//
|
|
397 |
// Needed for gesture framework
|
|
398 |
//
|
|
399 |
event->accept();
|
|
400 |
}
|
|
401 |
|
|
402 |
// -------------------------------------------------------------------------------------------------
|
|
403 |
// HbVideoBasePlaybackView::mouseReleaseEvent
|
|
404 |
// -------------------------------------------------------------------------------------------------
|
|
405 |
//
|
|
406 |
void HbVideoBasePlaybackView::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
|
|
407 |
{
|
|
408 |
MPX_ENTER_EXIT(_L("HbVideoBasePlaybackView::mouseReleaseEvent"));
|
|
409 |
|
|
410 |
Q_UNUSED( event );
|
|
411 |
|
|
412 |
emit tappedOnScreen();
|
|
413 |
}
|
|
414 |
|
35
|
415 |
// -------------------------------------------------------------------------------------------------
|
|
416 |
// HbVideoBasePlaybackView::handleClosePopupDialog()
|
|
417 |
// -------------------------------------------------------------------------------------------------
|
|
418 |
//
|
|
419 |
void HbVideoBasePlaybackView::handleClosePopupDialog()
|
|
420 |
{
|
|
421 |
MPX_DEBUG(_L("HbVideoBasePlaybackView::handleClosePopupDialog()") );
|
|
422 |
|
|
423 |
handleClosePlaybackView();
|
|
424 |
}
|
|
425 |
|
|
426 |
|
30
|
427 |
// EOF
|