×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Question CMdaAudioPlayerUtility::MaxVolume() returns Zero

    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.
    Nokia Asha applications [Price Point Policy] [Unlimited Updates] [Suggestions]: http://www.developer.nokia.com/Community/Discussion/showthread.php?240423-Nokia-Asha-applications-Price-Point-Policy-Unlimited-Updates-Suggestions

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: CMdaAudioPlayerUtility::MaxVolume() returns Zero

    what about trying to get the max volume on init complete, also you can not call play before init complete is called.

  3. #3
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Re: CMdaAudioPlayerUtility::MaxVolume() returns Zero

    Many thanks symbianyucca for your help, it really helped a lot.

    And I wonder why S60 3rd Ed FP1 SDK didn't mention clearly that "OpenFileL" calls "MapcInitComplete" as "NewFilePlayerL" does ?!


    That's why I thought that "MapcInitComplete" only called once when we initialize it, which led me to a chain of misunderstood code.
    Nokia Asha applications [Price Point Policy] [Unlimited Updates] [Suggestions]: http://www.developer.nokia.com/Community/Discussion/showthread.php?240423-Nokia-Asha-applications-Price-Point-Policy-Unlimited-Updates-Suggestions

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: CMdaAudioPlayerUtility::MaxVolume() returns Zero

    it is mentioned somewhere, basically the logic has always been that you first open the file, wait untill the initialization is done, and then you play it.

  5. #5
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Re: CMdaAudioPlayerUtility::MaxVolume() returns Zero

    And that's what I have done and got it works based on your advice.

    Best Regards.
    Nokia Asha applications [Price Point Policy] [Unlimited Updates] [Suggestions]: http://www.developer.nokia.com/Community/Discussion/showthread.php?240423-Nokia-Asha-applications-Price-Point-Policy-Unlimited-Updates-Suggestions

Similar Threads

  1. GetAppViews always returns zero app views
    By mady369 in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2010-02-09, 08:51
  2. keycapture icode always zero
    By letronje in forum Symbian
    Replies: 1
    Last Post: 2007-03-12, 14:28
  3. Replies: 0
    Last Post: 2005-09-02, 14:03
  4. Starting at Zero
    By muhairwejas in forum General Messaging
    Replies: 1
    Last Post: 2003-02-24, 12:41

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×