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

Author Topic: Failed to open sound file "canary.wav" (couldn't open stream)  (Read 12350 times)

0 Members and 1 Guest are viewing this topic.

SuperCharger

  • Newbie
  • *
  • Posts: 3
    • View Profile
Not sure what I have done wrong or what I am missing but when I run this code I get
"Failed to open sound file "canary.wav" (couldn't open stream) message.
My code is:

sf::SoundBuffer music;

   if (!music.loadFromFile("canary.wav"))
   {
      std::cout << "Error" << std::endl;
   }

   sf::Sound buffer(music);
   buffer.play();

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Failed to open sound file "canary.wav" (couldn't open stream)
« Reply #1 on: April 01, 2016, 08:12:33 am »
It means the wav file wasn't found. The errorr message is slightly misleading due to a bug that has already been fixed in master.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SuperCharger

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: AW: Failed to open sound file "canary.wav" (couldn't open stream)
« Reply #2 on: April 01, 2016, 09:20:28 am »
It means the wav file wasn't found. The errorr message is slightly misleading due to a bug that has already been fixed in master.
I currently have it located in my debug folder, where should I move it and what is the correct way to type in a string for loadFromFile(string)?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Failed to open sound file "canary.wav" (couldn't open stream)
« Reply #3 on: April 01, 2016, 09:28:06 am »
It needs to be in the working directory. If you use VS then that's by default next to your vcxprj file. The working directory can usually be changed in the project settings.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SuperCharger

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Failed to open sound file "canary.wav" (couldn't open stream)
« Reply #4 on: April 01, 2016, 09:37:22 am »
It needs to be in the working directory. If you use VS then that's by default next to your vcxprj file. The working directory can usually be changed in the project settings.
That worked, just moved the files, thankyou

 

anything