Talk:Playing audio files using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search
06 Sep
Article Review by kamalakshan (20090906)

This article provides very well written classes for playing audio files using both CMdaAudioRecorderUtility or CMdaAudioPlayerUtility. Any one beginning to play audio files will find this article good enough to suite their requirements - whether its playing it from a file or from the buffer.

Although it provide the content about how to use the CMdaAudioPlayerUtility, it does not work at all if you just follow the written code to run the program. Does not work at all.

If you want to build it with Qt, you need to change the inheritances. e.g. like this:

* AudioPlayer.h
* Created on: 02.02.2010
* Author: TAMHAN

#include <MdaAudioSamplePlayer.h>
#include <MdaAudioSampleEditor.h>
#include <Mda\Client\Utility.h>
#include "CExampleTimer.h"
const TInt KReFreshTimeOut = 1000000; // re-fresh every second
class MExamplePlayStateObserver
virtual void StateUpdate(CMdaAudioClipUtility::TState aState, TInt aPosition, TInt aDuration)=0;
class CAudioPlayer : MMdaObjectStateChangeObserver, CBase, MExampleTimerNotify
static CAudioPlayer* NewL(MExamplePlayStateObserver& aObserver);
static CAudioPlayer* NewLC(MExamplePlayStateObserver& aObserver);
public: // public functions
void PlayL(const TDesC& aFileName);
void StopL(void);
void SetVolume(TInt& aVolume);
protected: // from MMdaObjectStateChangeObserver & MExampleTimerNotify
void MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode);
void TimerExpired(TAny* aTimer,TInt aError);
private:// interna functions
void ReportStateAndTime(void);
void ConstructL();
CAudioPlayer(MExamplePlayStateObserver& aObserver);
MExamplePlayStateObserver& iObserver;
CMdaAudioRecorderUtility* iPlayerUtility;
TInt iVolume;
TMdaFileClipLocation iCurrentFile;
CExampleTimer* iExampleTimer;
#endif /* AUDIOPLAYER_H_ */