refactor: use using for SoundPlayer

This commit is contained in:
Anna 2020-08-03 23:16:07 -04:00
parent 141a2fad25
commit f7fb85a6d9
1 changed files with 8 additions and 8 deletions

View File

@ -464,14 +464,14 @@ namespace PeepingTom {
} else {
player = new SoundPlayer(this.config.SoundPath);
}
try {
player.Play();
} catch (FileNotFoundException e) {
this.SendError($"Could not play sound: {e.Message}");
} catch (InvalidOperationException e) {
this.SendError($"Could not play sound: {e.Message}");
} finally {
player.Dispose();
using (player) {
try {
player.Play();
} catch (FileNotFoundException e) {
this.SendError($"Could not play sound: {e.Message}");
} catch (InvalidOperationException e) {
this.SendError($"Could not play sound: {e.Message}");
}
}
}