1 // Copyright (c) 1999-2009 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MDAAUDIOSAMPLEPLAYER_H
17 #define __MDAAUDIOSAMPLEPLAYER_H
21 #include <mmf/common/mmfaudio.h>
22 #include <mmf/common/mmfbase.h>
23 #include <mmf/common/mmfcontrollerframeworkbase.h>
24 #include <mmf/common/mmfstandardcustomcommands.h>
25 #include <mmf/common/mmfdrmcustomcommands.h>
26 #include <mmfclntutility.h>
27 #include <mmf/common/mmfdurationinfocustomcommands.h>
35 An interface to a set of audio player callback functions.
37 The class is a mixin and is intended to be inherited by the client
38 class which is observing the audio playing operation. The functions
39 encapsulated by this class are called when specific events occur in
40 the process of initialising and playing an audio sample. A reference to
41 this object is passed as a parameter when constructing an audio player
46 class MMdaAudioPlayerCallback
51 Defines required client behaviour when an attempt to open and
52 initialise an audio sample has completed, successfully or otherwise.
55 The status of the audio sample after initialisation.
56 The following values have the same specific meaning
57 across all EPOC platforms: KErrNone the
58 sample is ready to play. KErrNotSupported
59 the audio format or particular encoding type is not
60 recognised or not supported. KErrNotFound
61 the audio sample cannot be found.
62 KErrNoMemory there is insufficient memory
63 to play this audio sample. Other values are possible
64 indicating a problem opening the audio sample. These
65 values are dependent on the EPOC platform.
67 The duration of the audio sample.
69 virtual void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration) = 0;
72 Defines required client behaviour when an attempt to playback an audio
73 sample has completed, successfully or otherwise.
76 The status of playback. The following values have the
77 same specific meaning across all EPOC platforms:
78 KErrNone playing of the audio sample is
79 complete. KErrCorrupt the sample data is
80 corrupt. KErrInUse the sound device is in
81 use by another higher priority client. This can happen
82 during playback. KErrNoMemory there is
83 insufficient memory to play this audio sample Other
84 values are possible indicating a problem opening the
85 audio sample. These values are dependent on the EPOC
88 virtual void MapcPlayComplete(TInt aError) = 0;
92 class CMMFMdaAudioPlayerUtility;
98 Plays sampled audio data.
100 The class offers a simple interface to open, play and obtain
101 information from, sampled audio data. The audio data can be supplied
102 either in a file (file-based), as a descriptor
103 (descriptor-based) or as a URL reference (since version 7.0s).
105 While this class is abstract, the three static functions construct, initialise
106 and return pointers to instances of concrete classes derived from this
111 class CMdaAudioPlayerUtility : public CBase,
112 public MMMFClientUtility
115 IMPORT_C static CMdaAudioPlayerUtility* NewFilePlayerL(const TDesC& aFileName,
116 MMdaAudioPlayerCallback& aCallback,
117 TInt aPriority = EMdaPriorityNormal,
118 TInt aPref = EMdaPriorityPreferenceTimeAndQuality,
119 CMdaServer* aServer = NULL);
120 IMPORT_C static CMdaAudioPlayerUtility* NewDesPlayerL(const TDesC8& aData,
121 MMdaAudioPlayerCallback& aCallback,
122 TInt aPriority = EMdaPriorityNormal,
123 TInt aPref = EMdaPriorityPreferenceTimeAndQuality,
124 CMdaServer* aServer = NULL);
125 IMPORT_C static CMdaAudioPlayerUtility* NewDesPlayerReadOnlyL(const TDesC8& aData,
126 MMdaAudioPlayerCallback& aCallback,
127 TInt aPriority = EMdaPriorityNormal,
128 TInt aPref = EMdaPriorityPreferenceTimeAndQuality,
129 CMdaServer* aServer = NULL);
131 // new export from version 7.0
132 IMPORT_C static CMdaAudioPlayerUtility* NewL(MMdaAudioPlayerCallback& aCallback,
133 TInt aPriority = EMdaPriorityNormal,
134 TInt aPref = EMdaPriorityPreferenceTimeAndQuality);
136 IMPORT_C void UseSharedHeap();
138 ~CMdaAudioPlayerUtility();
144 virtual TInt SetVolume(TInt aVolume);
146 virtual void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
148 virtual void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
150 virtual const TTimeIntervalMicroSeconds& Duration();
151 IMPORT_C TMMFDurationInfo Duration(TTimeIntervalMicroSeconds& aDuration);
153 virtual TInt MaxVolume();
155 IMPORT_C void OpenFileL(const TDesC& aFileName);
156 IMPORT_C void OpenFileL(const RFile& aFile);
158 IMPORT_C void OpenFileL(const TMMSource& aSource);
160 IMPORT_C void OpenDesL(const TDesC8& aDescriptor);
162 IMPORT_C void OpenUrlL(const TDesC& aUrl, TInt aIapId = KUseDefaultIap, const TDesC8& aMimeType=KNullDesC8);
164 IMPORT_C TInt Pause();
166 IMPORT_C void Close();
168 IMPORT_C TInt GetPosition(TTimeIntervalMicroSeconds& aPosition);
170 IMPORT_C void SetPosition(const TTimeIntervalMicroSeconds& aPosition);
172 IMPORT_C TInt SetPriority(TInt aPriority, TInt aPref);
174 IMPORT_C TInt GetVolume(TInt& aVolume);
176 IMPORT_C TInt GetNumberOfMetaDataEntries(TInt& aNumEntries);
178 IMPORT_C CMMFMetaDataEntry* GetMetaDataEntryL(TInt aMetaDataIndex);
180 IMPORT_C TInt SetPlayWindow(const TTimeIntervalMicroSeconds& aStart,
181 const TTimeIntervalMicroSeconds& aEnd);
183 IMPORT_C TInt ClearPlayWindow();
185 IMPORT_C TInt SetBalance(TInt aBalance = KMMFBalanceCenter);
187 IMPORT_C TInt GetBalance(TInt& aBalance);
189 IMPORT_C void RegisterForAudioLoadingNotification(MAudioLoadingObserver& aCallback);
191 IMPORT_C void GetAudioLoadingProgressL(TInt& aPercentageComplete);
193 IMPORT_C const CMMFControllerImplementationInformation& ControllerImplementationInformationL();
195 IMPORT_C TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
197 IMPORT_C TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
199 IMPORT_C void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
201 IMPORT_C void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
203 IMPORT_C TInt GetBitRate(TUint& aBitRate);
205 IMPORT_C MMMFDRMCustomCommand* GetDRMCustomCommand();
207 IMPORT_C TInt RegisterAudioResourceNotification(MMMFAudioResourceNotificationCallback& aCallback,TUid aNotificationEventUid,const TDesC8& aNotificationRegistrationData = KNullDesC8);
209 IMPORT_C TInt CancelRegisterAudioResourceNotification(TUid aNotificationEventId);
211 IMPORT_C TInt WillResumePlay();
213 IMPORT_C TInt SetThreadPriority(const TThreadPriority& aThreadPriority) const;
216 CMdaAudioPlayerUtility();
220 This member is internal and not intended for use.
222 CMMFMdaAudioPlayerUtility* iProperties;