29
|
1 |
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
/**
|
|
17 |
@file
|
|
18 |
@internalComponent
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include <mpxmessagegeneraldefs.h>
|
|
22 |
#include <mpxplaybackutility.h>
|
|
23 |
#include <mpxplaybackmessage.h>
|
|
24 |
#include <mpxplaybackmessagedefs.h>
|
|
25 |
#include <mpxcommandgeneraldefs.h>
|
|
26 |
|
|
27 |
#include <mpxcollectionplaylist.h>
|
|
28 |
#include <mpxcollectionpath.h>
|
|
29 |
|
|
30 |
#include "cmtpplaybackcontrolimpl.h"
|
|
31 |
#include "cmtpplaybackplaylisthelper.h"
|
|
32 |
#include "cmtpplaybackcommandchecker.h"
|
|
33 |
#include "cmtpplaybackresumehelper.h"
|
|
34 |
#include "mtpplaybackcontrolpanic.h"
|
|
35 |
#include "cmtpplaybackcommand.h"
|
|
36 |
#include "cmtpplaybackevent.h"
|
|
37 |
|
|
38 |
// Constants
|
|
39 |
__FLOG_STMT(_LIT8(KComponent,"PlaybackControlImpl");)
|
|
40 |
|
|
41 |
// ======== MEMBER FUNCTIONS ========
|
|
42 |
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
// CMTPPlaybackControlImpl::NewL
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CMTPPlaybackControlImpl* CMTPPlaybackControlImpl::NewL(
|
|
48 |
MMTPPlaybackObserver& aObserver )
|
|
49 |
{
|
|
50 |
CMTPPlaybackControlImpl* self = new ( ELeave )
|
|
51 |
CMTPPlaybackControlImpl( aObserver );
|
|
52 |
CleanupStack::PushL( self );
|
|
53 |
self->ConstructL();
|
|
54 |
CleanupStack::Pop( self );
|
|
55 |
return self;
|
|
56 |
}
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
// CMTPPlaybackControlImpl::Close()
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
void CMTPPlaybackControlImpl::Close()
|
|
63 |
{
|
|
64 |
delete this;
|
|
65 |
}
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
// CMTPPlaybackControlImpl::~CMTPPlaybackControlImpl
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
CMTPPlaybackControlImpl::~CMTPPlaybackControlImpl()
|
|
72 |
{
|
|
73 |
__FLOG(_L8("+CMTPPlaybackControlImpl::~CMTPPlaybackControlImpl"));
|
|
74 |
|
|
75 |
if ( iPlaybackUtility )
|
|
76 |
{
|
|
77 |
TRAP_IGNORE( SendMPXPlaybackCommandL( EPbCmdClose, ETrue ) );
|
|
78 |
TRAP_IGNORE( iPlaybackUtility->RemoveObserverL( *this ) );
|
|
79 |
iPlaybackUtility->Close();
|
|
80 |
}
|
|
81 |
|
|
82 |
if ( iNowActivePlaybackUtility )
|
|
83 |
{
|
|
84 |
TRAP_IGNORE( SendMPXPlaybackCommandL( EPbCmdClose, EFalse ) );
|
|
85 |
iNowActivePlaybackUtility->Close();
|
|
86 |
}
|
|
87 |
|
|
88 |
delete iPlaybackCommandChecker;
|
|
89 |
delete iPlaybackPlaylistHelper;
|
|
90 |
delete iPlaybackResumeHelper;
|
|
91 |
delete iPlayList;
|
|
92 |
iPrepareCmdArray.Reset();
|
|
93 |
iPrepareCmdArray.Close();
|
|
94 |
iResumeCmdArray.Reset();
|
|
95 |
iResumeCmdArray.Close();
|
|
96 |
delete iCmdParam;
|
|
97 |
|
|
98 |
__FLOG(_L8("-CMTPPlaybackControlImpl::~CMTPPlaybackControlImpl"));
|
|
99 |
__FLOG_CLOSE;
|
|
100 |
}
|
|
101 |
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
// CMTPPlaybackControlImpl::CommandL
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CMTPPlaybackControlImpl::CommandL( CMTPPlaybackCommand& aCmd, MMTPPlaybackCallback* aCallback )
|
|
107 |
{
|
|
108 |
__FLOG(_L8("+CMTPPlaybackControlImpl::CommandL"));
|
|
109 |
__FLOG_1(_L8("The command code is 0x%X"), aCmd.PlaybackCommand() );
|
|
110 |
|
|
111 |
iCallback = aCallback;
|
|
112 |
|
|
113 |
TRAPD( err, CheckPlaybackCmdAndCacheL( aCmd ));
|
|
114 |
|
|
115 |
if ( KErrNone == err )
|
|
116 |
{
|
|
117 |
UpdateCommandArray();
|
|
118 |
DoCommandL();
|
|
119 |
}
|
|
120 |
else
|
|
121 |
{
|
|
122 |
CompleteSelf( err );
|
|
123 |
}
|
|
124 |
|
|
125 |
__FLOG(_L8("-CMTPPlaybackControlImpl::CommandL"));
|
|
126 |
}
|
|
127 |
|
|
128 |
// ---------------------------------------------------------------------------
|
|
129 |
// From MMPXPlaybackObserver
|
|
130 |
// Handle playback message.
|
|
131 |
// ---------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
void CMTPPlaybackControlImpl::HandlePlaybackMessage( CMPXMessage* aMessage,
|
|
134 |
TInt aError )
|
|
135 |
{
|
|
136 |
__FLOG_1(_L8("+CMTPPlaybackControlImpl::HandlePlaybackMessage( %d ) "), aError );
|
|
137 |
|
|
138 |
if (( KErrNone == aError ) && aMessage )
|
|
139 |
{
|
|
140 |
TRAP( aError, DoHandlePlaybackMessageL( *aMessage ) );
|
|
141 |
}
|
|
142 |
|
|
143 |
if ( KErrNone != aError )
|
|
144 |
{
|
|
145 |
DoHandleError( MapError( aError ));
|
|
146 |
}
|
|
147 |
|
|
148 |
__FLOG(_L8("-CMTPPlaybackControlImpl::HandlePlaybackMessage"));
|
|
149 |
}
|
|
150 |
|
|
151 |
// ---------------------------------------------------------------------------
|
|
152 |
// From MMPXPlaybackCallback
|
|
153 |
// Handle playback property.
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
void CMTPPlaybackControlImpl::HandlePropertyL( TMPXPlaybackProperty aProperty,
|
|
157 |
TInt aValue, TInt aError )
|
|
158 |
{
|
|
159 |
__FLOG_VA((_L8("+CMTPPlaybackControlImpl::HandlePropertyL( aProperty = 0x%X, aValue = 0x%X, aError = %d ) "), aProperty, aValue, aError ));
|
|
160 |
|
|
161 |
if ( KErrNone == aError )
|
|
162 |
{
|
|
163 |
TRAP( aError, DoHandlePropertyL( aProperty, aValue ));
|
|
164 |
}
|
|
165 |
|
|
166 |
if ( KErrNone != aError )
|
|
167 |
{
|
|
168 |
DoHandleError( MapError( aError ) );
|
|
169 |
}
|
|
170 |
|
|
171 |
__FLOG(_L8("-CMTPPlaybackControlImpl::HandlePropertyL"));
|
|
172 |
}
|
|
173 |
|
|
174 |
// ---------------------------------------------------------------------------
|
|
175 |
// From MMPXPlaybackCallback
|
|
176 |
// Method is called continously until aComplete=ETrue, signifying that
|
|
177 |
// it is done and there will be no more callbacks
|
|
178 |
// Only new items are passed each time
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
void CMTPPlaybackControlImpl::HandleSubPlayerNamesL(
|
|
182 |
TUid /* aPlayer */,
|
|
183 |
const MDesCArray* /* aSubPlayers */,
|
|
184 |
TBool /* aComplete */,
|
|
185 |
TInt /* aError */ )
|
|
186 |
{
|
|
187 |
__FLOG(_L8("+CMTPPlaybackControlImpl::HandleSubPlayerNamesL"));
|
|
188 |
__FLOG(_L8("-CMTPPlaybackControlImpl::HandleSubPlayerNamesL"));
|
|
189 |
}
|
|
190 |
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
// From MMPXPlaybackCallback
|
|
193 |
// Handle media
|
|
194 |
// ---------------------------------------------------------------------------
|
|
195 |
//
|
|
196 |
void CMTPPlaybackControlImpl::HandleMediaL( const CMPXMedia& aMedia,
|
|
197 |
TInt aError )
|
|
198 |
{
|
|
199 |
__FLOG(_L8("+CMTPPlaybackControlImpl::HandleMediaL"));
|
|
200 |
|
|
201 |
if (( KErrNone == aError ) && ( aMedia.IsSupported( KMPXMediaGeneralUri )))
|
|
202 |
{
|
|
203 |
TRAP( aError, DoHandleMediaL( aMedia ));
|
|
204 |
}
|
|
205 |
|
|
206 |
if ( KErrNone != aError )
|
|
207 |
{
|
|
208 |
DoHandleError( MapError( aError ));
|
|
209 |
}
|
|
210 |
|
|
211 |
__FLOG(_L8("-CMTPPlaybackControlImpl::HandleMediaL"));
|
|
212 |
}
|
|
213 |
|
|
214 |
// ---------------------------------------------------------------------------
|
|
215 |
// From CActive
|
|
216 |
// CMTPPlaybackControlImpl::DoCancel()
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
//
|
|
219 |
void CMTPPlaybackControlImpl::DoCancel()
|
|
220 |
{
|
|
221 |
__FLOG(_L8("+CMTPPlaybackControlImpl::DoCancel"));
|
|
222 |
__FLOG(_L8("-CMTPPlaybackControlImpl::DoCancel"));
|
|
223 |
}
|
|
224 |
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
// From CActive
|
|
227 |
// CMTPPlaybackControlImpl::RunL()
|
|
228 |
// ---------------------------------------------------------------------------
|
|
229 |
//
|
|
230 |
void CMTPPlaybackControlImpl::RunL()
|
|
231 |
{
|
|
232 |
__FLOG(_L8("+CMTPBTConnection::RunL"));
|
|
233 |
|
|
234 |
if ( KPlaybackErrNone == iStatus.Int() )
|
|
235 |
{
|
|
236 |
TRAPD( error, SendPlaybackCommandCompleteL());
|
|
237 |
if ( error != KErrNone )
|
|
238 |
{
|
|
239 |
DoHandleError( MapError( error ) );
|
|
240 |
}
|
|
241 |
}
|
|
242 |
else
|
|
243 |
{
|
|
244 |
DoHandleError( iStatus.Int());
|
|
245 |
}
|
|
246 |
|
|
247 |
__FLOG(_L8("-CMTPBTConnection::RunL"));
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
// CMTPPlaybackControlImpl::CMTPPlaybackControlImpl
|
|
252 |
// ---------------------------------------------------------------------------
|
|
253 |
//
|
|
254 |
CMTPPlaybackControlImpl::CMTPPlaybackControlImpl(
|
|
255 |
MMTPPlaybackObserver& aObserver )
|
|
256 |
: CActive( EPriorityStandard ),
|
|
257 |
iObserver( &aObserver )
|
|
258 |
{
|
|
259 |
CActiveScheduler::Add( this );
|
|
260 |
}
|
|
261 |
|
|
262 |
// ---------------------------------------------------------------------------
|
|
263 |
// CMTPPlaybackControlImpl::ConstructL
|
|
264 |
// ---------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
void CMTPPlaybackControlImpl::ConstructL()
|
|
267 |
{
|
|
268 |
__FLOG_OPEN(KMTPSubsystem, KComponent);
|
|
269 |
__FLOG(_L8("+CMTPPlaybackControlImpl::ConstructL"));
|
|
270 |
|
|
271 |
iPlaybackUtility = MMPXPlaybackUtility::NewL( KMTPPlaybackControlDpUid, this );
|
|
272 |
iNowActivePlaybackUtility = MMPXPlaybackUtility::NewL( KPbModeActivePlayer );
|
|
273 |
|
|
274 |
iPlaybackCommandChecker = CMTPPlaybackCommandChecker::NewL( *this );
|
|
275 |
iPlaybackPlaylistHelper = CMTPPlaybackPlaylistHelper::NewL( *this );
|
|
276 |
iPlaybackResumeHelper = CMTPPlaybackResumeHelper::NewL( *this );
|
|
277 |
|
|
278 |
__FLOG(_L8("-CMTPPlaybackControlImpl::ConstructL"));
|
|
279 |
}
|
|
280 |
|
|
281 |
// ---------------------------------------------------------------------------
|
|
282 |
// CMTPPlaybackControlImpl::GetPlaylistFromCollectionCompleteL
|
|
283 |
// ---------------------------------------------------------------------------
|
|
284 |
//
|
|
285 |
void CMTPPlaybackControlImpl::GetPlaylistFromCollectionCompleteL( const CMPXCollectionPlaylist& aPlaylist )
|
|
286 |
{
|
|
287 |
__FLOG(_L8("+CMTPPlaybackControlImpl::GetPlaylistFromCollectionCompleteL "));
|
|
288 |
|
|
289 |
CMPXCollectionPlaylist* tmp =
|
|
290 |
CMPXCollectionPlaylist::NewL( aPlaylist );
|
|
291 |
CleanupStack::PushL( tmp );
|
|
292 |
tmp->SetEmbeddedPlaylist( ETrue );
|
|
293 |
tmp->SetRepeatEnabled( EFalse );
|
|
294 |
tmp->SetShuffleEnabledL( EFalse );
|
|
295 |
iPlaybackUtility->InitL( *tmp, ETrue );
|
|
296 |
CleanupStack::PopAndDestroy( tmp );
|
|
297 |
|
|
298 |
__FLOG(_L8("-CMTPPlaybackControlImpl::HandlePlaybackGetPlaylistCompleteL"));
|
|
299 |
}
|
|
300 |
|
|
301 |
// ----------------------------------------------------
|
|
302 |
// CMTPPlaybackControlImpl::DeActiveOtherPlayerL
|
|
303 |
// ----------------------------------------------------
|
|
304 |
//
|
|
305 |
void CMTPPlaybackControlImpl::DeActiveOtherPlayerL()
|
|
306 |
{
|
|
307 |
__FLOG(_L8("+CMTPPlaybackControlImpl::DeActiveOtherPlayerL()"));
|
|
308 |
|
|
309 |
if ( iNowActivePlaybackUtility->StateL() != iPlaybackUtility->StateL())
|
|
310 |
{
|
|
311 |
SendMPXPlaybackCommandL( EPbCmdPause, EFalse );
|
|
312 |
}
|
|
313 |
|
|
314 |
__FLOG(_L8("-CMTPPlaybackControlImpl::DeActiveOtherPlayerL()"));
|
|
315 |
}
|
|
316 |
|
|
317 |
// ----------------------------------------------------
|
|
318 |
// CMTPPlaybackControlImpl::CheckPlaybackCmdAndCacheL
|
|
319 |
// ----------------------------------------------------
|
|
320 |
//
|
|
321 |
void CMTPPlaybackControlImpl::CheckPlaybackCmdAndCacheL( CMTPPlaybackCommand& aCmd )
|
|
322 |
{
|
|
323 |
__FLOG(_L8("+CMTPPlaybackControlImpl::CheckPlaybackCmdAndCacheL"));
|
|
324 |
|
|
325 |
iPlaybackCommandChecker->CheckPlaybackCommandContextL( aCmd.PlaybackCommand());
|
|
326 |
iPlaybackCommandChecker->CheckAndUpdatePlaybackParamL( aCmd, &iCmdParam );
|
|
327 |
|
|
328 |
__FLOG(_L8("-CMTPPlaybackControlImpl::CheckPlaybackCmdAndCacheL"));
|
|
329 |
}
|
|
330 |
|
|
331 |
// ----------------------------------------------------
|
|
332 |
// CMTPPlaybackControlImpl::UpdateCommandArrayL
|
|
333 |
// ----------------------------------------------------
|
|
334 |
//
|
|
335 |
void CMTPPlaybackControlImpl::UpdateCommandArray()
|
|
336 |
{
|
|
337 |
__FLOG(_L8("+CMTPPlaybackControlImpl::UpdateCommandArrayL"));
|
|
338 |
|
|
339 |
iPlaybackResumeHelper->UpdatePrepareCmdArray( iMTPPBCmd, iPrepareCmdArray );
|
|
340 |
iPlaybackResumeHelper->UpdateResumeCmdArray( iMTPPBCmd, iResumeCmdArray );
|
|
341 |
|
|
342 |
__FLOG(_L8("-CMTPPlaybackControlImpl::UpdateCommandArrayL"));
|
|
343 |
}
|
|
344 |
|
|
345 |
// ----------------------------------------------------
|
|
346 |
// CMTPPlaybackControlImpl::RequestMediaL
|
|
347 |
// ----------------------------------------------------
|
|
348 |
//
|
|
349 |
void CMTPPlaybackControlImpl::RequestMediaL()
|
|
350 |
{
|
|
351 |
__FLOG(_L8("+CMTPPlaybackControlImpl::RequestMediaL"));
|
|
352 |
|
|
353 |
if ( iPlayList )
|
|
354 |
{
|
|
355 |
delete iCmdParam;
|
|
356 |
iCmdParam = NULL;
|
|
357 |
iCmdParam = CMTPPbCmdParam::NewL( iPlaybackPlaylistHelper->MTPPbCategory(),
|
|
358 |
iPlaybackPlaylistHelper->MTPPbSuid());
|
|
359 |
CompleteSelf( KPlaybackErrNone );
|
|
360 |
}
|
|
361 |
else if ( iPlaybackUtility->Source() )
|
|
362 |
{
|
|
363 |
//Album or Playlist
|
|
364 |
iPlayList = iPlaybackUtility->Source()->PlaylistL();
|
|
365 |
|
|
366 |
if ( iPlayList )
|
|
367 |
{
|
|
368 |
TMTPPbDataSuid suid( EMTPPbCatNone, KNullDesC );
|
|
369 |
suid = iPlaybackPlaylistHelper->GetMTPPBSuidFromCollectionL( *iPlayList );
|
|
370 |
delete iCmdParam;
|
|
371 |
iCmdParam = NULL;
|
|
372 |
iCmdParam = CMTPPbCmdParam::NewL( suid.Category(), suid.Suid());
|
|
373 |
CompleteSelf( KPlaybackErrNone );
|
|
374 |
}
|
|
375 |
else
|
|
376 |
{
|
|
377 |
//Single Song
|
|
378 |
RArray<TMPXAttribute> attrs;
|
|
379 |
CleanupClosePushL(attrs);
|
|
380 |
attrs.Append( KMPXMediaGeneralUri );
|
|
381 |
iPlaybackUtility->Source()->MediaL( attrs.Array(), *this );
|
|
382 |
CleanupStack::PopAndDestroy( &attrs );
|
|
383 |
}
|
|
384 |
}
|
|
385 |
else
|
|
386 |
{
|
|
387 |
//Not initialized
|
|
388 |
CompleteSelf( KPlaybackErrContextInvalid );
|
|
389 |
}
|
|
390 |
|
|
391 |
__FLOG(_L8("-CMTPPlaybackControlImpl::RequestMediaL"));
|
|
392 |
}
|
|
393 |
|
|
394 |
// ----------------------------------------------------
|
|
395 |
// CMTPPlaybackControlImpl::DoCommandL
|
|
396 |
// ----------------------------------------------------
|
|
397 |
//
|
|
398 |
void CMTPPlaybackControlImpl::DoCommandL()
|
|
399 |
{
|
|
400 |
__FLOG(_L8("+CMTPPlaybackControlImpl::DoCommandL"));
|
|
401 |
|
|
402 |
if ( iPrepareCmdArray.Count() != 0 )
|
|
403 |
{
|
|
404 |
InitiateMPXPlaybackCommandL( iPrepareCmdArray[0].iMPXCommand, ETrue );
|
|
405 |
return;
|
|
406 |
}
|
|
407 |
|
|
408 |
switch ( iMTPPBCmd )
|
|
409 |
{
|
|
410 |
case EPlaybackCmdInitObject:
|
|
411 |
{
|
|
412 |
const TMTPPbCategory category = iCmdParam->SuidSetL().Category();
|
|
413 |
if ( EMTPPbCatMusic == category )
|
|
414 |
{
|
|
415 |
iPlaybackUtility->InitL( iCmdParam->SuidSetL().Suid() );
|
|
416 |
}
|
|
417 |
else
|
|
418 |
{
|
|
419 |
iPlaybackPlaylistHelper->GetPlayListFromCollectionL( iCmdParam->SuidSetL() );
|
|
420 |
}
|
|
421 |
}
|
|
422 |
break;
|
|
423 |
case EPlaybackCmdInitIndex:
|
|
424 |
{
|
|
425 |
iPlaybackPlaylistHelper->GetPlayListFromCollectionL( iCmdParam->Uint32L() );
|
|
426 |
}
|
|
427 |
break;
|
|
428 |
case EPlaybackCmdStop:
|
|
429 |
{
|
|
430 |
delete iPlayList;
|
|
431 |
iPlayList = NULL;
|
|
432 |
SendMPXPlaybackCommandL( EPbCmdClose, ETrue );
|
|
433 |
CompleteSelf( KPlaybackErrNone );
|
|
434 |
}
|
|
435 |
break;
|
|
436 |
case EPlaybackCmdSkip:
|
|
437 |
{
|
|
438 |
iPlaybackPlaylistHelper->GetPlayListFromCollectionL( iCmdParam->Int32L() );
|
|
439 |
}
|
|
440 |
break;
|
|
441 |
case EPlaybackCmdSetVolume:
|
|
442 |
{
|
|
443 |
iPlaybackUtility->SetL( EPbPropertyVolume, iCmdParam->Uint32L() );
|
|
444 |
}
|
|
445 |
break;
|
|
446 |
case EPlaybackCmdSetPosition:
|
|
447 |
{
|
|
448 |
iPlaybackUtility->PropertyL(*this, EPbPropertyDuration);
|
|
449 |
}
|
|
450 |
break;
|
|
451 |
case EPlaybackCmdGetPosition:
|
|
452 |
{
|
|
453 |
iPlaybackUtility->PropertyL(*this, EPbPropertyPosition);
|
|
454 |
}
|
|
455 |
break;
|
|
456 |
case EPlaybackCmdGetVolumeSet:
|
|
457 |
case EPlaybackCmdGetVolume:
|
|
458 |
{
|
|
459 |
iPlaybackUtility->PropertyL(*this, EPbPropertyVolume);
|
|
460 |
}
|
|
461 |
break;
|
|
462 |
case EPlaybackCmdGetState:
|
|
463 |
{
|
|
464 |
delete iCmdParam;
|
|
465 |
iCmdParam = NULL;
|
|
466 |
TMTPPlaybackState state = MapState( CurrentState());
|
|
467 |
iCmdParam = CMTPPbCmdParam::NewL( static_cast<TUint32>( state ));
|
|
468 |
CompleteSelf( KPlaybackErrNone );
|
|
469 |
}
|
|
470 |
break;
|
|
471 |
case EPlaybackCmdGetObject:
|
|
472 |
{
|
|
473 |
RequestMediaL();
|
|
474 |
}
|
|
475 |
break;
|
|
476 |
case EPlaybackCmdGetIndex:
|
|
477 |
{
|
|
478 |
delete iCmdParam;
|
|
479 |
iCmdParam = NULL;
|
|
480 |
iCmdParam = CMTPPbCmdParam::NewL( static_cast<TUint32>( SongIndex()));
|
|
481 |
CompleteSelf( KPlaybackErrNone );
|
|
482 |
}
|
|
483 |
break;
|
|
484 |
default:
|
|
485 |
{
|
|
486 |
if ( iResumeCmdArray.Count() != 0 )
|
|
487 |
{
|
|
488 |
InitiateMPXPlaybackCommandL( iResumeCmdArray[0].iMPXCommand, ETrue );
|
|
489 |
}
|
|
490 |
else
|
|
491 |
{
|
|
492 |
CompleteSelf( KPlaybackErrNone );
|
|
493 |
}
|
|
494 |
}
|
|
495 |
break;
|
|
496 |
}
|
|
497 |
|
|
498 |
__FLOG(_L8("-CMTPPlaybackControlImpl::DoCommandL"));
|
|
499 |
}
|
|
500 |
|
|
501 |
// ----------------------------------------------------
|
|
502 |
// CMTPPlaybackControlImpl::DoHandlePlaybackMessageL
|
|
503 |
// ----------------------------------------------------
|
|
504 |
//
|
|
505 |
void CMTPPlaybackControlImpl::DoHandlePlaybackMessageL( const CMPXMessage& aMessage )
|
|
506 |
{
|
|
507 |
__FLOG(_L8("+CMTPPlaybackControlImpl::DoHandlePlaybackMessageL"));
|
|
508 |
|
|
509 |
TMPXMessageId id(
|
|
510 |
aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
|
|
511 |
|
|
512 |
if ( KMPXMessageGeneral == id )
|
|
513 |
{
|
|
514 |
TInt event( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) );
|
|
515 |
|
|
516 |
switch ( event )
|
|
517 |
{
|
|
518 |
case TMPXPlaybackMessage::EPropertyChanged:
|
|
519 |
{
|
|
520 |
DoHandlePropertyL(
|
|
521 |
aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ),
|
|
522 |
aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ));
|
|
523 |
}
|
|
524 |
break;
|
|
525 |
case TMPXPlaybackMessage::EStateChanged:
|
|
526 |
{
|
|
527 |
TMPXPlaybackState state(
|
|
528 |
aMessage.ValueTObjectL<TMPXPlaybackState>(
|
|
529 |
KMPXMessageGeneralType ));
|
|
530 |
DoHandleStateChangedL( state );
|
|
531 |
}
|
|
532 |
break;
|
|
533 |
case TMPXPlaybackMessage::EInitializeComplete:
|
|
534 |
{
|
|
535 |
DoHandleInitializeCompleteL();
|
|
536 |
}
|
|
537 |
break;
|
|
538 |
case TMPXPlaybackMessage::EMediaChanged:
|
|
539 |
{
|
|
540 |
DoHandleMediaChangedL();
|
|
541 |
}
|
|
542 |
break;
|
|
543 |
default:
|
|
544 |
__FLOG_VA((_L8("DoHandlePlaybackMessageL( TMPXPlaybackMessage event = 0x%X ) "), event ));
|
|
545 |
break;
|
|
546 |
}
|
|
547 |
}
|
|
548 |
|
|
549 |
__FLOG(_L8("-CMTPPlaybackControlImpl::DoHandlePlaybackMessageL"));
|
|
550 |
}
|
|
551 |
|
|
552 |
|
|
553 |
// ---------------------------------------------------------------------------
|
|
554 |
// Handle playback property.
|
|
555 |
// ---------------------------------------------------------------------------
|
|
556 |
//
|
|
557 |
void CMTPPlaybackControlImpl::DoHandlePropertyL( TInt aProperty, TInt aValue )
|
|
558 |
{
|
|
559 |
__FLOG_VA((_L8("+CMTPPlaybackControlImpl::DoHandlePropertyL( aProperty = 0x%X, aValue = 0x%X ) "), aProperty, aValue ));
|
|
560 |
|
|
561 |
switch ( aProperty )
|
|
562 |
{
|
|
563 |
case EPbPropertyPosition:
|
|
564 |
{
|
|
565 |
if ( EPlaybackCmdGetPosition == MTPPBCmdHandling())
|
|
566 |
{
|
|
567 |
delete iCmdParam;
|
|
568 |
iCmdParam = NULL;
|
|
569 |
iCmdParam = CMTPPbCmdParam::NewL(static_cast<TUint32>(aValue));
|
|
570 |
SendPlaybackCommandCompleteL();
|
|
571 |
}
|
|
572 |
else if ( EPlaybackCmdSetPosition == MTPPBCmdHandling() )
|
|
573 |
{
|
|
574 |
if ( aValue == iCmdParam->Uint32L() )
|
|
575 |
{
|
|
576 |
SendPlaybackCommandCompleteL();
|
|
577 |
}
|
|
578 |
}
|
|
579 |
}
|
|
580 |
break;
|
|
581 |
case EPbPropertyMute:
|
|
582 |
{
|
|
583 |
SendPlaybackEventL( EPlaybackEventVolumeUpdate );
|
|
584 |
}
|
|
585 |
break;
|
|
586 |
case EPbPropertyVolume:
|
|
587 |
{
|
|
588 |
switch ( MTPPBCmdHandling() )
|
|
589 |
{
|
|
590 |
case EPlaybackCmdSetVolume:
|
|
591 |
{
|
|
592 |
SendPlaybackCommandCompleteL();
|
|
593 |
}
|
|
594 |
break;
|
|
595 |
case EPlaybackCmdGetVolumeSet:
|
|
596 |
{
|
|
597 |
delete iCmdParam;
|
|
598 |
iCmdParam = NULL;
|
|
599 |
TMTPPbDataVolume volumeSet( KPbPlaybackVolumeLevelMax,
|
|
600 |
KPbPlaybackVolumeLevelMin,
|
|
601 |
KMPXPlaybackDefaultVolume,
|
|
602 |
aValue,
|
|
603 |
KMTPPlaybackVolumeStep );
|
|
604 |
iCmdParam = CMTPPbCmdParam::NewL( volumeSet );
|
|
605 |
SendPlaybackCommandCompleteL();
|
|
606 |
}
|
|
607 |
break;
|
|
608 |
case EPlaybackCmdGetVolume:
|
|
609 |
{
|
|
610 |
delete iCmdParam;
|
|
611 |
iCmdParam = NULL;
|
|
612 |
iCmdParam = CMTPPbCmdParam::NewL(static_cast<TUint32>( aValue ));
|
|
613 |
SendPlaybackCommandCompleteL();
|
|
614 |
}
|
|
615 |
break;
|
|
616 |
default:
|
|
617 |
{
|
|
618 |
SendPlaybackEventL( EPlaybackEventVolumeUpdate );
|
|
619 |
}
|
|
620 |
break;
|
|
621 |
}
|
|
622 |
}
|
|
623 |
break;
|
|
624 |
case EPbPropertyDuration:
|
|
625 |
{
|
|
626 |
if ( EPlaybackCmdSetPosition == MTPPBCmdHandling())
|
|
627 |
{
|
|
628 |
if ( iCmdParam->Uint32L() < aValue )
|
|
629 |
{
|
|
630 |
iPlaybackUtility->SetL( EPbPropertyPosition, iCmdParam->Uint32L() );
|
|
631 |
}
|
|
632 |
else
|
|
633 |
{
|
|
634 |
DoHandleError( KPlaybackErrParamInvalid );
|
|
635 |
}
|
|
636 |
}
|
|
637 |
}
|
|
638 |
break;
|
|
639 |
default:
|
|
640 |
break;
|
|
641 |
}
|
|
642 |
|
|
643 |
__FLOG(_L8("-CMTPPlaybackControlImpl::DoHandlePropertyL"));
|
|
644 |
}
|
|
645 |
|
|
646 |
// ---------------------------------------------------------------------------
|
|
647 |
// Handle playback state changed.
|
|
648 |
// ---------------------------------------------------------------------------
|
|
649 |
//
|
|
650 |
void CMTPPlaybackControlImpl::DoHandleStateChangedL( TMPXPlaybackState aState )
|
|
651 |
{
|
|
652 |
__FLOG_VA((_L8("+CMTPPlaybackControlImpl::DoHandleStateChangedL( aState = 0x%X ) "), aState ));
|
|
653 |
|
|
654 |
if (( iPrepareCmdArray.Count() != 0 ) && ( iPrepareCmdArray[0].iMPXExpectState == aState ))
|
|
655 |
{
|
|
656 |
iPrepareCmdArray.Remove( 0 );
|
|
657 |
DoCommandL();
|
|
658 |
}
|
|
659 |
else if (( iResumeCmdArray.Count() != 0 ) && ( iResumeCmdArray[0].iMPXExpectState == aState ))
|
|
660 |
{
|
|
661 |
iResumeCmdArray.Remove( 0 );
|
|
662 |
SendPlaybackCommandCompleteL();
|
|
663 |
}
|
|
664 |
else if (( iState != aState ) && ( MapState( aState )!= MapState( iState ) ))
|
|
665 |
{
|
|
666 |
SendPlaybackEventL( EPlaybackEventStateUpdate );
|
|
667 |
}
|
|
668 |
|
|
669 |
if ( iState != aState )
|
|
670 |
{
|
|
671 |
iPreState = iState;
|
|
672 |
iState = aState;
|
|
673 |
}
|
|
674 |
|
|
675 |
__FLOG(_L8("-CMTPPlaybackControlImpl::DoHandleStateChangedL"));
|
|
676 |
}
|
|
677 |
|
|
678 |
// ---------------------------------------------------------------------------
|
|
679 |
// DoHandleMediaL.
|
|
680 |
// ---------------------------------------------------------------------------
|
|
681 |
//
|
|
682 |
void CMTPPlaybackControlImpl::DoHandleMediaL( const CMPXMedia& aMedia )
|
|
683 |
{
|
|
684 |
__FLOG(_L8("+CMTPPlaybackControlImpl::DoHandleMediaL"));
|
|
685 |
|
|
686 |
TFileName filePath(aMedia.ValueText(KMPXMediaGeneralUri) );
|
|
687 |
delete iCmdParam;
|
|
688 |
iCmdParam = NULL;
|
|
689 |
iCmdParam = CMTPPbCmdParam::NewL( EMTPPbCatMusic, filePath );
|
|
690 |
SendPlaybackCommandCompleteL();
|
|
691 |
|
|
692 |
__FLOG(_L8("-CMTPPlaybackControlImpl::DoHandleMediaL"));
|
|
693 |
}
|
|
694 |
|
|
695 |
// ---------------------------------------------------------------------------
|
|
696 |
// Handle media changed.
|
|
697 |
// ---------------------------------------------------------------------------
|
|
698 |
//
|
|
699 |
void CMTPPlaybackControlImpl::DoHandleMediaChangedL()
|
|
700 |
{
|
|
701 |
__FLOG(_L8("+CMTPPlaybackControlImpl::DoHandleMediaChangedL"));
|
|
702 |
|
|
703 |
if (( EPbStateNotInitialised == iState ) || ( EPbStateInitialising == iState ))
|
|
704 |
{
|
|
705 |
if (( MTPPBCmdHandling() != EPlaybackCmdInitObject )
|
|
706 |
&& ( MTPPBCmdHandling() != EPlaybackCmdInitIndex )
|
|
707 |
&& ( MTPPBCmdHandling() != EPlaybackCmdSkip ))
|
|
708 |
{
|
|
709 |
//should send an event
|
|
710 |
MMPXSource* source = iPlaybackUtility->Source();
|
|
711 |
CMPXCollectionPlaylist* playlist = source->PlaylistL();
|
|
712 |
if (( playlist != NULL ) && ( iPlayList != NULL ))
|
|
713 |
{
|
|
714 |
CleanupStack::PushL( playlist );
|
|
715 |
//New media is a playlist or album
|
|
716 |
TInt level = playlist->Path().Levels();
|
|
717 |
if ( IfEqual(iPlayList->Path(), playlist->Path(), level-1 ) && !IfEqual(iPlayList->Path(), playlist->Path(), level ))
|
|
718 |
{
|
|
719 |
SendPlaybackEventL( EPlaybackEventObjectIndexUpdate );
|
|
720 |
|
|
721 |
CleanupStack::Pop( playlist );
|
|
722 |
delete iPlayList;
|
|
723 |
iPlayList = playlist;
|
|
724 |
}
|
|
725 |
else
|
|
726 |
{
|
|
727 |
SendPlaybackEventL( EPlaybackEventObjectUpdate );
|
|
728 |
SendPlaybackEventL( EPlaybackEventObjectIndexUpdate );
|
|
729 |
|
|
730 |
CleanupStack::PopAndDestroy( playlist );
|
|
731 |
delete iPlayList;
|
|
732 |
iPlayList = NULL;
|
|
733 |
}
|
|
734 |
}
|
|
735 |
else
|
|
736 |
{
|
|
737 |
//New media is a single song
|
|
738 |
SendPlaybackEventL( EPlaybackEventObjectUpdate );
|
|
739 |
|
|
740 |
delete iPlayList;
|
|
741 |
iPlayList = NULL;
|
|
742 |
}
|
|
743 |
}
|
|
744 |
}
|
|
745 |
|
|
746 |
__FLOG(_L8("-CMTPPlaybackControlImpl::DoHandleMediaChangedL"));
|
|
747 |
}
|
|
748 |
|
|
749 |
// ---------------------------------------------------------------------------
|
|
750 |
// Handle Initialize complete.
|
|
751 |
// ---------------------------------------------------------------------------
|
|
752 |
//
|
|
753 |
void CMTPPlaybackControlImpl::DoHandleInitializeCompleteL()
|
|
754 |
{
|
|
755 |
__FLOG(_L8("+CMTPPlaybackControlImpl::DoHandleInitializeCompleteL"));
|
|
756 |
|
|
757 |
if ( EPlaybackCmdInitObject == MTPPBCmdHandling()
|
|
758 |
|| EPlaybackCmdInitIndex == MTPPBCmdHandling()
|
|
759 |
|| EPlaybackCmdSkip == MTPPBCmdHandling())
|
|
760 |
{
|
|
761 |
delete iPlayList;
|
|
762 |
iPlayList = NULL;
|
|
763 |
|
|
764 |
MMPXSource* source = iPlaybackUtility->Source();
|
|
765 |
if ( source )
|
|
766 |
{
|
|
767 |
iPlayList = source->PlaylistL();
|
|
768 |
SendPlaybackCommandCompleteL();
|
|
769 |
}
|
|
770 |
}
|
|
771 |
|
|
772 |
__FLOG(_L8("-CMTPPlaybackControlImpl::DoHandleInitializeCompleteL"));
|
|
773 |
}
|
|
774 |
|
|
775 |
// ---------------------------------------------------------------------------
|
|
776 |
// Handle error.
|
|
777 |
// ---------------------------------------------------------------------------
|
|
778 |
//
|
|
779 |
void CMTPPlaybackControlImpl::DoHandleError( TInt aErr )
|
|
780 |
{
|
|
781 |
if ( aErr != KPlaybackErrNone )
|
|
782 |
{
|
|
783 |
if ( iCallback )
|
|
784 |
{
|
|
785 |
TRAP_IGNORE( iCallback->HandlePlaybackCommandCompleteL( NULL, aErr ));
|
|
786 |
ResetPlaybackCommand();
|
|
787 |
}
|
|
788 |
else
|
|
789 |
{
|
|
790 |
TRAP_IGNORE( iObserver->HandlePlaybackEventL( NULL, aErr ));
|
|
791 |
}
|
|
792 |
}
|
|
793 |
}
|
|
794 |
|
|
795 |
// ---------------------------------------------------------------------------
|
|
796 |
// Compare two path according to level.
|
|
797 |
// ---------------------------------------------------------------------------
|
|
798 |
//
|
|
799 |
TBool CMTPPlaybackControlImpl::IfEqual( const CMPXCollectionPath& aPathBase, const CMPXCollectionPath& aPathNew, TUint aLevel )
|
|
800 |
{
|
|
801 |
__FLOG(_L8("+CMTPPlaybackControlImpl::IfEqual"));
|
|
802 |
|
|
803 |
if (( aPathBase.Levels() < aLevel ) || ( aPathNew.Levels() < aLevel ))
|
|
804 |
{
|
|
805 |
return EFalse;
|
|
806 |
}
|
|
807 |
for ( TInt i = 0; i < aLevel; i++ )
|
|
808 |
{
|
|
809 |
if ( aPathBase.Index( i ) != aPathNew.Index( i ) )
|
|
810 |
{
|
|
811 |
return EFalse;
|
|
812 |
}
|
|
813 |
}
|
|
814 |
|
|
815 |
__FLOG(_L8("-CMTPPlaybackControlImpl::IfEqual"));
|
|
816 |
return ETrue;
|
|
817 |
}
|
|
818 |
|
|
819 |
// ---------------------------------------------------------------------------
|
|
820 |
// Map states from TMPXPlaybackState to TMTPPlaybackState
|
|
821 |
// ---------------------------------------------------------------------------
|
|
822 |
//
|
|
823 |
TMTPPlaybackState CMTPPlaybackControlImpl::MapState( TMPXPlaybackState aState )
|
|
824 |
{
|
|
825 |
__FLOG_VA((_L8("+CMTPPlaybackControlImpl::MapState( aState = 0x%X ) "), aState ));
|
|
826 |
|
|
827 |
TMTPPlaybackState state = EPlayStateError;
|
|
828 |
|
|
829 |
switch ( aState )
|
|
830 |
{
|
|
831 |
case EPbStatePlaying:
|
|
832 |
{
|
|
833 |
state = EPlayStatePlaying;
|
|
834 |
}
|
|
835 |
break;
|
|
836 |
case EPbStatePaused:
|
|
837 |
case EPbStateInitialising:
|
|
838 |
case EPbStateInitialised:
|
|
839 |
case EPbStateNotInitialised:
|
|
840 |
case EPbStateStopped:
|
|
841 |
{
|
|
842 |
state = EPlayStatePaused;
|
|
843 |
}
|
|
844 |
break;
|
|
845 |
case EPbStateSeekingForward:
|
|
846 |
{
|
|
847 |
state = EPlayStateForwardSeeking;
|
|
848 |
}
|
|
849 |
break;
|
|
850 |
case EPbStateSeekingBackward:
|
|
851 |
{
|
|
852 |
state = EPlayStateBackwardSeeking;
|
|
853 |
}
|
|
854 |
break;
|
|
855 |
default:
|
|
856 |
break;
|
|
857 |
}
|
|
858 |
|
|
859 |
__FLOG(_L8("-CMTPPlaybackControlImpl::MapState"));
|
|
860 |
return state;
|
|
861 |
}
|
|
862 |
|
|
863 |
// ---------------------------------------------------------------------------
|
|
864 |
// CMTPPlaybackControlImpl::MapError.
|
|
865 |
// ---------------------------------------------------------------------------
|
|
866 |
//
|
|
867 |
TInt CMTPPlaybackControlImpl::MapError( TInt aError )
|
|
868 |
{
|
|
869 |
TInt err( KPlaybackErrNone );
|
|
870 |
|
|
871 |
if ( KErrHardwareNotAvailable == aError )
|
|
872 |
{
|
|
873 |
err = KPlaybackErrDeviceUnavailable;
|
|
874 |
}
|
|
875 |
else if ( KErrArgument == aError )
|
|
876 |
{
|
|
877 |
err = KPlaybackErrParamInvalid;
|
|
878 |
}
|
|
879 |
else
|
|
880 |
{
|
|
881 |
err = KPlaybackErrDeviceBusy;
|
|
882 |
}
|
|
883 |
return err;
|
|
884 |
}
|
|
885 |
|
|
886 |
// ---------------------------------------------------------------------------
|
|
887 |
// CMTPPlaybackControlImpl::CompleteSelf.
|
|
888 |
// ---------------------------------------------------------------------------
|
|
889 |
//
|
|
890 |
void CMTPPlaybackControlImpl::CompleteSelf( TInt aCompletionCode )
|
|
891 |
{
|
|
892 |
__FLOG_1(_L8("+CMTPPlaybackControlImpl::CompleteSelf( %d )"), aCompletionCode );
|
|
893 |
|
|
894 |
SetActive();
|
|
895 |
TRequestStatus* status = &iStatus;
|
|
896 |
User::RequestComplete( status, aCompletionCode );
|
|
897 |
|
|
898 |
__FLOG(_L8("-CMTPPlaybackControlImpl::CompleteSelf"));
|
|
899 |
}
|
|
900 |
|
|
901 |
// ---------------------------------------------------------------------------
|
|
902 |
// CMTPPlaybackControlImpl::InitiateMPXPlaybackCommandL.
|
|
903 |
// ---------------------------------------------------------------------------
|
|
904 |
//
|
|
905 |
void CMTPPlaybackControlImpl::InitiateMPXPlaybackCommandL( TMPXPlaybackCommand aCommand, TBool aIsMTPPlaybackUtility )
|
|
906 |
{
|
|
907 |
__FLOG(_L8("+CMTPPlaybackControlImpl::InitiateMPXPlaybackCommandL"));
|
|
908 |
|
|
909 |
switch ( aCommand )
|
|
910 |
{
|
|
911 |
case EPbCmdPlay:
|
|
912 |
{
|
|
913 |
DeActiveOtherPlayerL();
|
|
914 |
SendMPXPlaybackCommandL( EPbCmdPlay, aIsMTPPlaybackUtility );
|
|
915 |
}
|
|
916 |
break;
|
|
917 |
case EPbCmdPlayPause:
|
|
918 |
{
|
|
919 |
DeActiveOtherPlayerL();
|
|
920 |
SendMPXPlaybackCommandL( EPbCmdPlayPause, aIsMTPPlaybackUtility );
|
|
921 |
}
|
|
922 |
break;
|
|
923 |
default:
|
|
924 |
{
|
|
925 |
SendMPXPlaybackCommandL( aCommand, aIsMTPPlaybackUtility );
|
|
926 |
}
|
|
927 |
break;
|
|
928 |
}
|
|
929 |
|
|
930 |
__FLOG(_L8("-CMTPPlaybackControlImpl::InitiateMPXPlaybackCommandL"));
|
|
931 |
}
|
|
932 |
|
|
933 |
// ---------------------------------------------------------------------------
|
|
934 |
// CMTPPlaybackControlImpl::SendMPXPlaybackCommandL.
|
|
935 |
// ---------------------------------------------------------------------------
|
|
936 |
//
|
|
937 |
void CMTPPlaybackControlImpl::SendMPXPlaybackCommandL( TMPXPlaybackCommand aCommand, TBool aIsMTPPlaybackUtility )
|
|
938 |
{
|
|
939 |
__FLOG(_L8("+CMTPPlaybackControlImpl::SendPlaybackCommandL"));
|
|
940 |
|
|
941 |
CMPXCommand* cmd( CMPXCommand::NewL() );
|
|
942 |
CleanupStack::PushL( cmd );
|
|
943 |
cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral );
|
|
944 |
cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
|
|
945 |
cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralType, aCommand );
|
|
946 |
cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralData, 0 );
|
|
947 |
|
|
948 |
if ( aIsMTPPlaybackUtility )
|
|
949 |
{
|
|
950 |
iPlaybackUtility->CommandL( *cmd, this );
|
|
951 |
}
|
|
952 |
else
|
|
953 |
{
|
|
954 |
iNowActivePlaybackUtility->CommandL( *cmd );
|
|
955 |
}
|
|
956 |
|
|
957 |
CleanupStack::PopAndDestroy( cmd );
|
|
958 |
|
|
959 |
__FLOG(_L8("-CMTPPlaybackControlImpl::SendPlaybackCommandL"));
|
|
960 |
}
|
|
961 |
|
|
962 |
// ---------------------------------------------------------------------------
|
|
963 |
// CMTPPlaybackControlImpl::SendPlaybackCommandCompleteL.
|
|
964 |
// ---------------------------------------------------------------------------
|
|
965 |
//
|
|
966 |
void CMTPPlaybackControlImpl::SendPlaybackCommandCompleteL()
|
|
967 |
{
|
|
968 |
__FLOG(_L8("+CMTPPlaybackControlImpl::SendPlaybackCommandCompleteL"));
|
|
969 |
|
|
970 |
__ASSERT_DEBUG( iCallback, Panic( EMTPPBCallbackInvalid ));
|
|
971 |
__ASSERT_DEBUG(( iMTPPBCmd > EPlaybackCmdNone ) && ( iMTPPBCmd < EPlaybackCmdEnd ), Panic( EMTPPBCallbackInvalid ));
|
|
972 |
|
|
973 |
if ( iResumeCmdArray.Count() != 0 )
|
|
974 |
{
|
|
975 |
InitiateMPXPlaybackCommandL( iResumeCmdArray[0].iMPXCommand, ETrue );
|
|
976 |
}
|
|
977 |
else
|
|
978 |
{
|
|
979 |
CMTPPlaybackCommand* cmd = CMTPPlaybackCommand::NewL( iMTPPBCmd, iCmdParam );
|
|
980 |
iCmdParam = NULL;//Ownership is handled to CMTPPlaybackCommand
|
|
981 |
CleanupStack::PushL(cmd);
|
|
982 |
iCallback->HandlePlaybackCommandCompleteL( cmd );
|
|
983 |
CleanupStack::PopAndDestroy(cmd);
|
|
984 |
|
|
985 |
ResetPlaybackCommand();
|
|
986 |
}
|
|
987 |
|
|
988 |
__FLOG(_L8("-CMTPPlaybackControlImpl::SendPlaybackCommandCompleteL"));
|
|
989 |
}
|
|
990 |
|
|
991 |
// ---------------------------------------------------------------------------
|
|
992 |
// CMTPPlaybackControlImpl::SendPlaybackEventL.
|
|
993 |
// ---------------------------------------------------------------------------
|
|
994 |
//
|
|
995 |
void CMTPPlaybackControlImpl::SendPlaybackEventL( TMTPPlaybackEvent aEvt )
|
|
996 |
{
|
|
997 |
__FLOG(_L8("+CMTPPlaybackControlImpl::SendPlaybackEventL"));
|
|
998 |
|
|
999 |
CMTPPlaybackEvent* event = CMTPPlaybackEvent::NewL( aEvt, NULL );
|
|
1000 |
CleanupStack::PushL(event);
|
|
1001 |
iObserver->HandlePlaybackEventL( event );
|
|
1002 |
CleanupStack::PopAndDestroy(event);
|
|
1003 |
|
|
1004 |
__FLOG(_L8("-CMTPPlaybackControlImpl::SendPlaybackEventL"));
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
// ---------------------------------------------------------------------------
|
|
1008 |
// CMTPPlaybackControlImpl::ResetPlaybackCommand.
|
|
1009 |
// ---------------------------------------------------------------------------
|
|
1010 |
//
|
|
1011 |
void CMTPPlaybackControlImpl::ResetPlaybackCommand()
|
|
1012 |
{
|
|
1013 |
__FLOG(_L8("+CMTPPlaybackControlImpl::ResetPlaybackCommand"));
|
|
1014 |
|
|
1015 |
iCallback = NULL;
|
|
1016 |
iMTPPBCmd = EPlaybackCmdNone;
|
|
1017 |
iPrepareCmdArray.Reset();
|
|
1018 |
iResumeCmdArray.Reset();
|
|
1019 |
delete iCmdParam;
|
|
1020 |
iCmdParam = NULL;
|
|
1021 |
|
|
1022 |
__FLOG(_L8("-CMTPPlaybackControlImpl::ResetPlaybackCommand"));
|
|
1023 |
}
|
|
1024 |
|
|
1025 |
// ---------------------------------------------------------------------------
|
|
1026 |
// Return current state
|
|
1027 |
// ---------------------------------------------------------------------------
|
|
1028 |
//
|
|
1029 |
TMPXPlaybackState CMTPPlaybackControlImpl::CurrentState() const
|
|
1030 |
{
|
|
1031 |
return iState;
|
|
1032 |
}
|
|
1033 |
|
|
1034 |
// ---------------------------------------------------------------------------
|
|
1035 |
// Return previous state
|
|
1036 |
// ---------------------------------------------------------------------------
|
|
1037 |
//
|
|
1038 |
TMPXPlaybackState CMTPPlaybackControlImpl::PreviousState() const
|
|
1039 |
{
|
|
1040 |
return iPreState;
|
|
1041 |
}
|
|
1042 |
|
|
1043 |
// ---------------------------------------------------------------------------
|
|
1044 |
// Return song count
|
|
1045 |
// ---------------------------------------------------------------------------
|
|
1046 |
//
|
|
1047 |
TInt32 CMTPPlaybackControlImpl::SongCount() const
|
|
1048 |
{
|
|
1049 |
TInt32 songCount = -1;
|
|
1050 |
if ( iPlayList )
|
|
1051 |
{
|
|
1052 |
songCount = iPlayList->Count();
|
|
1053 |
}
|
|
1054 |
return songCount;
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
// ---------------------------------------------------------------------------
|
|
1058 |
// Return song index
|
|
1059 |
// ---------------------------------------------------------------------------
|
|
1060 |
//
|
|
1061 |
TInt32 CMTPPlaybackControlImpl::SongIndex() const
|
|
1062 |
{
|
|
1063 |
TInt32 songIndex = -1;
|
|
1064 |
if ( iPlayList )
|
|
1065 |
{
|
|
1066 |
TInt level = iPlayList->Path().Levels();
|
|
1067 |
songIndex = iPlayList->Path().Index( level-1 );
|
|
1068 |
}
|
|
1069 |
return songIndex;
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
// ---------------------------------------------------------------------------
|
|
1073 |
// Set mtp playback command
|
|
1074 |
// ---------------------------------------------------------------------------
|
|
1075 |
//
|
|
1076 |
void CMTPPlaybackControlImpl::SetMTPPBCmd( TMTPPlaybackCommand aMTPPBCmd )
|
|
1077 |
{
|
|
1078 |
iMTPPBCmd = aMTPPBCmd;
|
|
1079 |
}
|
|
1080 |
|
|
1081 |
// ---------------------------------------------------------------------------
|
|
1082 |
// Return mtp playback command which is handling
|
|
1083 |
// ---------------------------------------------------------------------------
|
|
1084 |
//
|
|
1085 |
TMTPPlaybackCommand CMTPPlaybackControlImpl::MTPPBCmdHandling() const
|
|
1086 |
{
|
|
1087 |
if ( iPrepareCmdArray.Count() == 0 )
|
|
1088 |
{
|
|
1089 |
return iMTPPBCmd;
|
|
1090 |
}
|
|
1091 |
else
|
|
1092 |
{
|
|
1093 |
return EPlaybackCmdNone;
|
|
1094 |
}
|
|
1095 |
|
|
1096 |
}
|
|
1097 |
|