I am using winmm.dll and I found that I can't just suspend it and
resume it?
What should I do? Any better idea?
Should I use thread? and thread.suspend will work?
It's unlikely that you can simply suspend a thread playing a sound.
First, the thread that calls the API to play the sound is unlikely to have
anything to do with the thread actually playing the sound. Second, the
thread actually playing the sound is likely to be feeding audio samples to
the audio hardware; suspending that thread will just result in the
hardware repeating the same sample over and over.
Fortunately, there is an easier way.
Look at the AudioVideoPlayback
DirectX component. I am pretty sure that it includes pause/resume
functionality, unlike the basic .NET media SoundPlayer class.
Of course, that said...if you are using winmm.dll (via p/invoke
presumably), the wav/mci API has pause/resume as well, if I recall
correctly. IMHO using the AVP component is easier, since it doesn't
require p/invoke in your application, but you ought to be able to pause
and resume audio playback using the same playback mechanism you're using
now.
Pete