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