×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    22

    problem when make application play file .wav!

    Hi everybody!
    I'm making app play file .wav. But i don't listen evething when it run. I was try resolution it, but i don't succses. Help me, please!
    I using class CMdaAudioPlayerUtility;
    File AudioPlayer.h:
    Code:
    #ifndef AUDIOPLAYER_H_
    #define AUDIOPLAYER_H_
    
    #include <e32std.h>
    #include <mdaaudiosampleplayer.h>
    
    class CAudioPlayer : public CBase, public MMdaAudioPlayerCallback
    	{
    public:
    	static CAudioPlayer* NewL(const TDesC& aFileName);
    	static CAudioPlayer* NewLC(const TDesC& aFileName);
    public:
    	CAudioPlayer();
    	void ConstructL(const TDesC& aFileName);
    	virtual ~CAudioPlayer();
    public:
    	void Play();
    	void Stop();
    	void Pause();
    public:
    	void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
    	void MapcPlayComplete(TInt aError);
    private:
    	CMdaAudioPlayerUtility* iPlay;
    	};
    File AudioPlayer.cpp:
    Code:
    #include "AudioPlayer.h"
    #include <MdaAudioTonePlayer.h>
    #include <eikmenup.h>
    
    CAudioPlayer* CAudioPlayer::NewL(const TDesC& aFileName)
    	{
    	CAudioPlayer* self = NewLC(aFileName);
    	CleanupStack::Pop(self);
    	return self;
    	}
    
    CAudioPlayer* CAudioPlayer::NewLC(const TDesC& aFileName)
    	{
    	CAudioPlayer* self = new (ELeave) CAudioPlayer();
    	CleanupStack::PushL(self);
    	self->ConstructL(aFileName);
    	return self;
    	}
    CAudioPlayer::CAudioPlayer()
    	{
    	// TODO Auto-generated constructor stub
    
    	}
    
    CAudioPlayer::~CAudioPlayer()
    	{
    	// TODO Auto-generated destructor stub
    	if(iPlay)
    		{
    		iPlay->Stop();
    		iPlay->Close();
    		}
    	delete iPlay;
    	}
    
    void
    CAudioPlayer::ConstructL(const TDesC &aFileName)
    	{
    	iPlay = CMdaAudioPlayerUtility::NewFilePlayerL(aFileName, *this);
    	}
    
    void CAudioPlayer::Play()
    	{
    	
    	iPlay->Play();
    	}
    
    void CAudioPlayer::Pause()
    	{
    	iPlay->Pause();
    	}
    
    void CAudioPlayer::Stop()
    	{
    	iPlay->Stop();
    	}
    
    void
    CAudioPlayer::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration)
    	{
    	if(aError == KErrNone)
    		{
    		iPlay->SetVolume(iPlay->MaxVolume());
    		}
    	}
    
    void
    CAudioPlayer::MapcPlayComplete(TInt /*aError*/)
    	{
    	
    	}
    in file PlayAudioWav.h, i define CAudioPlayer* iPlay;

    and in file PlayAudioWav.cpp, i define link file wav:
    _LIT(KMusicFile,"VanHoa.wav");
    File VanHoa.wav i copied it in C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\winscw\c\private\E3A12752

    Code:
    void PlayAudioWav::ConstructL(const TRect& aRect)
    	{
    	// Create a window for this application view
    	CreateWindowL();
    	SetRect(aRect);
    	iPlay = CAudioPlayer::NewL(KMusicFile);
    	iPlay->Play();
    	ActivateL();
    	}

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,697

    Re: problem when make application play file .wav!

    Quote Originally Posted by tamnv110 View Post
    _LIT(KMusicFile,"VanHoa.wav");
    File VanHoa.wav i copied it in C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\winscw\c\private\E3A12752
    A clue: that is c:\ of the emulator.
    So KMusicFile has to be "c:\\private\\E3A12752\\VanHoa.wav".

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    22

    Re: problem when make application play file .wav!

    I try "c:\\private\\E3A12752\\VanHoa.wav", but it not succses

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

    Re: problem when make application play file .wav!

    What happens?
    You should check the value of aError in MapcInitComplete, for example in the debugger.

  5. #5
    Registered User
    Join Date
    May 2011
    Posts
    22

    Re: problem when make application play file .wav!

    The emulator run, but i don't listen everthing. I try draw image in the screen, it succses, but sounds not play. Sorry, i don't good english.

  6. #6
    Registered User
    Join Date
    May 2011
    Posts
    22

    Re: problem when make application play file .wav!

    Sorry, i want display logs like qDebug() in symbian^3 or AppLog in bada, what do i use?

  7. #7
    Registered User
    Join Date
    May 2008
    Location
    Surat Thani
    Posts
    260

    Re: problem when make application play file .wav!

    Hi,

    There's at least one clear issue in the code:

    Quote Originally Posted by tamnv110 View Post
    Code:
    	iPlay = CAudioPlayer::NewL(KMusicFile);
    	iPlay->Play();
    You're calling iPlay->Play() right away after instantiating the CAudioPlayer. The CMdaAudioPlayerUtility instance created in CAudioPlayer::ConstructL will not yet be ready for use at this point, you should wait for MapcInitComplete callback before trying to play sounds.

    Quote Originally Posted by tamnv110 View Post
    Sorry, i want display logs like qDebug() in symbian^3 or AppLog in bada, what do i use?
    Try RDebug::Print:
    http://www.developer.nokia.com/Commu..._to_use_RDebug

  8. #8
    Registered User
    Join Date
    May 2011
    Posts
    22

    Re: problem when make application play file .wav!

    Thank TongMuan very much. I think symbian c++ verry diffirent.

  9. #9
    Registered User
    Join Date
    May 2011
    Posts
    22

    Re: problem when make application play file .wav!

    I try call iPlay->Play() in MapcInitComplete, but it not play file audio. I need an example full, can you help me.

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,697

    Re: problem when make application play file .wav!


  11. #11
    Registered User
    Join Date
    May 2011
    Posts
    22

    Re: problem when make application play file .wav!

    Thank wizard, I was play file audio.

Similar Threads

  1. Is it possible to develop application to play avi and mpg file?
    By austin007 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2008-03-22, 20:32
  2. application in j2me to play video file
    By vivek.singh in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2007-02-21, 10:57
  3. play a wav file when starting application
    By jend_rommel in forum Symbian
    Replies: 4
    Last Post: 2006-04-04, 19:30
  4. How can i play rm file in my application
    By ekramulhuq in forum Symbian
    Replies: 1
    Last Post: 2003-08-07, 05:06
  5. How can i play rm file in my application
    By ekramulhuq in forum Streaming and Video
    Replies: 0
    Last Post: 2003-08-06, 08:30

Posting Permissions

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