I am trying to stop a Cue, then play it again. This code is in the Update() loop:
Cue torpedoSound = soundBank.GetCue("torpedo");
torpedoSound.Stop(AudioStopOptions.AsAuthored);
torpedoSound.Play(); // Invalid Operation Exception
However, I always get an InvalidOperationException
at the above location. The documentation says that will occur if Play()
is called on a Cue
for which isPlaying
is true. But if I call Stop()
immediately before, how can this be?
This works fine:
soundBank.PlayCue("torpedo");
Placing a call to Stop()
immediately after that allows the sound to play anyway, which surprises me:
soundBank.PlayCue("torpedo");
torpedoSound.Stop(AudioStopOptions.Immediate);
Shouldn't this make it never be audible to the user?
Additionally, when the sound is already playing, calling Stop()
fails to stop it.
I'm new to C#/XNA.