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

Author Topic: Problem opening sound file  (Read 2662 times)

0 Members and 1 Guest are viewing this topic.

N0iZE

  • Newbie
  • *
  • Posts: 1
    • View Profile
Problem opening sound file
« on: March 07, 2015, 09:43:27 pm »
Greetings SFML users. Ill get right to where the cookie crumbles.

I have made a function which plays a sound file in my resources map.

void MusicFunctions::playMusic(MusicFunctions &other)const
{
   // std::cout << other.songs[1].getSongTitle();
    string playeble = resourcePath() + other.songsInPlaylist[1].getSongTitle();
    std::cout << playeble;
    other.openFromFile(playeble);
    other.play();
}

songsInPlaylist is a vector which contains the class Song.
So as I'm trying to play the sound file(which in this case is called "02 song2.flac".
But when i do try to play it it gives me this error:
Failed to open sound file "/Users/xxxxx/Library/Developer/Xcode/DerivedData/MusicPlayer-beqmpaqteyhiekdpwwslfglinhbk/Build/Products/Debug/MusicPlayer.app/Contents/Resources/02 song2.flac
" (System error : No such file or directory.).

I have tried to print out the path where the file is and comparing them, and they are identical.
What should I do?


/N0iZE

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Problem opening sound file
« Reply #1 on: March 07, 2015, 10:07:13 pm »
Not directly related to what you ask, but I think you may enjoy taking a look at my Jukebox class. It does what you seem to want and works just fine :)
Maybe you can get some ideas for your code :-)

Ohh and please use the code tags when posting code.
« Last Edit: March 07, 2015, 10:46:31 pm by Jesper Juhl »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
AW: Problem opening sound file
« Reply #2 on: March 08, 2015, 05:48:42 pm »
Recheck the path and make sure the file and directory has the right permission.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Problem opening sound file
« Reply #3 on: March 08, 2015, 06:22:06 pm »
Quoting the OS X tutorial:

Quote
Resource files: the resources of the basic example are put in this folder and are automatically copied to your application bundle when you compile it.
To add new resources to your project, simply drag and drop them into this folder and make sure that they are a member of your application target; i.e. the box under Target Membership in the utility area (cmd+alt+1) should be checked.

Does that help?
SFML / OS X developer