My program is playing a sound PlaySound
.
The program works fine and I can hear the sound, but when the song end, there is a delay for like 1 second, and then the song play again.
I asked Google, and he gave me this question - PlaySound() Delay
The guy who answerd , said that instead SND_SYNC
we need to use SND_ASYNC
, I listened to him and did it, but I can't hear anything.
Do you have any suggestions ?
Btw, this is the song I'm currently using for this project - Nyan Cat
I want that this song will be start again immediately, for the user to not hear that there is a Delay.
Final Code:
#include <iostream>
#include <Windows.h>
#include <string>
#pragma comment(lib, "winmm.lib")
int main()
{
std::string pathtosound = "C:\\Users\\roile\\Documents\\Dragonite\\nyan.wav";
while (true) {
PlaySound(pathtosound.c_str(), 0, SND_SYNC);
}
return 0;
}