Hi all, after a lot of digging I couldn't find what is wrong in my code ,
I'm using S60 5th Ed SDK, and testing on Symbian^3 device, and I'm using CAudioOutput API to route the sounds(CAudioOutput::EAll).
All discussions say don't hard-code the volume value cause it differs between platforms, So here is my code that returns Zero :
Code:/* * PlayUtility.cpp * * Created on: Apr 6, 2011 * Author: MrAlshahawy */ //#include <eikenv.h> #include <MdaAudioTonePlayer.h> #include <eikmenup.h> #include "PlayUtility.h" #include "GlobalVar.h" #include <eikenv.h> const TTimeIntervalMicroSeconds SetToBeg = 0; CPlayerUtility* CPlayerUtility::NewL(const TDesC& aFileName) { CPlayerUtility* self = NewLC(aFileName); CleanupStack::Pop(self); return self; } CPlayerUtility* CPlayerUtility::NewLC(const TDesC& aFileName) { CPlayerUtility* self = new (ELeave) CPlayerUtility(); CleanupStack::PushL(self); self->ConstructL(aFileName); return self; } CPlayerUtility::~CPlayerUtility() { if(iAudioOutput) { delete iAudioOutput; iAudioOutput = NULL; } if(iPlayUtility) { iPlayUtility->Stop(); iPlayUtility->Close(); delete iPlayUtility; iPlayUtility = NULL; } } CPlayerUtility::CPlayerUtility() { } void CPlayerUtility::ConstructL(const TDesC& aFileName) { //If you would like to play buffers instead of files you can change the NewFilePlayerL to be NewDesPlayerL instead. iPlayUtility = CMdaAudioPlayerUtility::NewFilePlayerL(aFileName, *this); } void CPlayerUtility::PlaySoundL(TDesC& aFileName, TInt& VolumeLevel) { iPlayUtility->Stop(); iPlayUtility->Close(); iPlayUtility->OpenFileL(aFileName); TInt x = ( VolumeLevel * iPlayUtility->MaxVolume())/10; TBuf<20> buf;buf.Num(iPlayUtility->MaxVolume()); //-----------> always shows zero and no voice heard CEikonEnv::InfoWinL(_L("MaxVolume is :"),buf); iPlayUtility->SetVolume(x);// And x here is Zero CEikonEnv::InfoWinL(_L(""),_L("")); // if I add this line it plays the sound high as if it resets volume level, If I remove it no voice heard iPlayUtility->Play(); } void CPlayerUtility::StopSound() { iPlayUtility->Stop(); iPlayUtility->Close(); } //The MapcPlayComplete method is called when playing of audio is completed. You can then restart playing the file by calling Play function again. void CPlayerUtility::MapcPlayComplete(TInt /*aError*/) { } //Method MapcInitComplete() is called when the file opening(NewFilePlayerL) is completed void CPlayerUtility::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/) { if (aError == KErrNone) { iAudioOutput = CAudioOutput::NewL(*iPlayUtility); iAudioOutput->SetAudioOutputL(CAudioOutput::EAll); } else { CEikonEnv::InfoWinL(_L("Audio File Format Not Supported"),_L("")); } } void CPlayerUtility::ActivityDetected() { // Stop sound here ............. CPlayerUtility::StopSound(); }
Many thanks in advance.




