This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PlaySoundW


On 16/05/15 18:40, Hotmail (ArbolOne) wrote:
bool ps = !!PlaySoundW(Soundfile.c_str(), NULL, SND_ASYNC);
if(ps == false) {
       std::wcout << L"ps is false, it is  " << ps << endl;
} else {
       std::wcout << L"ps is not false, it is " << ps <<  endl;
}
output:
ps is not false, it is 1

The code above compiles with out any problem, but now sound is produced. I have added âlwinmm to the Linker Settings â> Other Linker Options in Code Blocks, is there anything else I should do?

I am using MinGW64 MSYS2 on my Win8.1 box.

Thanks

Probably, you are attempting to play a sound *named* with what's actually a filename (I'm assuming *SND_ALIAS is the default*). I think you should be pasing *SND_FILENAME to the third parameter. And since you are requesting it to be played asynchronously, I wouldn't be surprised if it started played but stopped immediatly as your program closes. I would start by playing it synchronously, and only change to ASYNC after it's working.


*Eg:
 bool ps = PlaySoundW(Soundfile.c_str(), NULL, SND_SYNC | *SND_FILENAME*);

And as Jonathan pointed out, this is a question off-topic for this mailing list. You could try a microsoft windows coding resource instead.

In this case , just looking at the function documentation may have solved it, too https://msdn.microsoft.com/en-us/library/windows/desktop/dd743680(v=vs.85).aspx

Best regards


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]