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

Author Topic: No Sound on a basic window application  (Read 2564 times)

0 Members and 1 Guest are viewing this topic.

Patrik

  • Guest
No Sound on a basic window application
« on: January 22, 2012, 04:34:11 pm »
Hey guys,

I've made a simple window application with SFML and although I've
loaded the needed sound there comes no music. But otherwise
everything is running well.

Here's the source code:

Code: [Select]

#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

using namespace sf;

int main(){
    RenderWindow Window(VideoMode(600, 400, 32), "The Deployment - Here they come!");
    while(Window.IsOpened()){
        Event Close;
        while(Window.GetEvent(Close)){
            if(Close.Type == Event::Closed){
                Window.Close();
            }
        }
        Music BackgroundMusic;
        if(!BackgroundMusic.OpenFromFile("/usr/local/games/The Deployment/sounds/BGSound.ogg")){
            return 0;
        }
        BackgroundMusic.SetLoop(true);
        BackgroundMusic.SetVolume(75.f);
        BackgroundMusic.Play();
        Window.Clear(Color(0, 191, 255));
        Window.Display();
    }
    return 0;
}


I using Code::Blocks on Ubuntu 11.10 and the needed libraries are all linked.

Thanks for any help,
Patrik

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
No Sound on a basic window application
« Reply #1 on: January 22, 2012, 04:55:30 pm »
Open/play the music before the main loop.
Laurent Gomila - SFML developer

Patrik

  • Guest
No Sound on a basic window application
« Reply #2 on: January 22, 2012, 05:03:51 pm »
Thanks Laurent, now does it works  :D

 

anything