×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    93

    Audio Routing API

    Hi, I developed an application, that shows a video, i would like to have the audio output routed to the earphones, I have tried in this way:
    Code:
    #ifndef __AUDIOENGINE_H__
    #define __AUDIOENGINE_H__
    
    
    #include <MdaAudioSamplePlayer.h> // for playing audio
    #include "AudioOutput.h"
    #include "MAudioOutputObserver.h"
    #include <QDebug>
    #include <mda\\client\\utility.h>
    class CMySound : public CBase ,public MMdaAudioPlayerCallback,public MAudioOutputObserver
    {
    
    public:
    	
    	static CMySound* NewL();
    	static CMySound* NewLC();
    	
    	void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
    	void MapcPlayComplete(TInt aError);
    	
    	void PlayL();
    	
    	void SetRoutingL(CAudioOutput::TAudioOutputPreference& aAudioOutput);
            void SetRoutingLPrivate();
    	void DefaultAudioOutputChanged( CAudioOutput& aAudioOutput,
                                            CAudioOutput::TAudioOutputPreference aNewDefault );
    	virtual ~CMySound();
    	
    private:
    
    	CMySound();
    
    	void ConstructL();
    	void PlayFile();
    	
    private:
    
    	CMdaAudioPlayerUtility* iMyAudioPlayerUtility;
    	CAudioOutput* iAudioOutput;
    	
    };
    
    #endif
    and

    Code:
    #include "AudioEngine.h"
    #include <eikenv.h>
    #include <AudioOutput.h>
    #include <AknNoteWrappers.h>
    
    //////////////////////////////////////////////////////////////////////
    // Construction/Destruction
    //////////////////////////////////////////////////////////////////////
    
    // Standard construction sequence
    CMySound* CMySound::NewL()
        {
       	CMySound* self = CMySound::NewLC();
        CleanupStack::Pop( self );
        return self;
        }
    
    CMySound* CMySound::NewLC()
        {
        CMySound* self = new ( ELeave ) CMySound;
        CleanupStack::PushL( self );
        self->ConstructL();
        return self;
        }
    void CMySound::ConstructL()
        {
        iMyAudioPlayerUtility = CMdaAudioPlayerUtility::NewL(*this);
        }
    
    CMySound::CMySound()
    	{
    	// No implementation required
    	}
    
    CMySound::~CMySound()
    	{
    	if(iMyAudioPlayerUtility)
    		{
    		delete iMyAudioPlayerUtility;
    		iMyAudioPlayerUtility = NULL;
    		}
    	if(iAudioOutput)
    		{
    		delete iAudioOutput;
    		iAudioOutput = NULL;
    		}
    	}
    //////////////////////////////////////////////////////////////////////
    // MClass/Callbacks
    //////////////////////////////////////////////////////////////////////
    
    void CMySound::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
    	{
    	if(aError == KErrNone)
    		{
    		iMyAudioPlayerUtility->SetVolume(iMyAudioPlayerUtility->MaxVolume());
    		PlayFile();
    		}
    	}
    
    void CMySound::MapcPlayComplete(TInt aError)
    	{
    	if(aError == KErrDied)
    		{
                    qDebug()<<"Player Died";
                    //CEikonEnv::InfoWinL(_L("Player died"),_L(""));
    		}
    	else
    		{
                    qDebug()<<"Play Completed";
    //		CEikonEnv::InfoWinL(_L("Play Completed"),_L(""));
    		}
    	}
    
    void CMySound::DefaultAudioOutputChanged( CAudioOutput& aAudioOutput,
                                            CAudioOutput::TAudioOutputPreference aNewDefault )
    	{
    //        CEikonEnv::InfoWinL(_L("In Callback"),_L("AudioOutput Routed"));
            qDebug()<<"OUTPUT CHANGED";
    	}
    
    //////////////////////////////////////////////////////////////////////
    // Audio functions
    //////////////////////////////////////////////////////////////////////
    void CMySound::PlayL()
    	{
    	iMyAudioPlayerUtility->Close();
    	iMyAudioPlayerUtility->OpenFileL(_L("C:\\Theme.mp3"));
    	}
    
    void CMySound::PlayFile()
    	{
    	iMyAudioPlayerUtility->Play();
    	}
    
    
    //////////////////////////////////////////////////////////////////////
    // Audio Routing
    //////////////////////////////////////////////////////////////////////
    
    void CMySound::SetRoutingL(CAudioOutput::TAudioOutputPreference& aAudioOutput)
    	{
    	if(iAudioOutput)
    	{
    		delete iAudioOutput;
    		iAudioOutput = NULL;
    	}
    	iAudioOutput = CAudioOutput::NewL(*iMyAudioPlayerUtility);
    	iAudioOutput->RegisterObserverL(*this);
    	iAudioOutput->SetAudioOutputL(aAudioOutput);
    	}
    
    
    void CMySound::SetRoutingLPrivate()
            {
            if(iAudioOutput)
            {
                    delete iAudioOutput;
                    iAudioOutput = NULL;
            }
            iAudioOutput = CAudioOutput::NewL(*iMyAudioPlayerUtility);
            iAudioOutput->RegisterObserverL(*this);
            CAudioOutput::TAudioOutputPreference aAudioOutput = CAudioOutput::EPrivate;
            iAudioOutput->SetAudioOutputL(aAudioOutput);
            }
    then i put this in my widget:

    Code:
      CMySound*  sound = CMySound::NewL();
    sound->SetRoutingLPrivate();
    but it returns me:
    Code:
    [Qt Message] CActiveScheduler::RunIfReady() returned error: -1
    What's wrong??
    Tnx so much
    Last edited by marsiliano; 2011-04-08 at 08:47. Reason: error in editing

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,091

    Re: Audio Routing API

    And you are testing it for which platform/edition?

  3. #3
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    93

    Re: Audio Routing API

    I'm testing it on Symbian^3, Device E7, using Nokia Qt Sdk 1.0.2

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: Audio Routing API

    The message is a bit misleading, RunIfReady returns a boolean, true/false. However it also propagates back the error code produced by the active object it was executing. So something is not found (http://wiki.forum.nokia.com/index.php/Error_codes), my bet would go for that file, c:\Theme.mp3 - make sure that it is really installed.

  5. #5
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    93

    Re: Audio Routing API

    This is not the problem also if i comment that line it returns me that error

Similar Threads

  1. Audio Routing API for S60 5th
    By heuven in forum Symbian User Interface
    Replies: 6
    Last Post: 2009-02-14, 23:39
  2. Audio Routing API plugin leaves on N95
    By gailu in forum Symbian
    Replies: 9
    Last Post: 2009-01-13, 14:04
  3. Audio Routing API
    By ayaloz in forum Symbian Media (Closed)
    Replies: 6
    Last Post: 2008-02-27, 21:02
  4. Audio routing limitations
    By galwa in forum Symbian
    Replies: 1
    Last Post: 2007-05-02, 08:53

Posting Permissions

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