0
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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: DRM Player
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "SimpleSoundPlayer.h"
|
|
19 |
|
|
20 |
const TInt CSimpleSoundPlayer::KPlayerActionPlay = 1;
|
|
21 |
const TInt CSimpleSoundPlayer::KPlayerActionPause = 2;
|
|
22 |
const TInt CSimpleSoundPlayer::KPlayerActionStopPlayFile = 3;
|
|
23 |
const TInt CSimpleSoundPlayer::KPlayerActionReportPosition = 4;
|
|
24 |
const TInt CSimpleSoundPlayer::KPlayerActionReportDuration = 5;
|
|
25 |
const TInt CSimpleSoundPlayer::KPlayerActionStopPlayDes = 6;
|
|
26 |
const TInt CSimpleSoundPlayer::KPlayerActionReportVolume = 7;
|
|
27 |
const TInt CSimpleSoundPlayer::KPlayerActionStopPlayUrl = 8;
|
|
28 |
const TInt CSimpleSoundPlayer::KPlayerActionStopPlayFileHandler = 9;
|
|
29 |
const TInt CSimpleSoundPlayer::KPlayerActionOpen = 10;
|
|
30 |
const TInt CSimpleSoundPlayer::KPlayerActionOpenFileHandler = 11;
|
|
31 |
const TInt CSimpleSoundPlayer::KplayerActionSetVolume = 12;
|
|
32 |
const TInt CSimpleSoundPlayer::KplayerActionGetBalance = 13;
|
|
33 |
const TInt CSimpleSoundPlayer::KplayerActionGetBitRate = 14;
|
|
34 |
const TInt CSimpleSoundPlayer::KplayerActionGetAudioLoadingProgress = 15;
|
|
35 |
const TInt CSimpleSoundPlayer::KplayerActionRegisterForAudioLoadingNotification = 16;
|
|
36 |
const TInt CSimpleSoundPlayer::KplayerActionControllerImplementationInformation = 17;
|
|
37 |
const TInt CSimpleSoundPlayer::KplayerActionMaxVolume = 18;
|
|
38 |
const TInt CSimpleSoundPlayer::KplayerActionSetBalance = 19;
|
|
39 |
const TInt CSimpleSoundPlayer::KplayerActionSetPriority = 20;
|
|
40 |
const TInt CSimpleSoundPlayer::KplayerActionSetRepeats = 21;
|
|
41 |
const TInt CSimpleSoundPlayer::KPlayerActionGetMetaDataEntry = 22;
|
|
42 |
const TInt CSimpleSoundPlayer::KPlayerActionGetNumberOfMetaDataEntries = 23;
|
5
|
43 |
const TInt CSimpleSoundPlayer::KPlayerActionCustomCommand = 24;
|
0
|
44 |
|
|
45 |
|
|
46 |
CSimpleSoundPlayer::CSimpleSoundPlayer(CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate, TBool aFileType)
|
|
47 |
: iConsole(aConsole) , iImmediate(aImmediate) , iLogger(aLogger) , iSoundOpen(EFalse),
|
|
48 |
iFinalError(KErrNone), iFileType(aFileType)
|
|
49 |
{
|
|
50 |
iSupervisor =0 ;
|
|
51 |
iEventTarget=0;
|
|
52 |
iParameters =0;
|
|
53 |
iPlayerId =0 ;
|
|
54 |
iPlayVolume = false;
|
|
55 |
iMetaInfo = false;
|
|
56 |
iMetaInfoTest = false;
|
|
57 |
iPlayWindow = false;
|
|
58 |
iClearWindow = false;
|
|
59 |
iSetBalance = false;
|
|
60 |
iFsOpened = false;
|
|
61 |
iDontPlayAudioClip = false;
|
|
62 |
iIsLoopPlayEnabled = EFalse;
|
|
63 |
}
|
|
64 |
|
|
65 |
void CSimpleSoundPlayer::ConstructUrlL(const TDesC &aUrl, TInt aIapId, const TDesC8 &aMime)
|
|
66 |
{
|
|
67 |
iMdaPlayer=CDrmPlayerUtility::NewL(*this, KAudioPriorityRealOnePlayer,
|
|
68 |
TMdaPriorityPreference(KAudioPrefRealOneLocalPlayback));
|
|
69 |
//KUseDefaultIap
|
|
70 |
iMdaPlayer->OpenUrlL(aUrl, aIapId, aMime );
|
|
71 |
iSoundOpen=ETrue;
|
|
72 |
|
|
73 |
_LIT(KPlayerCreated, "SoundPlayerCreated");
|
|
74 |
iConsole.Printf(100, KPlayerCreated, KPlayerCreated);
|
|
75 |
}
|
|
76 |
CSimpleSoundPlayer* CSimpleSoundPlayer::NewUrlL(const TDesC &aUrl, TInt aIapId, const TDesC8 &aMime, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate)
|
|
77 |
{
|
|
78 |
CSimpleSoundPlayer* self = NewUrlLC(aUrl, aIapId, aMime, aConsole, aLogger, aImmediate);
|
|
79 |
CleanupStack::Pop(self);
|
|
80 |
return self;
|
|
81 |
}
|
|
82 |
CSimpleSoundPlayer* CSimpleSoundPlayer::NewUrlLC(const TDesC &aUrl, TInt aIapId, const TDesC8 &aMime, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate)
|
|
83 |
{
|
|
84 |
CSimpleSoundPlayer* self = new (ELeave) CSimpleSoundPlayer(aConsole, aLogger, aImmediate);
|
|
85 |
CleanupStack::PushL(self);
|
|
86 |
self->ConstructUrlL(aUrl, aIapId, aMime);
|
|
87 |
return self;
|
|
88 |
}
|
|
89 |
|
|
90 |
|
|
91 |
void CSimpleSoundPlayer::ConstructL(const TDesC8 &aDescriptor)
|
|
92 |
{
|
|
93 |
// Create a file audio player utility instance
|
|
94 |
//iMdaPlayer=CMdaAudioPlayerUtility::NewFilePlayerL(aFile, *this); //Para usar creación inmediata
|
|
95 |
|
|
96 |
if (iImmediate)
|
|
97 |
{
|
|
98 |
if (iFileType)
|
|
99 |
{
|
|
100 |
iMdaPlayer=CDrmPlayerUtility::NewDesPlayerReadOnlyL(aDescriptor,*this, KAudioPriorityRealOnePlayer,
|
|
101 |
TMdaPriorityPreference(KAudioPrefRealOneLocalPlayback)); //For inmediate instantiation
|
|
102 |
}
|
|
103 |
else
|
|
104 |
{
|
|
105 |
iMdaPlayer=CDrmPlayerUtility::NewDesPlayerL(aDescriptor,*this, KAudioPriorityRealOnePlayer,
|
|
106 |
TMdaPriorityPreference(KAudioPrefRealOneLocalPlayback)); //For inmediate instantiation
|
|
107 |
}
|
|
108 |
|
|
109 |
/* iMdaPlayer=CDrmPlayerUtility::NewL(*this, KAudioPriorityRealOnePlayer,
|
|
110 |
TMdaPriorityPreference(KAudioPrefRealOneLocalPlayback)); //Por Pasos
|
|
111 |
iMdaPlayer->OpenDesL(aDescriptor);
|
|
112 |
iSoundOpen=ETrue; */
|
|
113 |
}
|
|
114 |
else if (!iImmediate)
|
|
115 |
{
|
|
116 |
iMdaPlayer=CDrmPlayerUtility::NewL(*this, KAudioPriorityRealOnePlayer,
|
|
117 |
TMdaPriorityPreference(KAudioPrefRealOneLocalPlayback)); //Por Pasos
|
|
118 |
iMdaPlayer->OpenDesL(aDescriptor);
|
|
119 |
iSoundOpen=ETrue;
|
|
120 |
}
|
|
121 |
_LIT(KPlayerCreated, "SoundPlayerCreated");
|
|
122 |
iConsole.Printf(100, KPlayerCreated, KPlayerCreated);
|
|
123 |
}
|
|
124 |
CSimpleSoundPlayer* CSimpleSoundPlayer::NewL(const TDesC8 &aDescriptor, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate, TBool aDesReadOnly)
|
|
125 |
{
|
|
126 |
CSimpleSoundPlayer* self = NewLC(aDescriptor, aConsole, aLogger, aImmediate, aDesReadOnly);
|
|
127 |
CleanupStack::Pop(self);
|
|
128 |
return self;
|
|
129 |
}
|
|
130 |
CSimpleSoundPlayer* CSimpleSoundPlayer::NewLC(const TDesC8 &aDescriptor, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate, TBool aDesReadOnly)
|
|
131 |
{
|
|
132 |
CSimpleSoundPlayer* self = new (ELeave) CSimpleSoundPlayer(aConsole, aLogger, aImmediate, aDesReadOnly);
|
|
133 |
CleanupStack::PushL(self);
|
|
134 |
self->ConstructL(aDescriptor);
|
|
135 |
return self;
|
|
136 |
}
|
|
137 |
|
|
138 |
void CSimpleSoundPlayer::ConstructL(const TFileName &aFile)
|
|
139 |
{
|
|
140 |
// Create a file audio player utility instance
|
|
141 |
//iMdaPlayer=CMdaAudioPlayerUtility::NewFilePlayerL(aFile, *this); //For inmediate instantiation
|
|
142 |
if (iImmediate)
|
|
143 |
{
|
|
144 |
iMdaPlayer=CDrmPlayerUtility::NewFilePlayerL(aFile,*this, KAudioPriorityRealOnePlayer,
|
|
145 |
TMdaPriorityPreference(KAudioPrefRealOneLocalPlayback)); //For inmediate instantiation
|
|
146 |
}
|
|
147 |
else if (!iImmediate)
|
|
148 |
{
|
|
149 |
iImmediate = ETrue;
|
|
150 |
iMdaPlayer=CDrmPlayerUtility::NewL(*this, KAudioPriorityRealOnePlayer,
|
|
151 |
TMdaPriorityPreference(KAudioPrefRealOneLocalPlayback)); //Instantiation by steps
|
|
152 |
|
|
153 |
if (iFileType)
|
|
154 |
{
|
|
155 |
TMMFileSource FileName = aFile;
|
|
156 |
iLogger.Log(_L("Opening file [%S] with FileType 1") , &FileName.Name());
|
|
157 |
// TRAPD(err1,iMdaPlayer->OpenFileL(FileName));
|
|
158 |
iMdaPlayer->OpenFileL(FileName);
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
iLogger.Log(_L("Opening file with FileType 0"));
|
|
163 |
// TRAPD(err,iMdaPlayer->OpenFileL(aFile));
|
|
164 |
iMdaPlayer->OpenFileL(aFile);
|
|
165 |
}
|
|
166 |
|
|
167 |
iSoundOpen=ETrue;
|
|
168 |
}
|
|
169 |
|
|
170 |
_LIT(KPlayerCreated, "SoundPlayerCreated");
|
|
171 |
iConsole.Printf(100, KPlayerCreated, KPlayerCreated);
|
|
172 |
}
|
|
173 |
|
|
174 |
CSimpleSoundPlayer* CSimpleSoundPlayer::NewLC(const TFileName &aFile, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate, TBool aFileType)
|
|
175 |
{
|
|
176 |
CSimpleSoundPlayer* self = new (ELeave) CSimpleSoundPlayer(aConsole, aLogger, aImmediate, aFileType);
|
|
177 |
CleanupStack::PushL(self);
|
|
178 |
self->ConstructL(aFile);
|
|
179 |
return self;
|
|
180 |
}
|
|
181 |
|
|
182 |
CSimpleSoundPlayer* CSimpleSoundPlayer::NewL(const TFileName &aFile, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate, TBool aFileType)
|
|
183 |
{
|
|
184 |
CSimpleSoundPlayer* self = NewLC(aFile, aConsole, aLogger, aImmediate, aFileType);
|
|
185 |
CleanupStack::Pop(self);
|
|
186 |
return self;
|
|
187 |
}
|
|
188 |
|
|
189 |
void CSimpleSoundPlayer::ConstructL(const RFile &aFile)
|
|
190 |
{
|
|
191 |
// Create a file audio player utility instance
|
|
192 |
//iMdaPlayer=CMdaAudioPlayerUtility::NewFilePlayerL(aFile, *this); //For inmediate instantiation
|
|
193 |
|
|
194 |
// iMdaPlayer=CDrmPlayerUtility::NewL(*this, KAudioPriorityRealOnePlayer, TMdaPriorityPreference(KAudioPrefRealOneLocalPlayback)); //Instantiation by steps
|
|
195 |
iMdaPlayer=CDrmPlayerUtility::NewL(*this, EMdaPriorityNormal, TMdaPriorityPreference(EMdaPriorityPreferenceTimeAndQuality));
|
|
196 |
iMdaPlayer->OpenFileL(aFile);
|
|
197 |
iSoundOpen=ETrue;
|
|
198 |
|
|
199 |
_LIT(KPlayerCreated, "SoundPlayerCreated");
|
|
200 |
iConsole.Printf(100, KPlayerCreated, KPlayerCreated);
|
|
201 |
}
|
|
202 |
|
|
203 |
CSimpleSoundPlayer* CSimpleSoundPlayer::NewLC(const RFile &aFile, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate)
|
|
204 |
{
|
|
205 |
CSimpleSoundPlayer* self = new (ELeave) CSimpleSoundPlayer(aConsole, aLogger, aImmediate);
|
|
206 |
CleanupStack::PushL(self);
|
|
207 |
self->ConstructL(aFile);
|
|
208 |
return self;
|
|
209 |
}
|
|
210 |
|
|
211 |
CSimpleSoundPlayer* CSimpleSoundPlayer::NewL(const RFile &aFile, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate)
|
|
212 |
{
|
|
213 |
CSimpleSoundPlayer* self = NewLC(aFile, aConsole, aLogger, aImmediate);
|
|
214 |
CleanupStack::Pop(self);
|
|
215 |
return self;
|
|
216 |
}
|
|
217 |
|
|
218 |
void CSimpleSoundPlayer::MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &/*aDuration*/)
|
|
219 |
{
|
|
220 |
iLogger.Log(_L("MapcInitComplete"));
|
|
221 |
if (iFsOpened)
|
|
222 |
{
|
|
223 |
iFs.Close();
|
|
224 |
iFsOpened = false;
|
|
225 |
}
|
|
226 |
if (iImmediate)
|
|
227 |
{
|
|
228 |
if (aError == KErrNone)
|
|
229 |
{
|
|
230 |
_LIT(KGonnaPlay, "MapcInitComplete, GoingToPlay");
|
|
231 |
_LIT(KGoing, "Going to");
|
|
232 |
_LIT(KDone, "Done Started Playing");
|
|
233 |
iConsole.Printf(100, KGonnaPlay, KGoing);
|
|
234 |
if (iPlayVolume)
|
|
235 |
{
|
|
236 |
// TInt VolumeHigh;
|
|
237 |
iLogger.Log(_L("SetVolume") );
|
|
238 |
iMdaPlayer->SetVolume(iMdaPlayer->MaxVolume());
|
|
239 |
iLogger.Log(_L("SetVolume(iMdaPlayer->MaxVolume()) max=(%d)"), iMdaPlayer->MaxVolume() );
|
|
240 |
}
|
|
241 |
if (iMetaInfo)
|
|
242 |
{
|
|
243 |
TInt NumMetaDatas = 0;
|
|
244 |
TInt MetaDataError = iMdaPlayer->GetNumberOfMetaDataEntries(NumMetaDatas);
|
|
245 |
if ( MetaDataError )
|
|
246 |
{ //Error getting meta data info
|
|
247 |
Exit(MetaDataError);
|
|
248 |
}
|
|
249 |
// else
|
|
250 |
if (iMetaInfoTest)
|
|
251 |
{ //No error yet
|
|
252 |
TInt currMetaDataIndex = 0;
|
|
253 |
CMMFMetaDataEntry* currMetaData = NULL;
|
|
254 |
for ( currMetaDataIndex=0 ; currMetaDataIndex < NumMetaDatas ; currMetaDataIndex++)
|
|
255 |
{
|
|
256 |
currMetaData = iMdaPlayer->GetMetaDataEntryL(currMetaDataIndex);
|
|
257 |
iLogger.Log(_L("MetaData[%d]: Name: [%S], Value: [%S]") , currMetaDataIndex , &(currMetaData->Name()) , &(currMetaData->Value()) );
|
|
258 |
// currMetaData = NULL;
|
|
259 |
}
|
|
260 |
delete currMetaData;
|
|
261 |
currMetaData = NULL;
|
|
262 |
}
|
|
263 |
}
|
|
264 |
if (iPlayWindow)
|
|
265 |
{
|
|
266 |
TInt err = iMdaPlayer->SetPlayWindow(iStartPosition, iEndPosition);
|
|
267 |
iLogger.Log(_L("SetPlayWindow, start=[%d]"),iStartPosition.Int64());
|
|
268 |
iLogger.Log(_L("SetPlayWindow, end=[%d]"), iEndPosition.Int64() );
|
|
269 |
iLogger.Log(_L("SetPlayWindow, error = [%d]"),err);
|
|
270 |
if (iClearWindow)
|
|
271 |
{
|
|
272 |
iLogger.Log(_L("ClearPlayWindow"));
|
|
273 |
iMdaPlayer->ClearPlayWindow();
|
|
274 |
}
|
|
275 |
}
|
|
276 |
if (iSetBalance)
|
|
277 |
{
|
|
278 |
SetBalance(iBalance);
|
|
279 |
}
|
|
280 |
if (iDontPlayAudioClip)
|
|
281 |
{
|
|
282 |
iState = EReady;
|
|
283 |
Exit(aError);
|
|
284 |
}
|
|
285 |
else
|
|
286 |
{
|
|
287 |
iState = EPlaying;
|
|
288 |
iLastPlayTime.HomeTime();
|
|
289 |
iLastStopTime.HomeTime();
|
|
290 |
// do not manually set the position here. if play window is set then the position is set to 0 (iPosition)
|
|
291 |
// instead the position must be set to the play window start position otherwise it crashes.
|
|
292 |
if (!iPlayWindow)
|
|
293 |
{
|
|
294 |
iLogger.Log(_L("Position before Play (%d)"), I64INT(iPosition.Int64())/1000000);
|
|
295 |
iMdaPlayer->SetPosition(iPosition);
|
|
296 |
}
|
|
297 |
iMdaPlayer->Play();
|
|
298 |
iLogger.Log(_L("Play() was called"));
|
|
299 |
iConsole.Printf(100, KGonnaPlay, KDone);
|
|
300 |
}
|
|
301 |
}
|
|
302 |
else
|
|
303 |
{
|
|
304 |
iLogger.Log(_L("InitError (%d)"), aError);
|
|
305 |
iState = ENotReady;
|
|
306 |
Exit(aError);
|
|
307 |
}
|
|
308 |
}
|
|
309 |
else
|
|
310 |
{
|
|
311 |
iLogger.Log(_L("InitComplete, error(%d)") , aError);
|
|
312 |
iState = aError ? ENotReady : EReady;
|
|
313 |
if (aError)
|
|
314 |
{
|
|
315 |
Exit(aError);
|
|
316 |
}
|
|
317 |
}
|
|
318 |
}
|
|
319 |
|
|
320 |
TInt CSimpleSoundPlayer::Pause()
|
|
321 |
{
|
|
322 |
iLogger.Log(_L("Requested Pause"));
|
|
323 |
iState=EPaused;
|
|
324 |
iMdaPlayer->Pause();
|
|
325 |
return KErrNone;
|
|
326 |
}
|
|
327 |
|
|
328 |
TInt CSimpleSoundPlayer::OpenL(const TFileName &aFileName , const TBool &aImmediate=ETrue)
|
|
329 |
{
|
|
330 |
TMMFileSource FileName = aFileName;
|
|
331 |
// TMMFileSource* FileName = aFileName;
|
|
332 |
// FileName->TMMFileSource((TDesC*)aFileName);//= (TMMSource*) aFileName;
|
|
333 |
iImmediate = aImmediate;
|
|
334 |
// Stop();
|
|
335 |
// iLogger.Log(_L("Stop before opening file"));
|
|
336 |
|
|
337 |
iLogger.Log(_L("Opening [%S]") , &aFileName);
|
|
338 |
iMdaPlayer->OpenFileL(FileName);
|
|
339 |
iSoundOpen=ETrue;
|
|
340 |
iLogger.Log(_L("Opened"));
|
|
341 |
return KErrNone;
|
|
342 |
}
|
|
343 |
|
|
344 |
TInt CSimpleSoundPlayer::OpenFileHandlerL(const TFileName &aFileName , const TBool &aImmediate=ETrue)
|
|
345 |
{
|
|
346 |
iImmediate = aImmediate;
|
|
347 |
// Stop();
|
|
348 |
// iLogger.Log(_L("Stop before opening file"));
|
|
349 |
|
|
350 |
iLogger.Log(_L("Opening [%S]") , &aFileName);
|
|
351 |
|
|
352 |
// RFs aFs;
|
|
353 |
// RFile aFileHandler;
|
|
354 |
User::LeaveIfError(iFs.Connect());
|
|
355 |
iFs.ShareProtected();
|
|
356 |
|
|
357 |
User::LeaveIfError(iFileHandler.Open( iFs, aFileName, EFileRead));
|
|
358 |
iMdaPlayer->OpenFileL(iFileHandler);
|
|
359 |
|
|
360 |
iFileHandler.Close();
|
|
361 |
iFsOpened = ETrue;
|
|
362 |
// aFs.Close();
|
|
363 |
|
|
364 |
iSoundOpen=ETrue;
|
|
365 |
iLogger.Log(_L("Opened"));
|
|
366 |
return KErrNone;
|
|
367 |
}
|
|
368 |
|
|
369 |
TInt CSimpleSoundPlayer::OpenUrlL(const TDesC &aUrl, TInt aIapId, const TDesC8 &aMime)
|
|
370 |
{
|
|
371 |
iLogger.Log(_L("Opening url [%S] with IapId [%s]") , &aUrl , aIapId );
|
|
372 |
iLogger.Log(_L8(" and MIME Type [%S]") , &aMime);
|
|
373 |
iMdaPlayer->OpenUrlL(aUrl, aIapId, aMime);
|
|
374 |
return ETrue;
|
|
375 |
}
|
|
376 |
|
|
377 |
TInt CSimpleSoundPlayer::OpenDesL(const TDesC8 &aSoundDes , const TBool &aImmediate)
|
|
378 |
{
|
|
379 |
iImmediate = aImmediate;
|
|
380 |
Stop();
|
|
381 |
iLogger.Log(_L("Stop before opening descriptor"));
|
|
382 |
|
|
383 |
iLogger.Log(_L("Closed, opening second descriptor of length (%d)") , aSoundDes.Length() );
|
|
384 |
|
|
385 |
iMdaPlayer->OpenDesL(aSoundDes);
|
|
386 |
iSoundOpen=ETrue;
|
|
387 |
iLogger.Log(_L("Opened"));
|
|
388 |
////iAutoClose = ETrue; ///K
|
|
389 |
return KErrNone;
|
|
390 |
}
|
|
391 |
|
|
392 |
TInt CSimpleSoundPlayer::Play()
|
|
393 |
{
|
|
394 |
if(iState==EReady || iState==EPaused)
|
|
395 |
{
|
|
396 |
iState=EPlaying;
|
|
397 |
iLastPlayTime.HomeTime();
|
|
398 |
iLastStopTime.HomeTime();
|
|
399 |
iMdaPlayer->Play();
|
|
400 |
iLogger.Log(_L("Requested Play"));
|
|
401 |
}
|
|
402 |
else
|
|
403 |
{
|
|
404 |
iLogger.Log(_L("Requested Play, Not Ready to play"));
|
|
405 |
iImmediate = true;
|
|
406 |
}
|
|
407 |
return KErrNone;
|
|
408 |
}
|
|
409 |
|
|
410 |
TInt CSimpleSoundPlayer::Stop(const TBool &aAlsoClose)
|
|
411 |
{
|
|
412 |
iLogger.Log(_L("Requested Stop,,,,,"));
|
|
413 |
iMdaPlayer->Stop();
|
|
414 |
iLogger.Log(_L("Requested Stop,,,,, successful"));
|
|
415 |
iLastStopTime.HomeTime();
|
|
416 |
if (aAlsoClose)
|
|
417 |
{
|
|
418 |
iLogger.Log(_L("iMdaPlayer->Close()" ));
|
|
419 |
iMdaPlayer->Close();
|
|
420 |
iLogger.Log(_L("iMdaPlayer->Close() successful" ));
|
|
421 |
iSoundOpen=EFalse;
|
|
422 |
iState = ENotReady;
|
|
423 |
}
|
|
424 |
else
|
|
425 |
{
|
|
426 |
if (iState==EPlaying || iState==EPaused) {iState = EReady;}
|
|
427 |
}
|
|
428 |
return KErrNone;
|
|
429 |
}
|
|
430 |
|
|
431 |
void CSimpleSoundPlayer::MdapcPlayComplete(TInt aError)
|
|
432 |
{
|
|
433 |
iLastStopTime.HomeTime();
|
|
434 |
iLogger.Log(_L("MapcPlayComplete, error (%d)") , aError);
|
|
435 |
|
|
436 |
_LIT(KGonnaPlay, "MapcPlayComplete, GoingToPlay");
|
|
437 |
_LIT(KGoing, "Going to");
|
|
438 |
|
|
439 |
iConsole.Printf(100, KGonnaPlay, KGoing);
|
|
440 |
|
|
441 |
iState = aError ? ENotReady : EReady;
|
|
442 |
iConsole.Printf(100, KGonnaPlay, KGoing);
|
|
443 |
|
|
444 |
Exit(aError);
|
|
445 |
if (iEventTarget && iParameters)
|
|
446 |
{
|
|
447 |
Stop();
|
|
448 |
iEventTarget->ExecuteL(iParameters) ;
|
|
449 |
}
|
|
450 |
}
|
|
451 |
|
|
452 |
CSimpleSoundPlayer::~CSimpleSoundPlayer()
|
|
453 |
{
|
|
454 |
iLogger.Log(_L("Trying to stop player") );
|
|
455 |
iMdaPlayer->Stop();
|
|
456 |
iLogger.Log(_L("Trying to close player") );
|
|
457 |
iMdaPlayer->Close();
|
|
458 |
iLogger.Log(_L(" Player stopped") );
|
|
459 |
delete iMdaPlayer;
|
|
460 |
iMdaPlayer = NULL;
|
|
461 |
|
|
462 |
delete iEventTarget;
|
|
463 |
delete iParameters;
|
|
464 |
delete iSupervisor;
|
|
465 |
}
|
|
466 |
|
|
467 |
TTimeIntervalMicroSeconds CSimpleSoundPlayer::GetDuration()
|
|
468 |
{
|
|
469 |
TTimeIntervalMicroSeconds duration = iMdaPlayer->Duration();
|
|
470 |
iLogger.Log(_L("CMdaAudioPlayerUtility::Duration() returned [%d]") , duration.Int64() );
|
|
471 |
return duration;
|
|
472 |
}
|
|
473 |
|
|
474 |
TTimeIntervalMicroSeconds CSimpleSoundPlayer::GetPlayDuration() { return iLastStopTime.MicroSecondsFrom(iLastPlayTime); }
|
|
475 |
|
|
476 |
TTime CSimpleSoundPlayer::GetPlayStartTime() { return iLastPlayTime; }
|
|
477 |
|
|
478 |
TTime CSimpleSoundPlayer::GetPlayStopTime() { return iLastStopTime; }
|
|
479 |
|
|
480 |
TInt CSimpleSoundPlayer::GetBitRate(TUint &aBitRate)
|
|
481 |
{
|
|
482 |
TInt error = iMdaPlayer->GetBitRate(aBitRate);
|
|
483 |
iLogger.Log(_L("Retrieving BitRate (%d), error(%d)") , aBitRate, error);
|
|
484 |
return error;
|
|
485 |
}
|
|
486 |
|
|
487 |
TInt CSimpleSoundPlayer::GetBalance(TInt &aBalance)
|
|
488 |
{
|
|
489 |
TInt error = iMdaPlayer->GetBalance(aBalance);
|
|
490 |
iLogger.Log(_L("Retrieving Balance (%d), error(%d)") , aBalance, error);
|
|
491 |
return error;
|
|
492 |
}
|
|
493 |
|
|
494 |
TInt CSimpleSoundPlayer::SetBalance(TInt aBalance=KMMFBalanceCenter)
|
|
495 |
{
|
|
496 |
TInt error=KErrNone;
|
|
497 |
TInt error2=KErrNone;
|
|
498 |
TInt OldBalance=0;
|
|
499 |
|
|
500 |
iLogger.Log(_L("Changing Balance "));
|
|
501 |
|
|
502 |
error=iMdaPlayer->GetBalance(OldBalance);
|
|
503 |
if (error)
|
|
504 |
{
|
|
505 |
iLogger.Log(_L(" Error getting old balance (%d)"), error) ;
|
|
506 |
}
|
|
507 |
else
|
|
508 |
{
|
|
509 |
iLogger.Log(_L(" Previous balance: %d"), OldBalance);
|
|
510 |
}
|
|
511 |
iLogger.Log(_L(" Setting balance to %d"), aBalance);
|
|
512 |
error2 = iMdaPlayer->SetBalance(aBalance);
|
|
513 |
if (error2)
|
|
514 |
{
|
|
515 |
iLogger.Log(_L(" Error setting new balance (%d)") , error);
|
|
516 |
}
|
|
517 |
else
|
|
518 |
{
|
|
519 |
error=iMdaPlayer->GetBalance(OldBalance);
|
|
520 |
if (error)
|
|
521 |
{
|
|
522 |
iLogger.Log(_L(" Error getting new balance (%d)"), error) ;
|
|
523 |
}
|
|
524 |
else
|
|
525 |
{
|
|
526 |
iLogger.Log(_L(" Current balance: %d"), OldBalance);
|
|
527 |
}
|
|
528 |
}
|
|
529 |
|
|
530 |
if (OldBalance!= aBalance)
|
|
531 |
{
|
|
532 |
Exit(-1502);
|
|
533 |
}
|
|
534 |
|
|
535 |
return error2;
|
|
536 |
}
|
|
537 |
|
|
538 |
TInt CSimpleSoundPlayer::SetPriority(TInt aPriority, TMdaPriorityPreference aPref)
|
|
539 |
{
|
|
540 |
iLogger.Log(_L("Trying to set priority settings to (%d),(%d) ") , aPriority, aPref);
|
|
541 |
TInt PriorityError = iMdaPlayer->SetPriority(aPriority, aPref);
|
|
542 |
if (PriorityError)
|
|
543 |
{
|
|
544 |
iLogger.Log(_L("Error setting priority to (%d),(%d) ") , aPriority, aPref);
|
|
545 |
}
|
|
546 |
else
|
|
547 |
{
|
|
548 |
iLogger.Log(_L("Priority set to (%d),(%d)") , aPriority, aPref);
|
|
549 |
}
|
|
550 |
return PriorityError;
|
|
551 |
}
|
|
552 |
|
|
553 |
void CSimpleSoundPlayer::SetPosition(const TTimeIntervalMicroSeconds &aPosition)
|
|
554 |
{
|
|
555 |
iMdaPlayer->SetPosition(aPosition);
|
|
556 |
}
|
|
557 |
|
|
558 |
|
|
559 |
TInt CSimpleSoundPlayer::GetPosition(TTimeIntervalMicroSeconds &aPosition)
|
|
560 |
{
|
|
561 |
TTimeIntervalMicroSeconds position;
|
|
562 |
TInt PositionError = iMdaPlayer->GetPosition(position);
|
|
563 |
|
|
564 |
if (!PositionError)
|
|
565 |
{
|
|
566 |
iLogger.Log(_L("Current position [%d]") , position.Int64());
|
|
567 |
if (iState != EPlaying) {iLogger.Log(_L(" But not playing"));}
|
|
568 |
if ( ! iSoundOpen ) {iLogger.Log(_L(" But not open"));}
|
|
569 |
aPosition=position;
|
|
570 |
}
|
|
571 |
else
|
|
572 |
{
|
|
573 |
Exit(PositionError);
|
|
574 |
}
|
|
575 |
return PositionError;
|
|
576 |
}
|
|
577 |
|
|
578 |
void CSimpleSoundPlayer::Exit(TInt aExitCode)
|
|
579 |
{
|
|
580 |
iFinalError = aExitCode;
|
|
581 |
if (iSupervisor)
|
|
582 |
{
|
|
583 |
iSupervisor->NotifyDestruction();
|
|
584 |
}
|
|
585 |
else
|
|
586 |
{
|
|
587 |
CActiveScheduler::Stop();
|
|
588 |
}
|
|
589 |
}
|
|
590 |
|
|
591 |
void CSimpleSoundPlayer::SetVolumeRamp(const TTimeIntervalMicroSeconds &aRampDuration)
|
|
592 |
{
|
|
593 |
iMdaPlayer->SetVolumeRamp(aRampDuration);
|
|
594 |
}
|
|
595 |
|
|
596 |
void CSimpleSoundPlayer::SetVolume(TInt aNewVolume)
|
|
597 |
{
|
|
598 |
iMdaPlayer->SetVolume(aNewVolume);
|
|
599 |
}
|
|
600 |
|
|
601 |
TInt CSimpleSoundPlayer::GetVolume(TInt &aVolume)
|
|
602 |
{
|
|
603 |
TInt VolumeError = iMdaPlayer->GetVolume(aVolume);
|
|
604 |
if (VolumeError)
|
|
605 |
{
|
|
606 |
iLogger.Log(_L("Error (%d) getting volume") , VolumeError );
|
|
607 |
}
|
|
608 |
else
|
|
609 |
{
|
|
610 |
iLogger.Log(_L("Getting volume: (%d)") , aVolume);
|
|
611 |
}
|
|
612 |
return VolumeError;
|
|
613 |
}
|
|
614 |
|
|
615 |
TInt CSimpleSoundPlayer::MaxVolume()
|
|
616 |
{
|
|
617 |
return iMdaPlayer->MaxVolume();
|
|
618 |
}
|
|
619 |
|
|
620 |
void CSimpleSoundPlayer::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds &aTrailingSilence)
|
|
621 |
{
|
|
622 |
iMdaPlayer->SetRepeats(aRepeatNumberOfTimes , aTrailingSilence);
|
|
623 |
if ((aRepeatNumberOfTimes == -2) || (aRepeatNumberOfTimes > 0))
|
|
624 |
iIsLoopPlayEnabled = ETrue;
|
|
625 |
else
|
|
626 |
iIsLoopPlayEnabled = EFalse;
|
|
627 |
}
|
|
628 |
|
|
629 |
void CSimpleSoundPlayer::RegisterForAudioLoadingNotification(MAudioLoadingObserver &aLoadingObserver)
|
|
630 |
{
|
|
631 |
iMdaPlayer->RegisterForAudioLoadingNotification(aLoadingObserver);
|
|
632 |
}
|
|
633 |
|
|
634 |
void CSimpleSoundPlayer::GetAudioLoadingProgressL(TInt& aPercentageProgress)
|
|
635 |
{
|
|
636 |
iMdaPlayer->GetAudioLoadingProgressL(aPercentageProgress);
|
|
637 |
}
|
|
638 |
|
|
639 |
void CSimpleSoundPlayer::ControllerImplementationInformationL()
|
|
640 |
{
|
|
641 |
//int g=0,a;
|
|
642 |
const CMMFControllerImplementationInformation& x = iMdaPlayer->ControllerImplementationInformationL();
|
|
643 |
/*const CMMFControllerImplementationInformation* ControllerImplementationInformation;
|
|
644 |
ControllerImplementationInformation = &(iMdaPlayer->ControllerImplementationInformationL());*/
|
|
645 |
//g=a;
|
|
646 |
}
|
|
647 |
|
|
648 |
TInt CSimpleSoundPlayer::SetPlayWindow(const TTimeIntervalMicroSeconds &aStart, const TTimeIntervalMicroSeconds &aEnd)
|
|
649 |
{
|
|
650 |
iLogger.Log(_L("iMdaPlayer->SetPlayWindow() Start[%d] End[%d]"), aStart.Int64(), aEnd.Int64());
|
|
651 |
return iMdaPlayer->SetPlayWindow(aStart, aEnd);
|
|
652 |
}
|
|
653 |
|
|
654 |
TInt CSimpleSoundPlayer::ClearPlayWindow()
|
|
655 |
{
|
|
656 |
iLogger.Log(_L("iMdaPlayer->ClearPlayWindow()"));
|
|
657 |
return iMdaPlayer->ClearPlayWindow();
|
|
658 |
}
|
|
659 |
|
|
660 |
void CSimpleSoundPlayer::SetSupervisor(TObjectCountDown *aCounter)
|
|
661 |
{
|
|
662 |
iSupervisor = aCounter;
|
|
663 |
iSupervisor->NotifyCreation();
|
|
664 |
}
|
|
665 |
|
|
666 |
void CSimpleSoundPlayer::SetPlayCompleteTarget(MEventTarget *aTarget, CParameters *aParameters)
|
|
667 |
{
|
|
668 |
iEventTarget = aTarget;
|
|
669 |
iParameters = aParameters;
|
|
670 |
}
|
|
671 |
|
|
672 |
TInt CSimpleSoundPlayer::GetNumberOfMetaDataEntries(TInt &aNumEntries)
|
|
673 |
{
|
|
674 |
TInt ErrorCode = iMdaPlayer->GetNumberOfMetaDataEntries(aNumEntries);
|
|
675 |
if (ErrorCode)
|
|
676 |
{
|
|
677 |
iLogger.Log(_L("Error (%d) getting number of meta data entries") , ErrorCode);
|
|
678 |
}
|
|
679 |
else
|
|
680 |
{
|
|
681 |
iLogger.Log(_L("Clip has (%d) meta data entries") , aNumEntries);
|
|
682 |
}
|
|
683 |
return ErrorCode;
|
|
684 |
}
|
|
685 |
|
|
686 |
CMMFMetaDataEntry *CSimpleSoundPlayer::GetMetaDataEntryL(TInt aMetaDataIndex)
|
|
687 |
{
|
|
688 |
iLogger.Log(_L("Obtaining meta data with index (%d)") , aMetaDataIndex);
|
|
689 |
return iMdaPlayer->GetMetaDataEntryL(aMetaDataIndex);
|
|
690 |
}
|
|
691 |
|
|
692 |
TInt CSimpleSoundPlayer::ExecuteL(CParameters *aParams)
|
|
693 |
{
|
|
694 |
TInt newVolume = 2000;
|
|
695 |
TInt balance=0;
|
|
696 |
|
|
697 |
TInt priority=EMdaPriorityNormal;
|
|
698 |
TMdaPriorityPreference aPref=EMdaPriorityPreferenceTime;
|
|
699 |
|
|
700 |
TInt repeatNumberOfTimes=3;
|
|
701 |
TTimeIntervalMicroSeconds SilenceDuration = (TTimeIntervalMicroSeconds ((TInt64)500000));
|
|
702 |
|
|
703 |
switch (aParams->iAction)
|
|
704 |
{
|
|
705 |
case KPlayerActionPause:
|
|
706 |
iLogger.Log(_L("CSimpleSoundPlayer::ExecuteL "));
|
|
707 |
Pause();
|
|
708 |
break;
|
|
709 |
case KPlayerActionPlay:
|
|
710 |
Play();
|
|
711 |
break;
|
|
712 |
case KPlayerActionStopPlayFile:
|
|
713 |
// OpenL( (static_cast<CFileNameParameters*>(aParams) )->GetFileName() , ETrue);
|
|
714 |
Stop();
|
|
715 |
break;
|
|
716 |
case KPlayerActionReportPosition:
|
|
717 |
{
|
|
718 |
TTimeIntervalMicroSeconds tmpPosition=TTimeIntervalMicroSeconds(0);
|
|
719 |
GetPosition(tmpPosition);
|
|
720 |
return ETrue;
|
|
721 |
}
|
|
722 |
//break;
|
|
723 |
case KPlayerActionReportDuration:
|
|
724 |
GetDuration();
|
|
725 |
return ETrue;
|
|
726 |
//break;
|
|
727 |
case KplayerActionMaxVolume:
|
|
728 |
MaxVolume();
|
|
729 |
return ETrue;
|
|
730 |
//break;
|
|
731 |
case KplayerActionSetVolume:
|
|
732 |
SetVolume(newVolume);
|
|
733 |
return ETrue;
|
|
734 |
//break;
|
|
735 |
case KplayerActionSetBalance:
|
|
736 |
SetBalance(balance);
|
|
737 |
return ETrue;
|
|
738 |
//break;
|
|
739 |
case KplayerActionGetBalance:
|
|
740 |
GetBalance(iBalance);
|
|
741 |
return ETrue;
|
|
742 |
//break;
|
|
743 |
case KplayerActionGetBitRate:
|
|
744 |
TUint bitRate;
|
|
745 |
GetBitRate(bitRate);
|
|
746 |
return ETrue;
|
|
747 |
//break;
|
|
748 |
case KplayerActionSetPriority:
|
|
749 |
SetPriority(priority, aPref);
|
|
750 |
return ETrue;
|
|
751 |
//break;
|
|
752 |
case KplayerActionSetRepeats:
|
|
753 |
SetRepeats(repeatNumberOfTimes, SilenceDuration);
|
|
754 |
return ETrue;
|
|
755 |
//break;
|
|
756 |
case KPlayerActionGetMetaDataEntry:
|
|
757 |
SetVolume(newVolume);
|
|
758 |
return ETrue;
|
|
759 |
//break;
|
|
760 |
case KPlayerActionGetNumberOfMetaDataEntries:
|
|
761 |
SetVolume(newVolume);
|
|
762 |
return ETrue;
|
|
763 |
// break;
|
|
764 |
case KplayerActionGetAudioLoadingProgress:
|
|
765 |
TInt percentageProgress;
|
|
766 |
GetAudioLoadingProgressL(percentageProgress);
|
|
767 |
return ETrue;
|
|
768 |
//break;
|
|
769 |
case KplayerActionRegisterForAudioLoadingNotification:
|
5
|
770 |
|
|
771 |
RegisterForAudioLoadingNotification(*this);
|
0
|
772 |
return ETrue;
|
|
773 |
//break;
|
|
774 |
case KplayerActionControllerImplementationInformation:
|
|
775 |
ControllerImplementationInformationL();
|
|
776 |
return ETrue;
|
|
777 |
// break;
|
|
778 |
case KPlayerActionStopPlayDes:
|
|
779 |
OpenDesL( (static_cast<CDes8Parameters *>(aParams) )->GetDes8() , ETrue);
|
|
780 |
break;
|
|
781 |
case KPlayerActionReportVolume:
|
|
782 |
TInt tmpVolume;
|
|
783 |
GetVolume(tmpVolume);
|
|
784 |
return ETrue;
|
|
785 |
//break;
|
|
786 |
case KPlayerActionStopPlayUrl:
|
|
787 |
CUrlParameters *p;
|
|
788 |
p = static_cast<CUrlParameters *>(aParams);
|
|
789 |
OpenUrlL(p->GetUrl() , p->GetIapId() , p->GetMimeType() );
|
|
790 |
break;
|
|
791 |
case KPlayerActionStopPlayFileHandler:
|
|
792 |
Stop();
|
|
793 |
// OpenFileHandlerL((static_cast<CFileNameParameters*>(aParams) )->GetFileName() , ETrue);
|
|
794 |
// OpenFileHandlerL( (static_cast<CFileHandlerParameters*>(aParams) )->GetFileHandler() , ETrue);
|
|
795 |
break;
|
|
796 |
case KPlayerActionOpen:
|
|
797 |
OpenL( (static_cast<CFileNameParameters*>(aParams) )->GetFileName() , ETrue);
|
|
798 |
break;
|
|
799 |
|
|
800 |
case KPlayerActionOpenFileHandler:
|
|
801 |
OpenFileHandlerL((static_cast<CFileNameParameters*>(aParams) )->GetFileName() , ETrue);
|
|
802 |
break;
|
5
|
803 |
case KPlayerActionCustomCommand:
|
|
804 |
CustomCommand();
|
0
|
805 |
}
|
|
806 |
if (iIsLoopPlayEnabled)
|
|
807 |
return ETrue;
|
|
808 |
else
|
|
809 |
return EFalse;
|
|
810 |
}
|
5
|
811 |
|
|
812 |
|
|
813 |
void CSimpleSoundPlayer::MaloLoadingStarted()
|
|
814 |
{
|
|
815 |
iLogger.Log(_L("CSimpleSoundPlayer::MaloLoadingStarted"));
|
|
816 |
}
|
|
817 |
void CSimpleSoundPlayer::MaloLoadingComplete()
|
|
818 |
{
|
|
819 |
iLogger.Log(_L("CSimpleSoundPlayer::MaloLoadingComplete"));
|
|
820 |
}
|
|
821 |
|
|
822 |
void CSimpleSoundPlayer::CustomCommand()
|
|
823 |
{
|
|
824 |
TBuf8<25> dataFrom;
|
|
825 |
|
|
826 |
TRequestStatus status;
|
|
827 |
TMMFMessageDestinationPckg dummyPckg;
|
|
828 |
TInt dummyFunc = 100;
|
|
829 |
TBuf8<8> dummyBuff;
|
|
830 |
iMdaPlayer->CustomCommandSync(dummyPckg,dummyFunc,dummyBuff,dummyBuff);
|
|
831 |
iMdaPlayer->CustomCommandSync(dummyPckg,dummyFunc,dummyBuff,dummyBuff,dataFrom);
|
|
832 |
|
|
833 |
iMdaPlayer->CustomCommandAsync(dummyPckg,dummyFunc,dummyBuff,dummyBuff,status);
|
|
834 |
User::WaitForRequest(status);
|
|
835 |
|
|
836 |
iMdaPlayer->CustomCommandAsync(dummyPckg,dummyFunc,dummyBuff,dummyBuff,dataFrom,status);
|
|
837 |
|
|
838 |
User::WaitForRequest(status);
|
|
839 |
|
|
840 |
|
|
841 |
}
|