怎么使用CMdaAudioRecorderUtility ?
我用的carbide c++, symbian 9.1:
class CMyRecorder : public CBase, public MMdaObjectStateChangeObserver
{
public:
virtual CMyRecorder();
static CMyRecorder *NewL();
static CMyRecorder *NewLC();
void RecordL();
protected:
CMyRecorder();
void MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode);
private:
void ConstructL();
private:
CMdaAudioRecorderUtility *iMdaAudioRecorderUtility;
};
_LIT(KRecorderFile, "xxx.wav");
void CMyRecorder::RecordL()
{
TFileName aFileName;
aFileName.Append(KRecorderFile);
CompleteWithAppPath(aFileName);
CEikonEnv::Static()->FsSession().Replace(aFileName, aFileName);
iMdaAudioRecorderUtility->OpenFileL(aFileName);
iMdaAudioRecorderUtility->SetAudioDeviceMode(CMdaAudioRecorderUtility::ETelephonyOrLocal);
iMdaAudioRecorderUtility->SetVolume(iMdaAudioRecorderUtility->MaxVolume());
iMdaAudioRecorderUtility->SetGain(iMdaAudioRecorderUtility->MaxGain());
iMdaAudioRecorderUtility->SetPosition(TTimeIntervalMicroSeconds(0));
iMdaAudioRecorderUtility->CropL();
iMdaAudioRecorderUtility->RecordL();
}
每次执行这个函数就不行了,提示什么"the feature not supported (-5)"
经过我观察,一执行到CropL的时候就不行了,如果把这一行去掉,执行到RecordL的时候就不行了.并且当执行完OpenFileL后,MoscoStateChangeEvent会被触发,aErrorCode好像是-1,
造成这个问题的原因是什么?如何解决?
谢谢了!
[解决办法]
要先调用iMdaAudioRecorderUtility->OpenL(...),在MoscoStateChangeEvent里面观察错误码,如果初始化成功,然后在EOpen的状态下调用iMdaAudioRecorderUtility-> CropL();
iMdaAudioRecorderUtility-> RecordL();
就可以了.