Hey all,
Can anyone give me a quick runthrough of how I correctly code to play an audio file? I need to dynamically link it as well, as writing the full file path isn't good practice.
Thanks.
it depends what format the audio file is in. if the audio file is a .wav file, you can use the PlaySound() function from the windows API. if it is not a .wav file, the only way that I know of to play sound files is to use a library that supports the type of file you are working with.
the only way that I know of to play sound files is to use a library
No, you don't need any external library (never in Windows)
You can play any sound (MP3, WMA, ..) with standard and native Win32 api (MM apis, DS, etc... and others, see SDK samples)
george135... I'm really confused about you. You've never posted a single line of code in any post I have ever seen you make... I would swear you are some kind of AI Microsoft Marketing bot and not a real person.
???
Why do you want that I copy-paste the code from MS ?
Can't you download and look at MS SDK samples ?
Each Win32 C or C++ sample has several source files with hundreds of lines of code !
george135, why the hell would you use Microsoft's WinAPI when you could just as easily use a cross-platform and possibly even more effecient library. What you just said is literally the WORST advice I've EVER seen anyone give.
For audio decoding and encoding, the likelyhood that there was much effort going into making it cross-platform is unlikely. There aren't many components that the audio decoding and encoding library needs to rely on to make them cross-platform. Even if it wasn't more effecient, the benefit of being cross-platform is a great advantage.
If you look in the headers, you can see some classes (or structs) being used internally, so I guess you can say that it uses C++, but for some strange reason they thought that they should give functions to do everything. They have you use id's to indicate specific models. While you can build your own set of classes to manage these objects for you, it would probably be faster if they actually gave an OO interface themselves.