本文介绍了Win32播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


bool Win64Sound :: PlayIt(){

    // return !! PlaySoundW(WideStringSoundFileName.c_str(),NULL,SND_FILENAME);

    return !! sndPlaySound(StringSoundFileName).c_str(),SND_ASYNC);

}

bool Win64Sound::PlayIt() {
    //return !!PlaySoundW(WideStringSoundFileName.c_str(), NULL, SND_FILENAME );
    return !!sndPlaySound(StringSoundFileName).c_str(),SND_ASYNC);
}

我使用 PlaySoundW测试了这个成员函数( )并没有问题,但
sndPlaySound()不会产生任何声音。我正在链接
-lwinmm -mwindows

I have tested this member function using PlaySoundW() and had no problems, butsndPlaySound() does not produce any sound. I am linking against -lwinmm -mwindows

我使用的是Win 8.1机器。

I am using a Win 8.1 machine.

这里的任何人都知道可能出现什么问题?

Anyone here knows what could be the problem?

推荐答案

否则,唯一要注意的是确保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播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 14:34