audio - c++ sfml mp3 music player error -


i'm trying implement music game using mp3 music file player fails load mp3(error1) file , every time press "e" prints error(error2).

error1: failed open sound file "music.mp3" couldn't open stream

error2: failed play audio stream: sound parameters have not been initialized call initialize first

code:

#include <sfml/graphics.hpp> #include <sfml\audio.hpp> #include <iostream>  const int width = 800; const int height = 800; const std::string title = "game 2000";  int main() {     sf::renderwindow window(sf::videomode(width, height), title);     window.setverticalsyncenabled(true);     sf::circleshape shape(400.f);     shape.setfillcolor(sf::color::green);     sf::clock clock;      sf::music music;      if (!music.openfromfile("music.mp3"))         std::cout << "cannot find music.mp3" << std::endl;       while (window.isopen())     {         sf::time time = clock.getelapsedtime();         sf::event event;         while (window.pollevent(event))         {             if (event.type == sf::event::closed)                 window.close();         }          if (sf::keyboard::iskeypressed(sf::keyboard::escape))             window.close();         if (sf::keyboard::iskeypressed(sf::keyboard::e))             music.play();          //std::cout << 1.0f / time.asseconds() << std::endl;         clock.restart().asseconds();          window.clear();         window.draw(shape);         window.display();     }      return 0; } 

directory: enter image description here

edit

i tried different formats mp3 wav ogg no change

current files in directory:

enter image description here

error 2 follow error, since loading doesn't fail (this or bug inside sfml).

your actual problem fact sfml doesn't support mp3 files. convert file wav or ogg , try again.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -