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

Author Topic: Error Window after debugging with sf::Music  (Read 2207 times)

0 Members and 1 Guest are viewing this topic.

Bloodbane7

  • Newbie
  • *
  • Posts: 2
    • View Profile
Error Window after debugging with sf::Music
« on: October 08, 2011, 11:01:34 pm »
I am new to SFML and am having trouble playing music. I have looked at the tutorial and documentation and through the forum and internet but I can't find the solution to my problem.

I am using VS 2010 Express and the program builds and debugs and works fine UNTIL I add this:

sf::Music (name);

then the program builds without errors but as soon as I debug this window pops up:

(Name).exe - Application Error
-------------------------------------------------
"The application was unable to start correctly (0xc000007b). Click OK to close the application."
-------------------------------------------------

If I remove sf::Music it will debug correctly again, and moving it around will also cause the error.

I have all of the sfml-(whatever) dlls linked in my additional dependencies under debug and release (for whatever one they need) and copied into my project directory.
-- I have included openal32.dll and libsndfile-1.dll in my project directory but haven't added them to additional dependencies (maybe the problem? If so- what do I label them as?)

I am the using SFML 2.0 library.

The code is:

Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>


int main()
{
sf::VideoMode Vmode = sf::VideoMode::GetDesktopMode()
sf::RenderWindow Window(Vmode, "Window Name", sf::Style::Fullscreen);

sf::Texture Texture1; // create a texture variable for an image
if (!Texture1.LoadFromFile("waterfall2.jpg")) // checks to see if the image is valid
return EXIT_FAILURE;

sf::Sprite Sprite1;
Sprite1.SetTexture(Texture1);
Sprite1.SetPosition(0.0f, 0.0f);
Sprite1.SetScale((float)Window.GetWidth()/(float)Texture1.GetWidth(), (float)Window.GetHeight()/(float)Texture1.GetHeight());

while (Window.IsOpened())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
case sf::Event::KeyPressed:
if (Event.Key.Code == sf::Keyboard::M)
{
sf::Music mTitle;
if (!mTitle.OpenFromFile("Song.mp3"))
return EXIT_FAILURE;

mTitle.Play();
}
default:
break;
}
}

Window.Clear(sf::Color(0, 0, 255));to blue (RGB)

Window.Draw(Sprite1);

Window.Display();
}

return 0;
}


Any suggestions are appreciated.

Bloodbane7

  • Newbie
  • *
  • Posts: 2
    • View Profile
Error Window after debugging with sf::Music
« Reply #1 on: October 11, 2011, 06:44:46 pm »
I switched the #include graphics and audio around and then it ran and crashed right away. Then I used std::cin.get(); to find out why the game was crashing before returning 1 as an error. Is says "songname".mp3 is not recognized as a file type?

Did some digging and both .mp3 and .mid are not supported :/ this is disappointing. I need to convert all my sound files to .wav now.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Error Window after debugging with sf::Music
« Reply #2 on: October 11, 2011, 10:13:37 pm »
You should rather convert to .ogg, which is a compressed format.
Laurent Gomila - SFML developer