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?

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('Play sound');
    for i := 1 to 1000 do

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.