I am trying to play a sound in a new thread, so that other sounds don’t interrupt it, while it is playing.
But it doesn’t work. Although the new thread runs in background (I assume), the sounds which are played afterwards interrupt it.
ParameterizedThreadStart pts;
Thread t;
private void playStreak(Object p)
{
SoundEffect sound = SoundEffect.FromStream(Application.GetResourceStream(new Uri("SOUNDFX/BOMB.wav", UriKind.Relative)).Stream);
SoundEffectInstance instance = sound.CreateInstance();
instance.Play();
}
private void playAsThread()
{
pts = new ParameterizedThreadStart(playStreak);
t = new Thread(pts);
t.Name = "Streak sound!";
t.Start();
}
I want to play various sounds without interrupting each other.
I think you don’t need to use threads. You can have 16 SoundEffectInstances at one moment. Isn’t it enough?
Check this example.
They just hold three
SoundEffectinstances.and play them by some event.