SFML community forums

Help => Audio => Topic started by: ngocdung93 on December 02, 2013, 03:38:29 pm

Title: Can you help me with the code for a simple audio player please
Post by: ngocdung93 on December 02, 2013, 03:38:29 pm
Hi everybody. I am a newbie and i have a homework about coding a simple audio player. I can write a program that show a plain window when you open it and play the audio but could you show me how to insert a picture into that window and have click function (click to play-click to pause, something like that).

This is my code

sf::RenderWindow window(sf::VideoMode(sf::VideoMode::getDesktopMode()), "SFML");
   sf::SoundBuffer buffer;
    if (!buffer.loadFromFile("Music.wav"))
        return -1;
   sf::Sound sound;
   sound.setBuffer(buffer);
   sound.play();
   while(window.isOpen())
   {
      sf::Event event;
      while(window.pollEvent(event))
      {
         if(event.type == sf::Event::Closed)
            window.close();
      }
   }
Title: Re: Can you help me with the code for a simple audio player please
Post by: eXpl0it3r on December 02, 2013, 04:25:45 pm
We're not really here to write your homework...

By looking at the tutorials, documentation and examples that get shipped with SFML, you should be able to get something up and running in no time. ;)
Title: Re: Can you help me with the code for a simple audio player please
Post by: ngocdung93 on December 03, 2013, 05:34:06 am
thank you anyway. i am trying my best,hope to figure it out soon.