iT邦幫忙

0

C++播放.wav音檔錯誤

  • 分享至 

  • xImage

各位大大好,我今天要用c++寫個程式來播放.wav檔,但是程式執行後沒有播出,想請問大大們我要如何解決此問題?

#include <stdio.h>
#include <windows.h>

int main(int argc, char *argv[])
{
    PlaySound("C:\RickRoll\RickRoll\music\RickRoll.wav", NULL, SND_SYNC|SND_FILENAME);

    getchar();
    return 0;
}
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
1
elena199x
iT邦見習生 ‧ 2024-07-25 12:16:12

You should check the file path, ensure the necessary header is included, and verify correct usage of the PlaySound function. If the Slope Game issue persists, consider sound card problems or compiler issues.

binyiWu iT邦新手 5 級 ‧ 2024-07-27 17:30:16 檢舉

I got it now.Thanks

1
YC
iT邦好手 1 級 ‧ 2024-07-29 10:55:23

根據官方文件

PlaySound(TEXT("recycle.wav"), NULL, SND_FILENAME);

你路徑需要加上TEXT

參考

binyiWu iT邦新手 5 級 ‧ 2024-08-03 10:39:29 檢舉

我懂了~~謝謝!!!

1
magnus21
iT邦見習生 ‧ 2024-08-21 12:55:47

The audio file path needs to be specified correctly. In C++, you need to use double slashes (\) to avoid errors when using backslashes (). Change your file path as follows:
PlaySound("C:\RickRoll\RickRoll\music\RickRoll.wav", NULL, SND_SYNC | SND_FILENAME);

Monkey Mart

0

I use C++ language to create this online game website: slope game

我要發表回答

立即登入回答