if audio is playing
public class SoundEffect
{
string _soundFile;
Thread _soundThread;
bool _isStopped = true;
public bool IsFinished { get { return _isStopped; } }
public SoundEffect(string soundFile)
{
_soundFile = soundFile;
}
public void Play()
{
if (!_isStopped)
return;
_soundThread = new Thread(PlayThread);
_soundThread.Start();
}
private void PlayThread()
{
_isStopped = false;
System.Media.SoundPlayer player = new System.Media.SoundPlayer(_soundFile);
player.PlaySync();
_isStopped = true;
}
}