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

Author Topic: Song Not Playing  (Read 5729 times)

0 Members and 1 Guest are viewing this topic.

mweston379

  • Guest
Song Not Playing
« on: October 06, 2020, 03:08:14 am »
I did exactly as is said in the SFML tutorials on how to play a song. My program compiles and runs, just the song never plays. You can see my code in the attached image. For context, the loop below there goes on for a very long time so it's not an issue of the loop ending too quickly then the program ends. Even without the setVolume() call it still doesn't work. I made sure to do all the basics like include <SFML/Audio.hpp> and use the -lsfml-audio flags in my Makefile so it's nothing trivial like that.

Any insight is appreciated. If my code looks fine then all I can think of is there's something wrong with the file. All I did was convert an mp3 file to .ogg which is what SFML uses in it's tutorial.
« Last Edit: October 06, 2020, 04:29:07 am by mweston379 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Song Not Playing
« Reply #1 on: October 06, 2020, 08:57:33 am »
Stupid question, but do you have the correct audio device set as default?
And does the file play in a media player (like VLC)? :D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Song Not Playing
« Reply #2 on: October 06, 2020, 07:18:39 pm »
If it's not failing at loading and is doing the main loop then it's also (in addition to what was mentioned above), test the music to see if it thinks it's playing.

You can output (song.getStatus() == sf::Status::Playing) to see. Try it just before the loop (after the window creation) and also from within the loop (maybe with a keypress?).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

mweston379

  • Guest
Re: Song Not Playing
« Reply #3 on: October 07, 2020, 05:27:47 pm »
I actually used that same conditional statement in an if statement to print out "yes" repeatedly if the song was playing and it did in fact print out yes over and over. The file plays on a media player...not sure about having the corerct audio device set as default. Though I'm working on my own computer my program is actually on my school's linux server that I ssh'd into from my own computer. I used WinSCP to transfer the audio file from my computer to the server so I don't know how being on another server affects that. At this point my guess is that's the issue since I'm not sure what else it could be. I just wanted to see if anything was wrong with the code.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Song Not Playing
« Reply #4 on: October 07, 2020, 09:18:41 pm »
So if it's running on a different machine entirely, how do you expect to hear any audio on your end?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/