|
1 /* |
|
2 * Copyright (c) 2008 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 playback view |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 21 % |
|
19 |
|
20 |
|
21 // Include Files |
|
22 #include <aknViewAppUi.h> |
|
23 #include <mpxplaybackutility.h> |
|
24 #include <mpxviewutility.h> |
|
25 #include <mpxcommandgeneraldefs.h> |
|
26 #include <mpxvideoplaybackviews.rsg> |
|
27 #include <mmf/common/mmferrors.h> |
|
28 #include <eikmenup.h> |
|
29 #include <AknTaskList.h> |
|
30 |
|
31 #include "mpxcommonvideoplaybackview.hrh" |
|
32 #include "mpxvideoplaybackuids.hrh" |
|
33 #include "mpxvideopdlplaybackview.h" |
|
34 #include "mpxvideoplaybackcontainer.h" |
|
35 #include "mpxvideoplaybackviewfiledetails.h" |
|
36 #include <mpxvideoplaybackdefs.h> |
|
37 #include "mpxvideo_debug.h" |
|
38 |
|
39 // Member Functions |
|
40 |
|
41 // ------------------------------------------------------------------------------------------------- |
|
42 // CMPXVideoPdlPlaybackView::NewLC() |
|
43 // ------------------------------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C CMPXVideoPdlPlaybackView* CMPXVideoPdlPlaybackView::NewLC() |
|
46 { |
|
47 MPX_ENTER_EXIT(_L("CMPXVideoPdlPlaybackView::NewLC()")); |
|
48 |
|
49 CMPXVideoPdlPlaybackView* self = new (ELeave) CMPXVideoPdlPlaybackView(); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ------------------------------------------------------------------------------------------------- |
|
56 // CMPXVideoPdlPlaybackView::NewL() |
|
57 // ------------------------------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CMPXVideoPdlPlaybackView* CMPXVideoPdlPlaybackView::NewL() |
|
60 { |
|
61 CMPXVideoPdlPlaybackView* self = CMPXVideoPdlPlaybackView::NewLC(); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ------------------------------------------------------------------------------------------------- |
|
67 // CMPXVideoPdlPlaybackView::CMPXVideoPdlPlaybackView() |
|
68 // ------------------------------------------------------------------------------------------------- |
|
69 // |
|
70 CMPXVideoPdlPlaybackView::CMPXVideoPdlPlaybackView() |
|
71 // note, CBase initialises all member variables to zero |
|
72 { |
|
73 } |
|
74 |
|
75 // ------------------------------------------------------------------------------------------------- |
|
76 // CMPXVideoPdlPlaybackView::ConstructL() |
|
77 // ------------------------------------------------------------------------------------------------- |
|
78 // |
|
79 void CMPXVideoPdlPlaybackView::ConstructL() |
|
80 { |
|
81 MPX_ENTER_EXIT(_L("CMPXVideoPdlPlaybackView::ConstructL()")); |
|
82 |
|
83 InitializeVideoPlaybackViewL(); |
|
84 } |
|
85 |
|
86 // ------------------------------------------------------------------------------------------------- |
|
87 // CMPXVideoPdlPlaybackView::~CMPXVideoPdlPlaybackView() |
|
88 // ------------------------------------------------------------------------------------------------- |
|
89 // |
|
90 CMPXVideoPdlPlaybackView::~CMPXVideoPdlPlaybackView() |
|
91 { |
|
92 MPX_DEBUG(_L("CMPXVideoPdlPlaybackView::~CMPXVideoPdlPlaybackView()")); |
|
93 } |
|
94 |
|
95 // ------------------------------------------------------------------------------------------------- |
|
96 // CMPXVideoPdlPlaybackView::Id() |
|
97 // ------------------------------------------------------------------------------------------------- |
|
98 // |
|
99 TUid CMPXVideoPdlPlaybackView::Id() const |
|
100 { |
|
101 return TUid::Uid( KMPXVIDEOPDLPLAYBACKVIEWUID ); |
|
102 } |
|
103 |
|
104 // ------------------------------------------------------------------------------------------------- |
|
105 // CMPXVideoPdlPlaybackView::ViewImplementationIdId() |
|
106 // ------------------------------------------------------------------------------------------------- |
|
107 // |
|
108 TUid CMPXVideoPdlPlaybackView::ViewImplementationId() const |
|
109 { |
|
110 return TUid::Uid( KMPXVIDEOPDLPLAYBACKVIEWPLUGINIMPLEMENTATIONUID ); |
|
111 } |
|
112 |
|
113 // ------------------------------------------------------------------------------------------------- |
|
114 // CMPXVideoPdlPlaybackView::CloseEmbeddedPlaybackViewL |
|
115 // ------------------------------------------------------------------------------------------------- |
|
116 // |
|
117 void CMPXVideoPdlPlaybackView::CloseEmbeddedPlaybackViewL() |
|
118 { |
|
119 MPX_ENTER_EXIT(_L("CMPXVideoPdlPlaybackView::CloseEmbeddedPlaybackViewL()")); |
|
120 |
|
121 // |
|
122 // If playback state is playing, pause playback |
|
123 // If playback state is stopped, close the plugin so file will be moved |
|
124 // |
|
125 if ( iPlaybackState == EPbStatePlaying ) |
|
126 { |
|
127 HandleCommandL( EMPXPbvCmdPause ); |
|
128 } |
|
129 else if ( iPlaybackState == EPbStateStopped ) |
|
130 { |
|
131 // |
|
132 // Close the playback plugin and clear out the PDL data from the PDL Handler |
|
133 // |
|
134 HandleCommandL( EMPXPbvCmdClose ); |
|
135 AppUi()->HandleCommandL( EAknCmdHideInBackground ); |
|
136 } |
|
137 |
|
138 // |
|
139 // Embedded PDL |
|
140 // If we are in the foreground, bring the browser to the foreground |
|
141 // |
|
142 if ( ! BringUpBrowserL() ) |
|
143 { |
|
144 // |
|
145 // Browser cannot be found, exit application |
|
146 // |
|
147 AppUi()->RunAppShutter(); |
|
148 } |
|
149 } |
|
150 |
|
151 // ------------------------------------------------------------------------------------------------- |
|
152 // CMPXVideoPdlPlaybackView::BringUpBrowserL |
|
153 // ------------------------------------------------------------------------------------------------- |
|
154 // |
|
155 TBool CMPXVideoPdlPlaybackView::BringUpBrowserL() |
|
156 { |
|
157 MPX_ENTER_EXIT(_L("CMPXVideoPdlPlaybackView::BringUpBrowserL()")); |
|
158 |
|
159 TBool browserFound( EFalse ); |
|
160 |
|
161 RWsSession& wsSession=iEikonEnv->WsSession(); |
|
162 CAknTaskList* taskList = CAknTaskList::NewL( wsSession ); |
|
163 TApaTask task = taskList->FindRootApp( TUid::Uid( KBROWSERUID ) ); |
|
164 |
|
165 delete taskList; |
|
166 |
|
167 if ( task.Exists() ) |
|
168 { |
|
169 task.BringToForeground(); |
|
170 browserFound = ETrue; |
|
171 } |
|
172 |
|
173 return browserFound; |
|
174 } |
|
175 |
|
176 // ------------------------------------------------------------------------------------------------- |
|
177 // CMPXVideoPdlPlaybackView::RetrievePdlInformationL |
|
178 // ------------------------------------------------------------------------------------------------- |
|
179 // |
|
180 void CMPXVideoPdlPlaybackView::RetrievePdlInformationL() |
|
181 { |
|
182 MPX_ENTER_EXIT(_L("CMPXVideoPdlPlaybackView::RetrievePdlInformationL()")); |
|
183 |
|
184 CMPXCommand* cmd( CMPXCommand::NewL() ); |
|
185 CleanupStack::PushL( cmd ); |
|
186 |
|
187 cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue ); |
|
188 cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD ); |
|
189 cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( KMPXCommandPlaybackGeneralType, |
|
190 EPbCmdGetPdStatus ); |
|
191 |
|
192 iPlaybackUtility->CommandL( *cmd ); |
|
193 |
|
194 // |
|
195 // Parse the PDL information |
|
196 // |
|
197 iPdlState = cmd->ValueTObjectL<TMPXPlaybackPdDownloadState>( KMPXCommandPlaybackPDState ); |
|
198 TInt downloadedBytes = cmd->ValueTObjectL<TInt>( KMPXCommandPlaybackPDDownloadedBytes ); |
|
199 iDownloadSize = cmd->ValueTObjectL<TInt>( KMPXCommandPlaybackPDTotalBytes ); |
|
200 |
|
201 MPX_DEBUG(_L(" PDL State = %d, current size = %d, total size = %d"), |
|
202 iPdlState, downloadedBytes, iDownloadSize ); |
|
203 |
|
204 CleanupStack::PopAndDestroy( cmd ); |
|
205 |
|
206 if ( iContainer ) |
|
207 { |
|
208 // |
|
209 // Check for a saved download. |
|
210 // The download size and downloaded bytes will be set to 100 so |
|
211 // the download progress bar will show 100% |
|
212 // |
|
213 if ( iPdlState == EPbDlStateNotDownloading ) |
|
214 { |
|
215 iDownloadSize = 100; |
|
216 downloadedBytes = 100; |
|
217 } |
|
218 |
|
219 iContainer->HandleEventL( EMPXControlCmdSetDownloadSize, iDownloadSize ); |
|
220 iContainer->HandleEventL( EMPXControlCmdDownloadUpdated, downloadedBytes ); |
|
221 } |
|
222 } |
|
223 |
|
224 // ------------------------------------------------------------------------------------------------- |
|
225 // CMPXVideoPdlPlaybackView::HandlePluginErrorL() |
|
226 // ------------------------------------------------------------------------------------------------- |
|
227 // |
|
228 void CMPXVideoPdlPlaybackView::HandlePluginErrorL( TInt aError ) |
|
229 { |
|
230 MPX_DEBUG( |
|
231 _L("CMPXVideoPdlPlaybackView::HandlePluginErrorL() aError = %d"), aError ); |
|
232 |
|
233 switch ( aError ) |
|
234 { |
|
235 case KErrAbort: |
|
236 { |
|
237 // |
|
238 // For progressive download mode, this indicates that the file |
|
239 // could not be played until the entire file is downloaded. |
|
240 // |
|
241 DisplayErrorMessageL( R_MPX_VIDEO_PDL_WAIT_DL_COMPLETE_MSG ); |
|
242 ClosePlaybackViewL(); |
|
243 |
|
244 break; |
|
245 } |
|
246 case KErrEof: |
|
247 { |
|
248 // |
|
249 // For progressive download mode, this indicates that the file |
|
250 // has timed out waiting for more data to be downloaded |
|
251 // |
|
252 DisplayErrorMessageL( R_MPX_VIDEO_PDL_ALL_CONTENT_PLAYED_MSG ); |
|
253 ClosePlaybackViewL(); |
|
254 |
|
255 break; |
|
256 } |
|
257 case KErrNotSupported: |
|
258 case KErrUnknown: |
|
259 case KErrMMDecoder: |
|
260 case KErrCorrupt: |
|
261 case KErrTooBig: |
|
262 { |
|
263 // |
|
264 // We have received an error for an invalid clip. |
|
265 // If the download is complete, display the invalid |
|
266 // clip message. If the download is in progress, |
|
267 // we do not know if the clip is invalid yet. |
|
268 // Show message to wait for more data. |
|
269 // |
|
270 if ( iPdlState >= EPbDlStateNotDownloading ) |
|
271 { |
|
272 DisplayErrorMessageL( R_MPX_PDL_MORE_DATA_NEEDED_MSG ); |
|
273 } |
|
274 else |
|
275 { |
|
276 DisplayErrorMessageL( R_MPX_VIDEO_INVALID_CLIP ); |
|
277 } |
|
278 |
|
279 ClosePlaybackViewL(); |
|
280 |
|
281 break; |
|
282 } |
|
283 default: |
|
284 { |
|
285 CMPXVideoBasePlaybackView::HandlePluginErrorL( aError ); |
|
286 } |
|
287 } |
|
288 } |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // CMPXVideoPdlPlaybackView::HandlePdlStateChangeL |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 void CMPXVideoPdlPlaybackView::HandlePdlStateChangeL( TInt aState ) |
|
295 { |
|
296 MPX_ENTER_EXIT(_L("CMPXVideoPdlPlaybackView::HandlePdlStateChangeL()"), |
|
297 _L("aState = %d"), aState ); |
|
298 |
|
299 TMPXPlaybackPdDownloadState prevPdlState = iPdlState; |
|
300 iPdlState = (TMPXPlaybackPdDownloadState)aState; |
|
301 |
|
302 switch ( aState ) |
|
303 { |
|
304 case EPbDlStateDownloadError: |
|
305 case EPbDlStateDownloadCanceled: |
|
306 { |
|
307 HandleCommandL( EMPXPbvCmdStop ); |
|
308 ClosePlaybackViewL(); |
|
309 break; |
|
310 } |
|
311 case EPbDlStateDownloading: |
|
312 { |
|
313 if ( prevPdlState == EPbDlStateDownloadPaused ) |
|
314 { |
|
315 if ( iContainer ) |
|
316 { |
|
317 iContainer->HandleEventL( EMPXControlCmdClearDownloadPaused ); |
|
318 } |
|
319 } |
|
320 |
|
321 break; |
|
322 } |
|
323 case EPbDlStateDownloadPaused: |
|
324 { |
|
325 // |
|
326 // If we are buffering, display information message and pause |
|
327 // |
|
328 if ( iPlaybackState == EPbStateBuffering ) |
|
329 { |
|
330 HandleCommandL( EMPXPbvCmdPause ); |
|
331 |
|
332 DisplayInfoMessageL( R_MPX_VIDEO_PDL_ALL_CONTENT_PLAYED_MSG, ETrue ); |
|
333 HandleCommandL( EAknSoftkeyBack ); |
|
334 } |
|
335 else |
|
336 { |
|
337 // |
|
338 // Download has been paused, let container show |
|
339 // the download paused icon |
|
340 // |
|
341 if ( iContainer ) |
|
342 { |
|
343 iContainer->HandleEventL( EMPXControlCmdSetDownloadPaused ); |
|
344 } |
|
345 } |
|
346 |
|
347 break; |
|
348 } |
|
349 case EPbDlStateDownloadCompleted: |
|
350 { |
|
351 if ( iContainer ) |
|
352 { |
|
353 iContainer->HandleEventL( EMPXControlCmdDownloadComplete, iDownloadSize ); |
|
354 } |
|
355 |
|
356 break; |
|
357 } |
|
358 case EPbDlStateNotDownloading: |
|
359 { |
|
360 break; |
|
361 } |
|
362 } |
|
363 } |
|
364 |
|
365 // ------------------------------------------------------------------------------------------------- |
|
366 // CMPXVideoPdlPlaybackView::HandleStoppedStateL |
|
367 // ------------------------------------------------------------------------------------------------- |
|
368 // |
|
369 void CMPXVideoPdlPlaybackView::HandleStoppedStateL() |
|
370 { |
|
371 MPX_DEBUG(_L("CMPXVideoPdlPlaybackView::HandleStoppedStateL()")); |
|
372 |
|
373 if ( iPlaybackState == EPbStateStopped ) |
|
374 { |
|
375 ClosePlaybackViewL(); |
|
376 } |
|
377 } |
|
378 |
|
379 // ------------------------------------------------------------------------------------------------- |
|
380 // CMPXVideoPdlPlaybackView::HandleBufferingStateL |
|
381 // ------------------------------------------------------------------------------------------------- |
|
382 // |
|
383 void CMPXVideoPdlPlaybackView::HandleBufferingStateL() |
|
384 { |
|
385 MPX_DEBUG(_L("CMPXVideoPdlPlaybackView::HandleBufferingStateL()")); |
|
386 |
|
387 // |
|
388 // If the download is paused and the state is buffering, |
|
389 // display information message |
|
390 // |
|
391 if ( iPdlState == EPbDlStateDownloadPaused ) |
|
392 { |
|
393 HandleCommandL( EMPXPbvCmdPause ); |
|
394 |
|
395 DisplayInfoMessageL( R_MPX_VIDEO_PDL_ALL_CONTENT_PLAYED_MSG, ETrue ); |
|
396 HandleCommandL( EAknSoftkeyBack ); |
|
397 } |
|
398 } |
|
399 |
|
400 // ------------------------------------------------------------------------------------------------- |
|
401 // CMPXVideoPdlPlaybackView::SendPdlCustomCommandL() |
|
402 // ------------------------------------------------------------------------------------------------- |
|
403 // |
|
404 void CMPXVideoPdlPlaybackView::SendPdlCustomCommandL( TMPXPlaybackPdCommand aCustomCmd ) |
|
405 { |
|
406 MPX_ENTER_EXIT(_L("CMPXVideoPdlPlaybackView::SendPdlCustomCommandL"), |
|
407 _L("aCustomCmd = %d"), aCustomCmd ); |
|
408 |
|
409 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
410 CleanupStack::PushL( cmd ); |
|
411 |
|
412 cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue ); |
|
413 cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD ); |
|
414 cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( KMPXCommandPlaybackGeneralType, aCustomCmd ); |
|
415 |
|
416 iPlaybackUtility->CommandL( *cmd ); |
|
417 |
|
418 CleanupStack::PopAndDestroy( cmd ); |
|
419 } |
|
420 |
|
421 // EOF |