×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    40

    How to play a series of wav files?

    I can play a wav file, but i really do not know how to play a series of wav files. In S60_Platform_Music_Application_Developers_Guide_v1_1_en.pdf, it guides how to do that, but it does not give an example code.

    For example, i place 5 wav files in C:\Data\Sounds\Simple, i can load these files into an array. But when i use for loop to play wav file one by one (there is no error, but i does not play these wav files).

    Anybody helps me, please?

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: How to play a series of wav files?

    Hi,

    honestly - this sounds pretty strange to me. You have a commented code to play a single wav file, which is working. Then you want to extend it to work on series of files - it should not be so hard task...

    So where exactly is the problem - what you found during debugging? You are saying that "here is no error, but i does not play these wav files" - unfortunatelly you do not provide us enough information to help you - there must be some error!

    It might be because some stupid mistake - e.g. the code is not called as you expect - this is something you can check in debugger or after finishing the first file some uninitialization is done... Provide us your code and we will tell you more.

    BR
    STeN

  3. #3
    Regular Contributor
    Join Date
    Apr 2008
    Location
    India
    Posts
    477

    Re: How to play a series of wav files?

    uare loading the whole file contents into array orthe file path ?

    and if u using MMdaAudioPlayerCallback class

    then use the Call back function of the class and play next file in MapcPlayComplete() ......

  4. #4
    Registered User
    Join Date
    Sep 2008
    Posts
    40

    Re: How to play a series of wav files?

    I am sorry, I want to play every wav file (one-by-one) that i get from C:\System\Apps.
    This is my code
    Code:
    TBool CPlayWAVFileContainerView::HandlePlay_fileMenuItemSelectedL( TInt aCommand )
    	{
    	// TODO: implement selected event handler
    	_LIT(KPath, "C:\\System\\Apps\\");
            
    	TInt result = iEngine->GetDirectoryAndFileList(KPath);
    	if (result == KErrNone)
    		{
    		_LIT(KSpace, " ");		
    		TInt iCount = iEngine->FileCount();
    		
                    //For loop in order to get all of wav files one-by-one
    		for(TInt index=0; index<iCount; index++)
    			{
    			TBuf<100> buff(KPath);
    			buff.Append(iEngine->FileName(index));
    			
                            //CPlayWAVFileContainerView.h
                            //CSoundPlayer* iSoundPlayer;
                            iSoundPlayer = CNewClass::NewL(buff);		
    			iSoundPlayer->Play();
    			delete iSoundPlayer;			
    			}	
    		}
    	return ETrue;
    	}
    This is CSoundPlayer class
    Code:
    class CSoundPlayer : public CBase, public MMdaAudioPlayerCallback
    	{
    public:
    	// Constructors and destructor
    
    	/**
    	 * Destructor.
    	 */
    	~CSoundPlayer();
    
    	/**
    	 * Two-phased constructor.
    	 */
    	static CSoundPlayer* NewL(const TDesC& aFile);
    
    	/**
    	 * Two-phased constructor.
    	 */
    	static CNewClass* NewLC(const TDesC& aFile);
    
    private:
    
    	/**
    	 * Constructor for performing 1st stage construction
    	 */
    	CSoundPlayer();
    
    	/**
    	 * EPOC default constructor for performing 2nd stage construction
    	 */
    	void ConstructL(const TDesC& aFile);
    private:
    	enum TState
        {
            ENotReady,
            EReady,
            EPlaying
        };
        
        TState iState;
        CMdaAudioPlayerUtility* iMdaPlayer;
    public:
    	void Play();	
        void Stop();
        void Close();
        //
        // from MMdaAudioPlayerCallback
        //
        void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
        void MapcPlayComplete(TInt aError);
    	};
    
        //in .cpp file
        CNewClass::CNewClass()
    	{
    	// No implementation required
    	iState = ENotReady;
    	}
    
    CNewClass::~CNewClass()
    	{
    	Close();
    	delete iMdaPlayer;
    	iMdaPlayer = NULL;
    	}
    
    CNewClass* CNewClass::NewLC(const TDesC& aFile)
    	{
    	CNewClass* self = new (ELeave)CNewClass();
    	CleanupStack::PushL(self);
    	self->ConstructL(aFile);
    	return self;
    	}
    
    CNewClass* CNewClass::NewL(const TDesC& aFile)
    	{
    	CNewClass* self=CNewClass::NewLC(aFile);
    	CleanupStack::Pop(); // self;
    	return self;
    	}
    
    void CNewClass::ConstructL(const TDesC& aFile)
    	{
    	iMdaPlayer = CMdaAudioPlayerUtility::NewFilePlayerL(aFile, *this); 
    	}
    
    void CNewClass::Play()
    	{
    		if (iState == EReady)
    			{
    				iMdaPlayer->Play();
    				iState = EPlaying;
    			}
    	}
    
    void CNewClass::Stop()
    	{
    	if (iState == EPlaying)
    		{
    			iMdaPlayer->Stop();
    			iState = EReady;
    		}
    	}
    
    void CNewClass::Close()
    	{
    	iMdaPlayer->Close();
    	iState = ENotReady;
    	}
    
    void CNewClass::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
    	{
    		iState = aError ? ENotReady : EReady;		
    	}
    
    void CNewClass::MapcPlayComplete(TInt aError)
    {
        iState = aError ? ENotReady : EReady;
    }

  5. #5
    Super Contributor
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: How to play a series of wav files?

    hi 113115, if you read In S60_Platform_Music_Application_Developers_Guide_v1_1_en.pdf
    you will find it need you implement MMdaAudioPlayerCallback.

    when you create and play iSoundPlayer, you need wait MapcPlayComplete callback event.
    not stop iSoundPlayer immediatly.
    it will cause not output any sound.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  6. #6
    Registered User
    Join Date
    Sep 2008
    Posts
    40

    Re: How to play a series of wav files?

    Hi qxiaoyuan,

    I know that i must implement MMdaAudioPlayerCallback (and i did it), but i really do not know how to play a series of wav files. And i know that i have to wait MapcPlayComplete callback event, but i really do not know how to fix it. So could you write a code or give me an example about playing a series of wav files. Thank first.

  7. #7
    Super Contributor
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: How to play a series of wav files?

    Quote Originally Posted by 113115 View Post
    Hi qxiaoyuan,

    I know that i must implement MMdaAudioPlayerCallback (and i did it), but i really do not know how to play a series of wav files. And i know that i have to wait MapcPlayComplete callback event, but i really do not know how to fix it. So could you write a code or give me an example about playing a series of wav files. Thank first.
    you can use 2 class do the work.
    1st is palyerengine, 2nd is controller.
    playerengine implement MMdaAudioPlayerCallback and play one wav file. when MapcPlayComplete, notify controller.

    controller find all wav file, and select one file, create palyerengine, and wait playerengine notify finish, and select next file.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    40

    Re: How to play a series of wav files?

    Hi qxiaoyuan,
    So my code is done exactly what you say,

    My first class is CSoundPlayer (to play one wav file).
    I use class CPlayWAVFileContainerView as second class, which has CSoundPlayer* iSoundPlayer as a member variable.

    But the problem is i do not know how to notify CPlayWAVFileContainerView class when playing one wav file is finished.

    Thank for your reply.

  9. #9
    Super Contributor
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: How to play a series of wav files?

    you can define a M interface class.
    CPlayWAVFileContainerView implment the M class.
    it has a func to notify play finish.
    and CSoundPlayer call the func.

    it seems:
    Code:
    class MAudioPlayerEngineObserver
    {
    public:
        virtual void    AudioInitCompleteNotifyL(TInt aError, const TTimeIntervalMicroSeconds &aDuration) = 0;
        virtual void    AudioPlayCompleteNotifyL(TInt aError) = 0;
        virtual void    AudioErrorNotifyL(TInt aError) = 0;
    };
    and

    Code:
    CPlayWAVFileContainerView : public CAknView, public ...,  public MAudioPlayerEngineObserver
    and
    Code:
    void CAudioController::AudioPlayCompleteNotifyL(TInt aError)
    {
        if ( aError == KErrNone )
        {
                iSoundPlayer->Stop();
                iSoundPlayer->OpenFile(nextfile);
            }
        }
    }
    for CSoundPlayer
    Code:
    void CSoundPlayer::MapcPlayComplete(TInt aError)
    {
        iObserver.AudioPlayCompleteNotifyL(aError);
    }
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  10. #10
    Registered User
    Join Date
    Sep 2008
    Posts
    40

    Re: How to play a series of wav files?

    I understand what you mean, but there is one thing that CPlayWAVFileContainerView implements MAudioPlayerEngineObserver (so this CPlayWAVFileContainerView class is a controller), and CSoundPlayer class is a player engine class. So what about CAudioController class?, and Is "iObserver" varible an instance of MAudioPlayerEngineObserver?

    Code:
    iObserver.AudioPlayCompleteNotifyL(aError);
    Thank for your reply.
    Last edited by 113115; 2008-12-05 at 03:17.

  11. #11
    Registered User
    Join Date
    Sep 2008
    Posts
    40

    Re: How to play a series of wav files?

    I really appreciate if you show me how to play all of wav files whose name are in array. Thank first.

Similar Threads

  1. Cannot play mid and wav sound at the same time on Nokia N96.
    By Ishnu_Blue in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2008-08-26, 11:14
  2. linking error
    By dakosurf in forum Symbian
    Replies: 1
    Last Post: 2008-03-27, 22:45
  3. Phones that doesn't play WAV files
    By kailab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2007-10-02, 17:02
  4. Replies: 3
    Last Post: 2006-07-07, 05:50
  5. How to play video files on Symbian 1.2 SDK (Symbian 6.0)
    By go4jas in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2005-01-19, 07:44

Posting Permissions

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