I am using SoundPlayer class in C# (WPF), to play the same .5s audio over and over (on key press). Every time user presses custom on-screen keyboard buttons, sound plays.
static SoundPlayer soundPlayer = null;
try
{
soundPlayer = new SoundPlayer(@"c:\media\click.wav");
}
catch (Exception e)
{
Logger.LogException(e);
}
// later on (usage)
try
{
soundPlayer?.Play();
}
Can anyone provide some guidance on if I should keep this SoundPlayer obj as static or if I should change to instance based? Thanks!