public void PlayFile(string path)
{
bool isMusic = Path.GetExtension(path) != ".wav";
IPlayer music;
try
{
try { music = new IrrPlayer(path, isMusic); }
catch (Exception) { music = new NAudioPlayer(path, isMusic); }
}
catch (Exception)
{
MessageBox.Show("Sound Test was unable to play the track you selected. The format may not be supported on your system.",
"Audio Playback Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
music.Play();
if (isMusic)
{
StopMusic();
_musicName = Path.GetFileNameWithoutExtension(path);
_music = music;
trackNameLabel.Text = @"Now Playing: " + _musicName;
playTool.Text = @"Playing";
playTool.Image = _playIcons.Images["play"];
pauseTool.Enabled = true;
pauseTool.CheckState = CheckState.Unchecked;
stopTool.Enabled = true;
}
}