Trycatch sound stop, only stop if a sound has been played

Closes #3224

mono's impl of soundplayer is different, hence the need to be a little safer here.
bdd772531d/mcs/class/System/System.Media/SoundPlayer.cs (L255)
https://referencesource.microsoft.com/#System/sys/system/Media/SoundPlayer.cs,455
This commit is contained in:
Kurt 2021-06-22 17:06:30 -07:00
parent 3fecea9e29
commit 8bac5c259a

View file

@ -26,7 +26,16 @@ namespace PKHeX.WinForms.Controls
#pragma warning restore CA1031 // Do not catch general exception types
}
public void Stop() => Sounds.Stop();
public void Stop()
{
if (string.IsNullOrWhiteSpace(Sounds.SoundLocation))
return;
try { Sounds.Stop(); }
#pragma warning disable CA1031 // Do not catch general exception types
catch { Debug.WriteLine("Failed to stop sound."); }
#pragma warning restore CA1031 // Do not catch general exception types
}
private static string GetCryPath(ISpeciesForm pk, string cryFolder, int format)
{