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

Author Topic: Window Crashes when loading sound and music  (Read 3129 times)

0 Members and 1 Guest are viewing this topic.

CodingMadeEasy

  • Newbie
  • *
  • Posts: 38
    • MSN Messenger - petetheheat_represent@msn.com
    • AOL Instant Messenger - 622+Amaretto+Ave
    • Yahoo Instant Messenger - petetheheat_baller@yahoo.com
    • View Profile
    • http://www.youtube.com/CodingMadeEasy
Window Crashes when loading sound and music
« on: February 02, 2011, 11:22:02 pm »
Hi Everybody. For some reason I can't load sounds or music in sfml anymore. I got it to work and I used music in a lot of my other programs but not suddenly it won't work! It won't even display an error message , the window just crashes when it tries to load the file , which generally shouldn't happen

Here's my code

Code: [Select]


void Sound::LoadSound (const char* filename, int linenum) {
  string test;
  ifstream openfile (filename);

    cout << "opened " << filename << endl;
    for (int i = 0; i <= linenum; i ++) {
      if (openfile.is_open())
        openfile >> test;
    }
    //name = "Sound/audio.wav";
    cout << "Done" << endl;
    cout << test << endl;
    if (SoundBuf.LoadFromFile(test)) {
      cout << "Loaded " << test << " successfully" << endl;
      SoundInst.SetBuffer (SoundBuf);
    }
    else
      cout << "Failed" << endl;

} // End of LoadSound ( , )

void Sound::LoadMusic (const char* filename, int linenum) {
  ifstream openfile;
  string testing;
  openfile.open(filename, ifstream::in);
  for (int i = 0; i <= linenum; i ++)
    openfile >> testing;

    cout << testing << endl;

  if (MusicInst.OpenFromFile (testing))
    cout << "Loaded " << testing << " successfully" << endl;
} // End of LoadMusic ( , )



I used cout to see it if got the directory right and it works I just don't know why the sound and music won't load and why it crashes the window.

I'm using sfml 1.6 on windows vista and I'm using code::blocks

Help would be greatly appreciated :D[/code]

tntexplosivesltd

  • Full Member
  • ***
  • Posts: 163
    • View Profile
Window Crashes when loading sound and music
« Reply #1 on: February 03, 2011, 01:04:44 am »
So, it used to work? What's changed since then?

CodingMadeEasy

  • Newbie
  • *
  • Posts: 38
    • MSN Messenger - petetheheat_represent@msn.com
    • AOL Instant Messenger - 622+Amaretto+Ave
    • Yahoo Instant Messenger - petetheheat_baller@yahoo.com
    • View Profile
    • http://www.youtube.com/CodingMadeEasy
Window Crashes when loading sound and music
« Reply #2 on: February 03, 2011, 02:30:27 am »
Nothing. And that's the weird thing. I just can't figure out the problem

ANtY93

  • Newbie
  • *
  • Posts: 6
    • View Profile
Window Crashes when loading sound and music
« Reply #3 on: April 25, 2011, 02:21:05 am »
I have the same problem, it also happens with fonts (those which I wrote earlier to load are working).
When I'm trying to draw sf::String to which I set some loaded from file font before.

Please help, cause it is important to me and I need solution fast.

ANtY93

  • Newbie
  • *
  • Posts: 6
    • View Profile
Window Crashes when loading sound and music
« Reply #4 on: April 25, 2011, 10:41:47 am »
I tried new project and there it is working, what can be wrong with loading from file new sound buffer?


EDIT: Don't bother, I found out that I forgot to put "-s" to sound library.

 

anything