0

I am currently having problems with a console application in delphi. I start playing a song as soon as the program starts using the sndPlaySound function. But, later in the program I use sleep() to improve the aesthetics of the program. When I do this my sound stops playing. Is there anyway to have this play in the background of the program so it is not interrupted by the sleep()? Is there any other way to easily create a delay without the sleep function?

2
Contributors
1
Reply
12
Views
3 Years
Discussion Span
Last Post by SalmiSoft
0

sndPlaySound doesn't work like that for me. I guess you are specifying SND_ASYNC in your sndPlaySound call, so I am not sure what is going wrong. I just tried a quick test:

    for i := 1 to 1000 do
      writeln(i);
    writeln('Play sound');
    sndPlaySound('Whatever.wav',SND_ASYNC);
    writeln('Sleep');
    sleep(2000);
    for i := 1 to 1000 do
      writeln(i);
    readln;

This worked as I expected. I see the 'Sleep' output and listen to the audio during the sleep period. If the audio is longer than the sleep period I get the second count at the same time as the end of the audio.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.