Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Failed to open "file.mp3" for reading  (Read 5050 times)

0 Members and 1 Guest are viewing this topic.

IndigoNeko

  • Newbie
  • *
  • Posts: 2
    • View Profile
Failed to open "file.mp3" for reading
« on: September 26, 2011, 10:15:04 pm »
I'm sure I'm doing something stupid, but I can't for the life of me get the audio system working. Not having any problems with graphics at all, just audio.

I'm using Microsoft Visual Studio C++ 2010.
I'm using SFML 1.6.
I've installed OpenAL.
I've installed libsndfile.

I'm linking:sfml-audio-d.lib; sfml-graphics-d.lib; sfml-main-d.lib; sfml-network-d.lib; sfml-system-d.lib; sfml-window-d.lib; opengl32.lib; glu32.lib; assimp.lib; BulletCollision-d.lib; BulletDynamics-d.lib; LinearMath-d.lib

My project configuration is set to Debug. My project SubSystem is set to Console (so I can vew std::cerr). The engine.hpp file is pretty complicated, but in this instance all it's doing is loading settings from an INI file and loading an sf::RenderWindow instance using the INI settings.

Code: [Select]

// Windows Headers
#include <Windows.h>
// SFML Headers
#include <SFML\System.hpp>
#include <SFML\Audio.hpp>
// ReoTekEngine Headers
#include "Engine.hpp"

int main(int argc, char* argv[])
{
// TODO: Parse Command Line Options Here.
rt::ReoTekEngine GameEngine;
GameEngine.LoadEngineSettings( "default.ini" );
GameEngine.OpenRenderWindow();

// TODO: Insert Code Here.
FILE *fp;
fp = std::fopen( "01_Reign_of_Hell.mp3", "r" );
if( fp == NULL )
{
// Error
std::cerr << "File \"01_Reign_of_Hell.mp3\" does not exist." << std::endl;
}

sf::Music MusicTrack;
if( !MusicTrack.OpenFromFile( "01_Reign_of_Hell.mp3" ) )
{
// Error
};
sf::Clock Clock;
while( Clock.GetElapsedTime() < 5.0f ){};

GameEngine.CloseRenderWindow();
GameEngine.SaveEngineSettings( "default.ini" );
return EXIT_SUCCESS;
}


I have 01_Reign_of_Hell.mp3 in the core project directory, same as my default.ini file which my application has no problems reading or writing. Using fopen to test the file shows that the file exists.

Can someone tell me why it would say "Failed to open "01_Reign_of_Hell.mp3" for reading"?

IndigoNeko

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Failed to open "file.mp3" for reading
« Reply #1 on: September 26, 2011, 10:21:49 pm »
Nevermind. I tried converting the mp3 file to an ogg format and loading it as an ogg file. Works just fine. Guess I'll just have to convert all my tracks.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Failed to open "file.mp3" for reading
« Reply #2 on: September 27, 2011, 12:12:07 am »
If you had read the features page you'd have know that SFML doesn't support the MP3 format. Thus you'll indeed to convert all of your files.
Want to play movies in your SFML application? Check out sfeMovie!