0
我非常喜歡Symbian,我無法播放聲音。我看了很多例子,我找不到我的錯誤。有沒有其他人有過這方面的經驗?任何方向都會有幫助。我用另一個班的計時器打電話給Play。在Symbian上播放聲音S60
頭:
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();
}