I'm trying to use Playsound() in C++.
I've looked at everything but I always get the default windows error sound.
PlaySound(TEXT("D:\\Pokemon Game Stuff\\Programming\\Tests\\city simulator\\Sound.wav"), NULL, SND_FILENAME | SND_ASYNC);
winmm.lib has been set up in linker settings. Full location and just filename has been tested. I'm Using Code::Blocks and compiling with C++ 14 standards.
Per the PlaySound()
documentation:
SND_FILENAME
ThepszSound
parameter is a file name. If the file cannot be found, the function plays the default sound unless theSND_NODEFAULT
flag is set....
PlaySound
searches the following directories for sound files: the current directory; the Windows directory; the Windows system directory; directories listed in thePATH
environment variable; and the list of directories mapped in a network. If the function cannot find the specified sound and theSND_NODEFAULT
flag is not specified,PlaySound
uses the default system event sound instead. If the function can find neither the system default entry nor the default sound, it makes no sound and returnsFALSE
.
Double check that the file actually exists at the path you are specifying, and that the user that is running your app has permissions to access the file.