I suggest you to use a 3rd party library. PlaySound only can play WAVs, and is not able to play more files in the same time.
I personally use the Bass Library.
All you have to do is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include "bass.h"
int main()
{
if(!BASS_Init(-1,44100,0,0,0)) //Initializes BASS Library. Needed only once.
return 0;
HSTREAM AudioChannel = BASS_StreamCreateFile(false,"Audio File Name Here plox",0,0,0);
//Create a Audio Stream from a File.
BASS_ChannelPlay(AudioChannel,true);
//Plays the Stream.
while(BASS_ChannelIsActive(AudioChannel))
{
//Waits until song/audio file ends.
Pause(500);
}
BASS_Free();
return 1;
}
| |
This is the complete code you need to play an audio file.
BASS Library natively supports WAVs, MP3s, OGGs and has many plugins like WMA, MP4...
Link: www.un4seen.com/
Other functions are:
BASS_ChannelStop(HANDLE) - Stops a Stream
BASS_ChannelPause(HANDLE) - Pauses a Stream
HANDLE is AudioChannel over. (I mean, you can do BASS_ChannelStop(AudioChannel) and BASS_ChannelPause(AudioChannel). Remember, ChannelStop stops a channel, ChannelPause pauses it and you can re-play it with BASS_ChannelPlay. )