4

How would i make it so in my program there is a button when that button is clicked i want it to play a .wma file without opening and media player?

Steve Rowe
  • 19,315
  • 9
  • 50
  • 81
H4cKL0rD
  • 5,193
  • 15
  • 50
  • 73

5 Answers5

19

The C++ standard does not include this functionality. That means it depends on what your system offers.

For Windows, you can try something like PlaySound.

However, you best bet is to use a pre-existing library, like:

Searching for C++ Sound Library brings up a lot of information.

Also, check out these three other SO topics:

eeze
  • 448
  • 1
  • 4
  • 20
GManNickG
  • 478,574
  • 51
  • 478
  • 539
2

Although the above answer mentions it (and everything else, it doesn't give any recommendations so...), FMOD is the king of C++ sound (the most used) and works great so I'd recommend FMOD in particular.

Robert Gould
  • 67,019
  • 60
  • 184
  • 270
1

Gstreamer is a free, cross-platform multimedia framework written in C (using GObject) that allows encoding/decoding for many types of media, including wma. Very easy to use and well documented.

tmatth
  • 489
  • 3
  • 13
0

KDE's Phonon is a cross-platform(!) C++ multimedia library. It supports native sound systems as backends. Worth a look if you haven't seen it before, and a simple video player can be written in a mere 83 lines of code.

greyfade
  • 24,214
  • 7
  • 64
  • 79
0

For Windows, in all honesty your best bet is DirectShow. The RenderFile API allows you to play most audio file types with just a few lines of code.

The best part about DirectShow is that it's a part of the Windows platform so you don't need to bundle an external component.

Larry Osterman
  • 15,996
  • 31
  • 59