私は Symbian の初心者で、サウンドを再生するのに苦労しています。多数の例を見てきましたが、エラーが見つかりません。他の誰かがこれを経験したことがありますか?どんな方向性でも役に立ちます。別のクラスのタイマーで Play を呼び出します。
ヘッダ:
class TonePlayer : public CBase, public MMdaAudioPlayerCallback
{
public:
static TonePlayer* NewL();
static TonePlayer* NewLC();
~TonePlayer();
void Play();
void Stop();
protected:
TonePlayer();
void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration);
void MapcPlayComplete(TInt aError);
private:
CMdaAudioPlayerUtility* m_pAudioPlayer;
void ConstructL();
};
cpp:
TonePlayer* TonePlayer::NewL()
{
TonePlayer* self = NewLC();
CleanupStack::Pop(self);
return self;
}
TonePlayer* TonePlayer::NewLC()
{
TonePlayer* self = new (ELeave) TonePlayer();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
TonePlayer::TonePlayer()
{
}
TonePlayer::~TonePlayer()
{
delete m_pAudioPlayer;
m_pAudioPlayer = NULL;
}
void TonePlayer::ConstructL()
{
m_pAudioPlayer = CMdaAudioPlayerUtility::NewL(*this);
}
void TonePlayer::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
{
MProEngEngine* pProfileEngine = ProEngFactory::NewEngineLC();
MProEngProfile* pProfile = pProfileEngine->ActiveProfileL();
MProEngTones& oTones = pProfile->ProfileTones();
m_pAudioPlayer->OpenFileL(oTones.MessageAlertTone());
m_pAudioPlayer->SetVolume(m_pAudioPlayer->MaxVolume());
Play();
delete pProfileEngine;
}
void TonePlayer::MapcPlayComplete(TInt aError)
{
}
void TonePlayer::Play()
{
m_pAudioPlayer->Play();
}
void TonePlayer::Stop()
{
m_pAudioPlayer->Stop();
}