每次我尝试使用 sfml 播放音乐时,我都会遇到一个
Failed to open sound file "" (couldn't open stream)
Failed to play audio stream: sound parameters have not been initialized (call initialize() first)
error.
我试过将我的音频放在多个地方。目前,我的代码看起来像这样
void PlaySound()
{
sf::Music music;
music.openFromFile("fullBattleTheme.wav");
music.play();
}
在这个代码实例中,我在解决方案的根目录中有 wav 文件。
但我也让 openFromFile 尝试不同的目录,以及同一目录的不同实现。
我尝试过的:
music.openFromFile("C:/Users/Angel/source/repos/RockTheStick/fullBattleTheme.wav");
music.openFromFile("C:\\Users\\Angel\\source\\repos\\Rockthestick\\sounds\\fullBattleTheme.wav");
music.openFromFile("C:\\Users\\Angel\\source\\repos\\Rockthestick\\fullBattleTheme.wav");
编辑:我尝试在 wmp.h 中使用 PlaySound 函数并使用它工作正常的相同目录。我想继续前进如果我要使用 wmp
,我真的不需要 sfml