playing sounds usig the wxSounds Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
jkbagain
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed May 09, 2007 1:01 am
Location: Manila,Philippines
Contact:

playing sounds usig the wxSounds

Post by jkbagain » Wed May 16, 2007 7:26 am

Hello everyone,,,,Could you pls help me on how to play music in wxWidgets using the wxSound for i am having trouble in playing music/sound...

my constructor is like this......
wxSound *mySound = new wxSound (_T("hello.wav"), false );

and i put this into my frame and yet the music does'nt play...I dont have any error in compiling my program it just that the music doesnt played...


I hope you could help me most especialy those who have encountered the same problem like this one........
Thanks in advanced......salamat!!!!
What important in a problem is not the solution but the lessons you learned in finding the solution.

tan
Moderator
Moderator
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan » Wed May 16, 2007 8:04 am

Hi,
1) do you have "hallo.wav" in the working dir of the app?
2) try check mySound.IsOk(), is it true?
3) do you call Play() method anywhere?
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10

wforl
Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu May 10, 2007 11:04 am

Post by wforl » Wed May 16, 2007 9:05 am

yeah, make sure hello is in the project file, in the folder with your cpp and.h files,

heres some code that works,

wxSound *mySound;

mySound = new wxSound(_T("kick.wav"), false);

mySound->Play();


you can also use the bool IsOk() function


if (mySound->IsOk())
{
mySound->Play();
}


also, try it like this, just incase you miss the first one or somthing,


mySound->Play();


you can also use the bool IsOk() function


if (mySound->IsOk())
{
mySound->Play(wxSOUND_ASYNC | wxSOUND_LOOP);
}


and finally make sure the .wav is named correctly and is in fact a ,wav file,

jkbagain
Knows some wx things
Knows some wx things
Posts: 29
Joined: Wed May 09, 2007 1:01 am
Location: Manila,Philippines
Contact:

thanks to both of u

Post by jkbagain » Wed May 16, 2007 9:16 am

thanks to both of you tan and wforl....


I really appreciate your help

Thank you very much!!!!!
What important in a problem is not the solution but the lessons you learned in finding the solution.

Post Reply