playsound

PlaySound in C beeps but does not play wav file

随声附和 提交于 2019-11-29 16:06:57
In C, my PlaySound is not throwing any errors... but instead of playing the file I want, it just beeps. Any suggestions? I tried : PlaySound("song1.wav", NULL, SND_ALIAS | SND_APPLICATION); And: PlaySound("song1.wav", NULL, SND_FILENAME); But I got the same result. Instead of using relative path like you have done: PlaySound("song1.wav", NULL, SND_FILENAME); Use an absolute path like: PlaySound("F:\\path\\to\\your\\song\\song1.wav", NULL, SND_FILENAME); Quote from PlaySound API description, at msdn.microsoft.com: PlaySound searches the following directories for sound files: the current

PlaySound in C beeps but does not play wav file

◇◆丶佛笑我妖孽 提交于 2019-11-28 09:58:09
问题 In C, my PlaySound is not throwing any errors... but instead of playing the file I want, it just beeps. Any suggestions? I tried : PlaySound("song1.wav", NULL, SND_ALIAS | SND_APPLICATION); And: PlaySound("song1.wav", NULL, SND_FILENAME); But I got the same result. 回答1: Instead of using relative path like you have done: PlaySound("song1.wav", NULL, SND_FILENAME); Use an absolute path like: PlaySound("F:\\path\\to\\your\\song\\song1.wav", NULL, SND_FILENAME); 回答2: Quote from PlaySound API

How to PlaySound in C++ using Windows API?

三世轮回 提交于 2019-11-27 04:41:29
问题 I try to play a music file in my coding, but failed. I have my music file in the same folder which save .cpp file. Can someone help me? My code is: #include <iostream> #include <windows.h> int main() { PlaySound("kenny g.WAV", NULL, SND_ASYNC); } 回答1: You need to use the absolute path, make sure that you're sending a filename (use SND_FILENAME flag), and pause the program long enough to play the sound file (e.g., use getchar()). You need to link the winmm.lib library in your project settings,