Win32播放声音 [英] Win32 Play sound
问题描述
bool Win64Sound :: PlayIt(){ bool Win64Sound::PlayIt() { 我使用 I have tested this member function using 我使用的是Win 8.1机器。 I am using a Win 8.1 machine. 这里的任何人都知道可能出现什么问题? Anyone here knows what could be the problem? 嗯,除了sndPlaySound行中明显的编译器错误,你有sndPlaySound的SND_ASYNC但不是PlaySound,是否将SND_ASYNC添加到PlaySound,或者从sndPlaySound中删除它会有什么区别? Well, besides the obvious compiler error in the sndPlaySound line, you have SND_ASYNC for sndPlaySound but not for PlaySound, does adding SND_ASYNC to PlaySound, or removing it from sndPlaySound make any difference? 否则,唯一要注意的是确保StringSoundFileName具有正确的路径,因为它是PlaySound使用的WideStringSoundFileName的不同变量。 Otherwise, the only other things to look at is to make sure that the StringSoundFileName has the correct path, since it is a different variable to WideStringSoundFileName that PlaySound uses. 无论如何,仅为了向后兼容性而维护sndPlaySound。如果可以的话,我建议你把所有内容改为PlaySound。更重要的是,这两个基本上已被WASAPI取代。 Anyway, sndPlaySound is only being maintained for backwards compatibility. If you can, I would suggest you change everything over to PlaySound anyway. What's more, both of these have basically been superseded by WASAPI. 这篇关于Win32播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
// return !! PlaySoundW(WideStringSoundFileName.c_str(),NULL,SND_FILENAME);
return !! sndPlaySound(StringSoundFileName).c_str(),SND_ASYNC);
}
//return !!PlaySoundW(WideStringSoundFileName.c_str(), NULL, SND_FILENAME );
return !!sndPlaySound(StringSoundFileName).c_str(),SND_ASYNC);
} PlaySoundW测试了这个成员函数( )并没有问题,但
sndPlaySound()不会产生任何声音。我正在链接
-lwinmm -mwindows PlaySoundW() and had no problems, but
sndPlaySound() does not produce any sound. I am linking against
-lwinmm -mwindows
推荐答案