我搜索了很多内容,没有运气,尤其是在加载.OGG文件的编码方面。我正在尝试以.ogg格式添加音频文件,却不知道问题出在哪里。
我首先将其添加到项目中的音频资产中。当我打开.OGG文件时,出现警告/错误: 如果重要的话,我应该以哪种编码方式加载.OGG文件?
#include "Sound.h"
Sound::Sound() {
const std::string pathToProject = "C:\\Users\\User\\projectName";
exSongbuffer.loadFromFile(pathToProject + "\\projectContainer\\Assets\\Sounds\\ExampleSound.ogg");
exampleSong.setBuffer(exSongbuffer);
}
#include <SFML/Audio/Sound.hpp>
#include <SFML/Audio/SoundBuffer.hpp>
class Sound {
public:
Sound();
sf::Sound ExampleSound;
sf::SoundBuffer exSoundBuffer;
}
class Configuration {
public:
Sound* sound = new Sound();
}
StateMachine::StateMachine() {
auto* sound = new Sound();
config.sound = sound;
sound->menuSong.play();
}
int main() {
StateMachine stateMachine;
while (stateMachine.run()) { // run() just runs the program until the user exits.
}
}