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

Author Topic: Music how to?  (Read 2345 times)

0 Members and 1 Guest are viewing this topic.

GroundZero

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Music how to?
« on: September 01, 2011, 03:25:59 pm »
Dear reader,

kan someone tell me how to play music and -or sounds correctly?
I tried the code from 2.0 documentation but no error, but neither sound or any thing.

Could someone make me a simple code so I can see the proper way?
I am useing SFML 2.0

Best regards

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Music how to?
« Reply #1 on: September 01, 2011, 03:30:18 pm »
The documentation code is supposed to be the simple/proper one. Show us your code if it doesn't work.

Have you tried the "sound" SFML example?
Laurent Gomila - SFML developer

GroundZero

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Music how to?
« Reply #2 on: September 01, 2011, 04:07:23 pm »
Code: [Select]
   sf::SoundBuffer buffer;
    if (buffer.LoadFromFile("sound/laugh.wav")) {

       sf::Sound sound;
       sound.SetBuffer(buffer);
       sound.Play();
    }


All it does with this code is give me a error:

Starting C:\Users\Ground Zero\Desktop\C++\leren\GAME\game-build-desktop\debug\test.exe...
C:\Users\Ground Zero\Desktop\C++\leren\GAME\test-build-desktop\debug\test.exe exited with code -1073741515

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Music how to?
« Reply #3 on: September 02, 2011, 02:03:53 am »
Quote from: "GroundZero"
Code: [Select]
   sf::SoundBuffer buffer;
    if (buffer.LoadFromFile("sound/laugh.wav")) {

       sf::Sound sound;
       sound.SetBuffer(buffer);
       sound.Play();
    }


All it does with this code is give me a error:

Starting C:\Users\Ground Zero\Desktop\C++\leren\GAME\game-build-desktop\debug\test.exe...
C:\Users\Ground Zero\Desktop\C++\leren\GAME\test-build-desktop\debug\test.exe exited with code -1073741515
Complete and minimal code please.
I use the latest build of SFML2

atmamta

  • Newbie
  • *
  • Posts: 2
    • View Profile
Music how to?
« Reply #4 on: November 22, 2011, 06:06:53 pm »
...the problem is that your main thread exits before the audio playing thread could play any samples, and kills any spawned threads. if you insert this line right after sound.Play() the code will work fine.:

sf::Sleep(sound.GetDuration());

 

anything