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

Author Topic: Can you help me with the code for a simple audio player please  (Read 1853 times)

0 Members and 1 Guest are viewing this topic.

ngocdung93

  • Newbie
  • *
  • Posts: 6
    • View Profile
Can you help me with the code for a simple audio player please
« 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();
      }
   }

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Can you help me with the code for a simple audio player please
« Reply #1 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ngocdung93

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Can you help me with the code for a simple audio player please
« Reply #2 on: December 03, 2013, 05:34:06 am »
thank you anyway. i am trying my best,hope to figure it out soon.