I did absolutely everything according to the instructions and it came out as usual, I read the documentation, this error is not specified, in the console in quotes should be the directory of the audio file, but it is empty, how do you understand it? I searched a lot on the Internet, there is nothing on this topic. Visual studio 2022, C++, CMake, SFML 2.6.1, windows 11, intel core i5 9400f, RAM 16gb.
#include "chucknorris.h"
#include "Button.h"
#include <SFML/Audio.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(1280, 720), "SFML works!"/*, sf::Style::Fullscreen*/);
sf::CircleShape shape(100.f, 100);
shape.setFillColor(sf::Color::Green);
int x = 500;
int y = 250;
Button button(sf::Vector2i(5, 5), sf::Vector2i(5, 5));
sf::Music music;
if (!music.openFromFile("./ex.ogg"))
{
std::cout << "idi nahuy\n";
}
music.play();
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
sf::Mouse::getPosition();
if (event.type == sf::Event::Closed)
window.close();
}
shape.setPosition(sf::Vector2f(x, y));
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
here is the console, and the directory (which should be in quotes) is empty.
I want sfml to work properly and search for files in directories normally.
I think that the issue might be related to the path you're using to access the audio file.....
You have to make sure the file path to your audio file is correct. You're currently using ./ex.ogg. This means the program is looking for ex.ogg in the current working directory. Double-check that ex.ogg exists in the same directory as your executable or if not modify the path to where your file is located or just move it in the current working directory.
this code will print the current directory and the SFML error message to help debug it.