SphereStudio.Plugins.SoundPicker.PlayFile C# (CSharp) Method

PlayFile() public method

Plays the song or sound located at the path's location.
public PlayFile ( string path ) : void
path string The full path of the file to play.
return void
        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;
            }
        }