Do Anyone know the best way to play a sound which is stored in a buffer on Series 60.
I am currently using the CMdaAudioRecorderUtility class to play the sound, however when Play() is called, I get "System error Try again (-18)".
This is strange because inside the MoscoStateChangeEvent function, the current state of the CMdaAudioRecorderUtility object is EOpen....hence it is ready to play..but it doesn't.
Also I know the buffer I pass is ok because it starts with RIFF1/4WAV which proves that the data in the buffer is .WAV audio content.
here is my code below:
void _CPP_Peer_PlayAudio(int in_wnd, TUint8* soundData, int aDataSize)
//The Sound data to Play
TPtr8 dataToPlay( (TUint8*)soundData, aDataSize, aDataSize);
CPlayerAdapter* ptr->iPlayerAdapter = CPlayerAdapter::NewWithDataL(dataToPlay);
The CPlayerAdapter is the same one as in S60 examples, but I use CMdaAudioRecorderUtility instead of CMdaAudiopPlayerUtility. Here is the CPlayerAdater code :
CPlayerAdapter* CPlayerAdapter::NewWithDataL(TDes8& aData)
CPlayerAdapter* self = NewWithDataLC(aData);
CleanupStack::Pop(); // self
CPlayerAdapter* CPlayerAdapter::NewWithDataLC(TDes8& aData)
CPlayerAdapter* self = new (ELeave) CPlayerAdapter();
void CPlayerAdapter::ConstructWithDataL(TDes8& aData)
iMdaAudioRecorderUtility = CMdaAudioRecorderUtility::NewL(*this);
// Open an existing sample file for playback or recording causes MMdaObjectStateChangeObserver::MoscoStateChangeEvent to be called
// from MMdaObjectStateChangeObserver
void CPlayerAdapter::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
iState = EReadyToPlay;
// Play through the device speaker
// Set maximum volume for playback
// Set the playback position to the start of the file
iState = EPlaying;
As soon as iMdaAudioRecorderUtility->PlayL(); is called I get error code -18.
The funny thing is that if I supply a filename then the sound plays fine but it can't play with a buffer.
Any help or examples would be greatly appreciated!!!!
or does anyone have a better way to play sounds from a buffer??