SFML community forums

Help => Audio => Topic started by: CytraL on May 10, 2013, 06:25:48 pm

Title: [SOLVED] I can't play music
Post by: CytraL on May 10, 2013, 06:25:48 pm
Hi! I've never had problems playing sounds but with 2.0 yes.. xDD

Code: [Select]
    sf::Music musicIntro;
    if (musicIntro.openFromFile("sonidos/intro.ogg"))
    {
        //musicIntro.setPitch(1.0f);
        //musicIntro.setVolume(100);
        musicIntro.play();
    }

I try with .wav and .ogg... Can found the sound here: http://soundbible.com/1563-Pacman-Introduction-Music.html (http://soundbible.com/1563-Pacman-Introduction-Music.html)

P.S: SFML not show errors in console..
P.S 2: Sry for my bad english :d

-------------------

Yes... i know.... omg.... xDD
Title: Re: I can't play music
Post by: Grimshaw on May 10, 2013, 07:19:44 pm
You re doing that code in a local scope, like a function or something. When that function ends, the sf::Music object is destroyed and you don't get to hear anything.

Define sf::Music in a place that it will remain alive for longer time
Title: Re: I can't play music
Post by: CytraL on May 10, 2013, 07:27:12 pm
Fuuuuuuu.... sry sry sry sry sry sry sry sry sry xDDDDD