【发布时间】:2021-09-02 14:13:22
【问题描述】:
我正在尝试实现一个背景音乐循环并发出其他声音,当我再次使用“PlaySound”功能时,它不会被切断。
void CcpPongView::playBGsound(int num)
{
//added in the linker to additional name : winmm.lib
if(num)
PlaySound(L"sound.wav", NULL, SND_LOOP | SND_ASYNC);
}
void CcpPongView::initGame()
{
std::thread test (playBGsound, 1);
test.join();
}
这是我使用 Playsound 的第二个地方
void Ball::playSound()
{
switch (rand()%2) {
case 0:PlaySound(sounds[0], NULL, SND_FILENAME | SND_ASYNC);
break;
case 1:PlaySound(sounds[1], NULL, SND_FILENAME | SND_ASYNC);
break;
}
我不确定我需要在哪里放置线程或如何在 mfc Single Document 中创建线程.. (“num”是用来测试的)
【问题讨论】: