Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User ashraf fawzy's Avatar
    Join Date
    May 2010
    Location
    Egypt
    Posts
    416
    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.
    How to protect application copyright information on Symbian: http://www.developer.nokia.com/Community/Wiki/How_to_protect_application_copyright_information_on_Symbian

  2. #2
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,671
    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 ashraf fawzy's Avatar
    Join Date
    May 2010
    Location
    Egypt
    Posts
    416
    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.
    How to protect application copyright information on Symbian: http://www.developer.nokia.com/Community/Wiki/How_to_protect_application_copyright_information_on_Symbian

  4. #4
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,671
    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 ashraf fawzy's Avatar
    Join Date
    May 2010
    Location
    Egypt
    Posts
    416
    And that's what I have done and got it works based on your advice.

    Best Regards.
    How to protect application copyright information on Symbian: http://www.developer.nokia.com/Community/Wiki/How_to_protect_application_copyright_information_on_Symbian

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. Replies: 1
    Last Post: 2009-09-01, 09:17
  3. keycapture icode always zero
    By letronje in forum Symbian C++
    Replies: 1
    Last Post: 2007-03-12, 14:28
  4. AppForDocument returns zero TUid and empty TDataType
    By tanechka_a in forum Symbian C++
    Replies: 0
    Last Post: 2005-09-02, 14:03
  5. 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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved