fix: catch exceptions when playing sound

This commit is contained in:
Anna 2021-11-20 23:13:12 -05:00
parent b4ed5ed02f
commit f8ac56b3c4
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
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();