fix: catch exceptions when playing sound

This commit is contained in:
Anna 2021-11-20 23:13:12 -05:00
parent d82d0bf0cb
commit 96880ae757
1 changed files with 8 additions and 4 deletions

View File

@ -188,11 +188,15 @@ namespace PeepingTom {
using var output = new WaveOutEvent {
DeviceNumber = soundDevice,
};
output.Init(channel);
output.Play();
try {
output.Init(channel);
output.Play();
while (output.PlaybackState == PlaybackState.Playing) {
Thread.Sleep(500);
while (output.PlaybackState == PlaybackState.Playing) {
Thread.Sleep(500);
}
} catch (Exception ex) {
PluginLog.LogError(ex, "Exception playing sound");
}
}
}).Start();