Stop Robot.Notifications.PlaySound() logging 'succes' lines
Stop Robot.Notifications.PlaySound() logging 'succes' lines
19 Mar 2021, 11:53
Is there a way to disable the
Notification: PlaySound of 'C:\Users\....mp3' was successful
it cluthers up the log with these useless lines.
If it is NOT succesfull it should log ofcourse or even better:
throw an exception instead of cluthering the log.
Replies
Shares4us
20 Mar 2021, 00:08
RE:
amusleh said:
Hi,
There is no way to disable the log right now, but you can use the .NET sound player instead of Notifications.PlaySound method and it will not product any log.
private static void PlaySound(string path) { if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException($"'{nameof(path)}' cannot be null or whitespace", nameof(path)); SoundPlayer soundPlayer = null; try { soundPlayer = new SoundPlayer(path); soundPlayer.PlaySync(); } finally { if (soundPlayer != null) soundPlayer.Dispose(); } }
You have to add "using System.Media" for the above code to work.
Thanks for your time. But i hoped Spotware would change it ;-)
@Shares4us
amusleh
19 Mar 2021, 12:10
Hi,
There is no way to disable the log right now, but you can use the .NET sound player instead of Notifications.PlaySound method and it will not product any log.
You have to add "using System.Media" for the above code to work.
@amusleh