26
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-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: Music Player Action Handler Plugin
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <liwvariant.h> // TLiwVariant
|
|
20 |
#include <apgcli.h> // RApaLsSession, TApaAppInfo
|
|
21 |
#include <apacmdln.h> // CApaCommandLine
|
|
22 |
#include <apgtask.h> // TApaTaskList
|
|
23 |
#include <mpxlog.h> // MPX_DEBUG
|
|
24 |
#include <mpxparameter.h> // CMPXParameter
|
|
25 |
#include <mpxplaybackutility.h> // MMPXPlaybackUtility
|
|
26 |
#include <mpxconstants.h> // KAppUidMusicPlayerX
|
|
27 |
#include <mpxmusicplayerviewplugin.hrh> // KMPXPluginTypePlaybackUid
|
|
28 |
#include <AknTaskList.h> // CAknTaskList
|
|
29 |
#include <gfxtranseffect/gfxtranseffect.h>
|
|
30 |
#include <akntranseffect.h>
|
|
31 |
|
|
32 |
#include <mpxcommandgeneraldefs.h>
|
|
33 |
#include <mpxcommonuihelper.h>
|
|
34 |
#include <mpxcollectionhelperfactory.h>
|
|
35 |
#include "musicplayeractionhandler.h"
|
|
36 |
#include <mpxcollectionpath.h>
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
const TInt KPlayerMusicPlayerParameterGranularity = 50;
|
|
42 |
const TUid KMusicPlayerAppUid = { 0x102072C3 };
|
|
43 |
|
|
44 |
const TInt KMPXStandAloneProcessIDTop32( 1 );
|
|
45 |
const TInt KMPXStandAloneProcessIDBottom32( 2 );
|
|
46 |
// RProperty key to identify the case when Music Player launching
|
|
47 |
// in the background
|
|
48 |
const TInt KMPXLaunchingOnBackground( 100 );
|
|
49 |
|
|
50 |
//map values
|
|
51 |
_LIT( KActionPlaybackCommand , "PlaybackCommand" );
|
|
52 |
_LIT( KactionMessageToMusicPlayer, "MessageToMusicPlayer" );
|
|
53 |
_LIT( KGoToNowPlaying, "GoToNowPlaying" );
|
|
54 |
_LIT( KGoToLastPlayed, "GoToLastPlayed" );
|
|
55 |
_LIT( KGoToLastPlayedMinimized, "GoToLastPlayedMinimized" );
|
|
56 |
_LIT( KGoToMusicLibrary, "GoToMusicLibrary" );
|
|
57 |
_LIT( KGoToAlbumView, "GoToAlbumView" );
|
|
58 |
|
|
59 |
//map keys
|
|
60 |
_LIT8( KType, "type" );
|
|
61 |
_LIT8( KCommand, "command" );
|
|
62 |
_LIT8( KMessage, "message" );
|
|
63 |
|
|
64 |
// ======== MEMBER FUNCTIONS ========
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// Symbian 2nd phase constructor can leave.
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
void CMusicPlayerActionHandler::ConstructL()
|
|
71 |
{
|
|
72 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::ConstructL()");
|
|
73 |
|
|
74 |
//iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeActivePlayer );
|
|
75 |
//iPlaybackUtility = MMPXPlaybackUtility::NewL( KMusicPlayerAppUid);
|
|
76 |
|
|
77 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::ConstructL()");
|
|
78 |
}
|
|
79 |
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
// Two-phased constructor.
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
CMusicPlayerActionHandler* CMusicPlayerActionHandler::NewL()
|
|
85 |
{
|
|
86 |
CMusicPlayerActionHandler* self = CMusicPlayerActionHandler::NewLC();
|
|
87 |
CleanupStack::Pop( self );
|
|
88 |
return self;
|
|
89 |
}
|
|
90 |
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
// Two-phased constructor.
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
CMusicPlayerActionHandler* CMusicPlayerActionHandler::NewLC()
|
|
96 |
{
|
|
97 |
CMusicPlayerActionHandler* self = new( ELeave ) CMusicPlayerActionHandler;
|
|
98 |
CleanupStack::PushL( self );
|
|
99 |
self->ConstructL();
|
|
100 |
return self;
|
|
101 |
}
|
|
102 |
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
// destructor
|
|
105 |
// ---------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
CMusicPlayerActionHandler::~CMusicPlayerActionHandler()
|
|
108 |
{
|
|
109 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::~CMusicPlayerActionHandler()");
|
|
110 |
if ( iPlaybackUtility )
|
|
111 |
{
|
|
112 |
iPlaybackUtility->Close();
|
|
113 |
}
|
|
114 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::~CMusicPlayerActionHandler()");
|
|
115 |
}
|
|
116 |
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
// Executes Playback command on current player
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
TInt CMusicPlayerActionHandler::ExecutePlaybackCommandL(const CLiwMap* aMap)
|
|
122 |
{
|
|
123 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::ExecutePlaybackCommandL()");
|
|
124 |
TInt errCode;
|
|
125 |
TLiwVariant variant;
|
|
126 |
variant.PushL();
|
|
127 |
errCode = ExtractVariantL( aMap, variant, KCommand );
|
|
128 |
if ( errCode == KErrNone )
|
|
129 |
{
|
|
130 |
TMPXPlaybackCommand Command;
|
|
131 |
Command = static_cast<TMPXPlaybackCommand>( variant.AsTInt32() );
|
|
132 |
SetPlaybackCommandL( Command );
|
|
133 |
}
|
|
134 |
CleanupStack::PopAndDestroy( &variant);
|
|
135 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::ExecutePlaybackCommandL()");
|
|
136 |
return errCode;
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// Sends a message to music player
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
TInt CMusicPlayerActionHandler::ExecuteMessageToMusicPlayerL(
|
|
144 |
const CLiwMap* aMap )
|
|
145 |
{
|
|
146 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::"
|
|
147 |
"ExecuteMessageToMusicPlayerL()");
|
|
148 |
TInt errCode;
|
|
149 |
RBuf msg;
|
|
150 |
CleanupClosePushL( msg );
|
|
151 |
errCode = ExtractDesL( aMap, msg, KMessage );
|
|
152 |
if ( errCode == KErrNone )
|
|
153 |
{
|
|
154 |
if ( ! msg.CompareF( KGoToNowPlaying ) )
|
|
155 |
{
|
|
156 |
errCode = GoToNowPlayingL();
|
|
157 |
}
|
|
158 |
else if ( ! msg.CompareF( KGoToLastPlayed ) )
|
|
159 |
{
|
|
160 |
errCode = GoToLastPlayedL( EFalse );
|
|
161 |
}
|
|
162 |
else if ( ! msg.CompareF( KGoToLastPlayedMinimized ) )
|
|
163 |
{
|
|
164 |
errCode = GoToLastPlayedL( ETrue );
|
|
165 |
}
|
|
166 |
else if ( ! msg.CompareF( KGoToMusicLibrary ) )
|
|
167 |
{
|
|
168 |
errCode = GoToMusicLibraryL();
|
|
169 |
}
|
|
170 |
else if ( ! msg.CompareF( KGoToAlbumView ) )
|
|
171 |
{
|
|
172 |
errCode = GoToAlbumViewL();
|
|
173 |
}
|
|
174 |
}
|
|
175 |
CleanupStack::PopAndDestroy( &msg );
|
|
176 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::"
|
|
177 |
"ExecuteMessageToMusicPlayerL()");
|
|
178 |
return errCode;
|
|
179 |
}
|
|
180 |
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
// Opens musicplayer in library view, even if it is already open and playing.
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
TInt CMusicPlayerActionHandler::GoToMusicLibraryL()
|
|
186 |
{
|
|
187 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::GoToMusicLibraryL()");
|
|
188 |
//Launch player
|
|
189 |
RWsSession wsSession;
|
|
190 |
User::LeaveIfError( wsSession.Connect() );
|
|
191 |
CAknTaskList *taskList = CAknTaskList::NewL( wsSession );
|
|
192 |
TApaTask task = taskList->FindRootApp( KAppUidMusicPlayerX );
|
|
193 |
delete taskList;
|
|
194 |
CMPXParameter* param = new ( ELeave ) CMPXParameter();
|
|
195 |
CleanupStack::PushL( param );
|
|
196 |
param->iType.iUid = KMPXPluginTypeCollectionUid;
|
|
197 |
param->iCmdForward = EMPXCmdFwdNone;
|
|
198 |
|
|
199 |
MMPXCollectionUiHelper* collectionHelper = CMPXCollectionHelperFactory::NewCollectionUiHelperL();
|
|
200 |
CMPXCollectionPath* path = collectionHelper->MusicMenuPathL();
|
|
201 |
path->AppendL(3); // Albums
|
|
202 |
if (path)
|
|
203 |
{
|
|
204 |
param->iCollectionPath = path;
|
|
205 |
param->iPathType = EMPXTypeCollectionPath;
|
|
206 |
}
|
|
207 |
collectionHelper->Close();
|
|
208 |
|
|
209 |
CBufBase* buffer =
|
|
210 |
CBufFlat::NewL( KPlayerMusicPlayerParameterGranularity );
|
|
211 |
CleanupStack::PushL( buffer );
|
|
212 |
RBufWriteStream writeStream( *buffer );
|
|
213 |
CleanupClosePushL( writeStream );
|
|
214 |
param->ExternalizeL( writeStream );
|
|
215 |
writeStream.CommitL();
|
|
216 |
buffer->Compress();
|
|
217 |
CleanupStack::PopAndDestroy( &writeStream );
|
|
218 |
if ( task.Exists() )
|
|
219 |
{
|
|
220 |
// task.SendMessage( KAppUidMusicPlayerX, buffer->Ptr( 0 ));
|
|
221 |
BeginFullScreenTransEffect( KAppUidMusicPlayerX );
|
|
222 |
wsSession.SendMessageToWindowGroup( task.WgId(), KAppUidMusicPlayerX,
|
|
223 |
buffer->Ptr( 0 ) );
|
|
224 |
}
|
|
225 |
else //Application needs to be launched. The first view is library view.
|
|
226 |
{
|
|
227 |
// Launch Music Player Application
|
|
228 |
RApaLsSession appArcSession;
|
|
229 |
_LIT(KEmpty,"");
|
|
230 |
User::LeaveIfError(appArcSession.Connect()); // connect to AppArc server
|
|
231 |
TThreadId id;
|
|
232 |
appArcSession.StartDocument( KEmpty, KAppUidMusicPlayerX, id );
|
|
233 |
appArcSession.Close();
|
|
234 |
}
|
|
235 |
CleanupStack::PopAndDestroy( buffer );
|
|
236 |
CleanupStack::PopAndDestroy( param );
|
|
237 |
wsSession.Close();
|
|
238 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::GoToMusicLibraryL()");
|
|
239 |
return KErrNone;
|
|
240 |
}
|
|
241 |
|
|
242 |
// ---------------------------------------------------------------------------
|
|
243 |
// Opens musicplayer in Album and Artist view, even if it is already open and playing.
|
|
244 |
// ---------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
TInt CMusicPlayerActionHandler::GoToAlbumViewL()
|
|
247 |
{
|
|
248 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::GoToAlbumViewL()");
|
|
249 |
//Launch player
|
|
250 |
RWsSession wsSession;
|
|
251 |
User::LeaveIfError( wsSession.Connect() );
|
|
252 |
CAknTaskList *taskList = CAknTaskList::NewL( wsSession );
|
|
253 |
TApaTask task = taskList->FindRootApp( KAppUidMusicPlayerX );
|
|
254 |
delete taskList;
|
|
255 |
CMPXParameter* param = new ( ELeave ) CMPXParameter();
|
|
256 |
CleanupStack::PushL( param );
|
|
257 |
param->iType.iUid = KMPXPluginTypeCollectionUid;
|
|
258 |
param->iCmdForward = EMPXCmdFwdNone;
|
|
259 |
|
|
260 |
MMPXCollectionUiHelper* collectionHelper = CMPXCollectionHelperFactory::NewCollectionUiHelperL();
|
|
261 |
CMPXCollectionPath* path = collectionHelper->MusicMenuPathL();
|
|
262 |
path->AppendL(3); // Albums
|
|
263 |
if (path)
|
|
264 |
{
|
|
265 |
param->iCollectionPath = path;
|
|
266 |
param->iPathType = EMPXTypeCollectionPath;
|
|
267 |
}
|
|
268 |
collectionHelper->Close();
|
|
269 |
|
|
270 |
CBufBase* buffer =
|
|
271 |
CBufFlat::NewL( KPlayerMusicPlayerParameterGranularity );
|
|
272 |
CleanupStack::PushL( buffer );
|
|
273 |
RBufWriteStream writeStream( *buffer );
|
|
274 |
CleanupClosePushL( writeStream );
|
|
275 |
param->ExternalizeL( writeStream );
|
|
276 |
writeStream.CommitL();
|
|
277 |
buffer->Compress();
|
|
278 |
CleanupStack::PopAndDestroy( &writeStream );
|
|
279 |
if ( task.Exists() )
|
|
280 |
{
|
|
281 |
// task.SendMessage( KAppUidMusicPlayerX, buffer->Ptr( 0 ));
|
|
282 |
BeginFullScreenTransEffect( KAppUidMusicPlayerX );
|
|
283 |
wsSession.SendMessageToWindowGroup( task.WgId(), KAppUidMusicPlayerX,
|
|
284 |
buffer->Ptr( 0 ) );
|
|
285 |
}
|
|
286 |
else //Application needs to be launched. The first view is library view.
|
|
287 |
{
|
|
288 |
// Launch Music Player Application
|
|
289 |
RApaLsSession appArcSession;
|
|
290 |
_LIT(KEmpty,"");
|
|
291 |
User::LeaveIfError(appArcSession.Connect()); // connect to AppArc server
|
|
292 |
TThreadId id;
|
|
293 |
appArcSession.StartDocument( KEmpty, KAppUidMusicPlayerX, id );
|
|
294 |
appArcSession.Close();
|
|
295 |
}
|
|
296 |
CleanupStack::PopAndDestroy( buffer );
|
|
297 |
CleanupStack::PopAndDestroy( param );
|
|
298 |
wsSession.Close();
|
|
299 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::GoToAlbumViewL()");
|
|
300 |
return KErrNone;
|
|
301 |
}
|
|
302 |
|
|
303 |
|
|
304 |
// ---------------------------------------------------------------------------
|
|
305 |
// Opens musicplayer, if it is already open and playing it goes to nowplaying.
|
|
306 |
// ---------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
TInt CMusicPlayerActionHandler::GoToNowPlayingL()
|
|
309 |
{
|
|
310 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::GoToNowPlayingL()");
|
|
311 |
//Launch player
|
|
312 |
RWsSession wsSession;
|
|
313 |
User::LeaveIfError( wsSession.Connect() );
|
|
314 |
CAknTaskList *taskList = CAknTaskList::NewL( wsSession );
|
|
315 |
TApaTask task = taskList->FindRootApp( KAppUidMusicPlayerX );
|
|
316 |
delete taskList;
|
|
317 |
CMPXParameter* param = new ( ELeave ) CMPXParameter();
|
|
318 |
CleanupStack::PushL( param );
|
|
319 |
param->iType.iUid = KMPXPluginTypePlaybackUid;
|
|
320 |
param->iCmdForward = EMPXCmdFwdNone;
|
|
321 |
CBufBase* buffer =
|
|
322 |
CBufFlat::NewL( KPlayerMusicPlayerParameterGranularity );
|
|
323 |
CleanupStack::PushL( buffer );
|
|
324 |
RBufWriteStream writeStream( *buffer );
|
|
325 |
CleanupClosePushL( writeStream );
|
|
326 |
param->ExternalizeL( writeStream );
|
|
327 |
writeStream.CommitL();
|
|
328 |
buffer->Compress();
|
|
329 |
CleanupStack::PopAndDestroy( &writeStream );
|
|
330 |
if ( task.Exists() )
|
|
331 |
{
|
|
332 |
BeginFullScreenTransEffect( KAppUidMusicPlayerX );
|
|
333 |
wsSession.SendMessageToWindowGroup( task.WgId(), KAppUidMusicPlayerX,
|
|
334 |
buffer->Ptr( 0 ) );
|
|
335 |
|
|
336 |
|
|
337 |
}
|
|
338 |
else
|
|
339 |
{
|
|
340 |
RApaLsSession ls;
|
|
341 |
CleanupClosePushL( ls );
|
|
342 |
User::LeaveIfError( ls.Connect() );
|
|
343 |
TApaAppInfo appInfo;
|
|
344 |
User::LeaveIfError( ls.GetAppInfo( appInfo, KAppUidMusicPlayerX ) );
|
|
345 |
CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
|
|
346 |
apaCommandLine->SetExecutableNameL( appInfo.iFullName );
|
|
347 |
apaCommandLine->SetTailEndL( buffer->Ptr( 0 ) );
|
|
348 |
User::LeaveIfError( ls.StartApp( *apaCommandLine ) );
|
|
349 |
CleanupStack::PopAndDestroy(); // apaCommandLine
|
|
350 |
CleanupStack::PopAndDestroy(); // ls
|
|
351 |
}
|
|
352 |
CleanupStack::PopAndDestroy( buffer );
|
|
353 |
CleanupStack::PopAndDestroy( param );
|
|
354 |
wsSession.Close();
|
|
355 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::GoToNowPlayingL()");
|
|
356 |
return KErrNone;
|
|
357 |
}
|
|
358 |
|
|
359 |
|
|
360 |
// ---------------------------------------------------------------------------
|
|
361 |
// Opens Stand alone MP and goes to now playing, it will display last played
|
|
362 |
// ---------------------------------------------------------------------------
|
|
363 |
//
|
|
364 |
TInt CMusicPlayerActionHandler::GoToLastPlayedL( TBool aMinimized )
|
|
365 |
{
|
|
366 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::GoToLastPlayed()");
|
|
367 |
//Launch player
|
|
368 |
RWsSession wsSession;
|
|
369 |
User::LeaveIfError( wsSession.Connect() );
|
|
370 |
CAknTaskList *taskList = CAknTaskList::NewL( wsSession );
|
|
371 |
TApaTask task = taskList->FindRootApp( KAppUidMusicPlayerX );
|
|
372 |
delete taskList;
|
|
373 |
CMPXParameter* param = new ( ELeave ) CMPXParameter();
|
|
374 |
CleanupStack::PushL( param );
|
|
375 |
param->iType.iUid = KMPXPluginTypeLastPlayedUid;//KMPXPluginTypePlaybackUid;
|
|
376 |
param->iCmdForward = EMPXCmdFwdNone;
|
|
377 |
CBufBase* buffer =
|
|
378 |
CBufFlat::NewL( KPlayerMusicPlayerParameterGranularity );
|
|
379 |
CleanupStack::PushL( buffer );
|
|
380 |
RBufWriteStream writeStream( *buffer );
|
|
381 |
CleanupClosePushL( writeStream );
|
|
382 |
param->ExternalizeL( writeStream );
|
|
383 |
writeStream.CommitL();
|
|
384 |
buffer->Compress();
|
|
385 |
CleanupStack::PopAndDestroy( &writeStream );
|
|
386 |
if ( task.Exists() )
|
|
387 |
{
|
|
388 |
BeginFullScreenTransEffect( KAppUidMusicPlayerX );
|
|
389 |
wsSession.SendMessageToWindowGroup( task.WgId(), KAppUidMusicPlayerX,
|
|
390 |
buffer->Ptr( 0 ) );
|
|
391 |
if (!aMinimized)
|
|
392 |
{
|
|
393 |
task.BringToForeground();
|
|
394 |
}
|
|
395 |
}
|
|
396 |
else
|
|
397 |
{
|
|
398 |
RApaLsSession ls;
|
|
399 |
CleanupClosePushL( ls );
|
|
400 |
User::LeaveIfError( ls.Connect() );
|
|
401 |
TApaAppInfo appInfo;
|
|
402 |
User::LeaveIfError( ls.GetAppInfo( appInfo, KAppUidMusicPlayerX ) );
|
|
403 |
CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
|
|
404 |
if (aMinimized)
|
|
405 |
{
|
|
406 |
apaCommandLine->SetCommandL(EApaCommandBackground);
|
|
407 |
|
|
408 |
TInt err( RProperty::Define(
|
|
409 |
KAppUidMusicPlayerX, KMPXLaunchingOnBackground, RProperty::EInt ) );
|
|
410 |
MPX_DEBUG2( "CMusicPlayerActionHandler::GoToLastPlayed() RProperty define err = %d", err );
|
|
411 |
if ( err == KErrNone || err == KErrAlreadyExists )
|
|
412 |
{
|
|
413 |
err = RProperty::Set( KAppUidMusicPlayerX,
|
|
414 |
KMPXLaunchingOnBackground,
|
|
415 |
ETrue );
|
|
416 |
MPX_DEBUG2( "CMusicPlayerActionHandler::GoToLastPlayed() RProperty set to true err = %d", err );
|
|
417 |
}
|
|
418 |
}
|
|
419 |
apaCommandLine->SetExecutableNameL( appInfo.iFullName );
|
|
420 |
apaCommandLine->SetTailEndL( buffer->Ptr( 0 ) );
|
|
421 |
User::LeaveIfError( ls.StartApp( *apaCommandLine ) );
|
|
422 |
CleanupStack::PopAndDestroy(); // apaCommandLine
|
|
423 |
CleanupStack::PopAndDestroy(); // ls
|
|
424 |
|
|
425 |
if ( aMinimized )
|
|
426 |
{
|
|
427 |
TInt err = RProperty::Set( KAppUidMusicPlayerX,
|
|
428 |
KMPXLaunchingOnBackground,
|
|
429 |
EFalse );
|
|
430 |
MPX_DEBUG2( "CMusicPlayerActionHandler::GoToLastPlayed() RProperty set to false err = %d", err );
|
|
431 |
}
|
|
432 |
}
|
|
433 |
CleanupStack::PopAndDestroy( buffer );
|
|
434 |
CleanupStack::PopAndDestroy( param );
|
|
435 |
wsSession.Close();
|
|
436 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::GoToLastPlayed()");
|
|
437 |
return KErrNone;
|
|
438 |
}
|
|
439 |
// ---------------------------------------------------------------------------
|
|
440 |
// Extracts a descriptor
|
|
441 |
// ---------------------------------------------------------------------------
|
|
442 |
//
|
|
443 |
TInt CMusicPlayerActionHandler::ExtractDesL( const CLiwMap* aMap,
|
|
444 |
RBuf& aString, const TDesC8& aMapName )
|
|
445 |
{
|
|
446 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::ExtractDesL()");
|
|
447 |
TInt errCode( KErrArgument );
|
|
448 |
TLiwVariant variant;
|
|
449 |
variant.PushL();
|
|
450 |
TPtrC tempString( KNullDesC );
|
|
451 |
if ( aMap->FindL( aMapName, variant) )
|
|
452 |
{
|
|
453 |
variant.Get( tempString );
|
|
454 |
aString.ReAllocL( tempString.Length() );
|
|
455 |
aString.Append( tempString );
|
|
456 |
errCode = KErrNone;
|
|
457 |
}
|
|
458 |
CleanupStack::PopAndDestroy( &variant );
|
|
459 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::ExtractDesL()");
|
|
460 |
return errCode;
|
|
461 |
}
|
|
462 |
|
|
463 |
// ---------------------------------------------------------------------------
|
|
464 |
// Extract variant
|
|
465 |
// ---------------------------------------------------------------------------
|
|
466 |
//
|
|
467 |
TInt CMusicPlayerActionHandler::ExtractVariantL( const CLiwMap* aMap,
|
|
468 |
TLiwVariant& aVariant, const TDesC8& aMapName )
|
|
469 |
{
|
|
470 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::ExtractVariantL()");
|
|
471 |
TInt errCode( KErrNone );
|
|
472 |
if ( ! aMap->FindL( aMapName, aVariant ) )
|
|
473 |
{
|
|
474 |
errCode = KErrArgument;
|
|
475 |
}
|
|
476 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::ExtractVariantL()");
|
|
477 |
return errCode;
|
|
478 |
}
|
|
479 |
|
|
480 |
// ---------------------------------------------------------------------------
|
|
481 |
// From CAHPlugin
|
|
482 |
// Executes provided action
|
|
483 |
// ---------------------------------------------------------------------------
|
|
484 |
//
|
|
485 |
TInt CMusicPlayerActionHandler::ExecuteActionL( const CLiwMap* aMap )
|
|
486 |
{
|
|
487 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::ExecuteActionL()");
|
|
488 |
TInt errCode;
|
|
489 |
RBuf type;
|
|
490 |
CleanupClosePushL( type );
|
|
491 |
errCode = ExtractDesL( aMap, type, KType );
|
|
492 |
if ( errCode == KErrNone )
|
|
493 |
{
|
|
494 |
if ( ! type.CompareF( KActionPlaybackCommand ) )
|
|
495 |
{
|
|
496 |
errCode = ExecutePlaybackCommandL( aMap );
|
|
497 |
}
|
|
498 |
else
|
|
499 |
if ( ! type.CompareF( KactionMessageToMusicPlayer ) )
|
|
500 |
{
|
|
501 |
errCode = ExecuteMessageToMusicPlayerL( aMap );
|
|
502 |
}
|
|
503 |
}
|
|
504 |
CleanupStack::PopAndDestroy( &type );
|
|
505 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::ExecuteActionL()");
|
|
506 |
return errCode;
|
|
507 |
}
|
|
508 |
|
|
509 |
// ---------------------------------------------------------------------------
|
|
510 |
// Set the command to playbackUtility
|
|
511 |
// ---------------------------------------------------------------------------
|
|
512 |
//
|
|
513 |
void CMusicPlayerActionHandler::SetPlaybackCommandL( TMPXPlaybackCommand aCommand )
|
|
514 |
{
|
|
515 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::SetPlaybackCommandL()");
|
|
516 |
//Try to get musicplay StandAloneMode process id
|
|
517 |
TInt procId( 0 );
|
|
518 |
TUint64 mpProcId( 0 );
|
|
519 |
TInt err( RProperty::Get( KMusicPlayerAppUid, KMPXStandAloneProcessIDTop32, procId ) );
|
|
520 |
if ( err == KErrNone )
|
|
521 |
{
|
|
522 |
mpProcId = TUint64( procId ) << 32;
|
|
523 |
err = RProperty::Get( KMusicPlayerAppUid, KMPXStandAloneProcessIDBottom32, procId );
|
|
524 |
if ( err == KErrNone )
|
|
525 |
{
|
|
526 |
mpProcId += procId;
|
|
527 |
}
|
|
528 |
else
|
|
529 |
{
|
|
530 |
mpProcId = 0;
|
|
531 |
}
|
|
532 |
}
|
|
533 |
|
|
534 |
CMPXCommand* cmd( CMPXCommand::NewL() );
|
|
535 |
CleanupStack::PushL( cmd );
|
|
536 |
cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral );
|
|
537 |
cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
|
|
538 |
cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralType, aCommand );
|
|
539 |
cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralData, 0 );
|
|
540 |
if ( mpProcId )
|
|
541 |
{
|
|
542 |
//This attribute will be used by playbckEngine->iLastActiveProcess
|
|
543 |
cmd->SetTObjectValueL<TProcessId> ( KMPXCommandPlaybackGeneralClientPid, mpProcId );
|
|
544 |
}
|
|
545 |
if ( !iPlaybackUtility ) // Ensure that the utility exists
|
|
546 |
{
|
|
547 |
iPlaybackUtility = MMPXPlaybackUtility::NewL( KMusicPlayerAppUid);
|
|
548 |
}
|
|
549 |
|
|
550 |
iPlaybackUtility->CommandL( *cmd );
|
|
551 |
CleanupStack::PopAndDestroy( cmd );
|
|
552 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::SetPlaybackCommandL()");
|
|
553 |
}
|
|
554 |
|
|
555 |
// ---------------------------------------------------------------------------
|
|
556 |
// Sets a transition effect, to be called before bringing an application to foreground
|
|
557 |
// ---------------------------------------------------------------------------
|
|
558 |
//
|
|
559 |
void CMusicPlayerActionHandler::BeginFullScreenTransEffect( const TUid& aNext )
|
|
560 |
{
|
|
561 |
MPX_DEBUG1("-->CMusicPlayerActionHandler::BeginFullScreenTransEffect()");
|
|
562 |
GfxTransEffect::BeginFullScreen(
|
|
563 |
AknTransEffect::EApplicationStart,
|
|
564 |
TRect(),
|
|
565 |
AknTransEffect::EParameterType,
|
|
566 |
AknTransEffect::GfxTransParam( aNext,
|
|
567 |
AknTransEffect::TParameter::EActivateExplicitContinue ));
|
|
568 |
MPX_DEBUG1("<--CMusicPlayerActionHandler::BeginFullScreenTransEffect()");
|
|
569 |
}
|
|
570 |
// End of File
|
|
571 |
|