Beispiel #1
0
        /// <summary>
        /// Play the music
        /// </summary>
        private void Play()
        {
            //Initialize Player
            if (Player == null)
            {
                Player = new WaveOut();
            }

            if (SelectedItem == null)
            {
                return;
            }

            //if(SelectedItem.FullPath == Reader != null ? Reader. )

            switch (Player.PlaybackState)
            {
            case PlaybackState.Playing:
                Player.Pause();
                if (!Reader.Equals(new AudioFileReader(SelectedItem.FullPath)))
                {
                    try
                    {
                        Reader.Dispose();
                    }
                    catch { }
                    Reader = new AudioFileReader(SelectedItem.FullPath);
                    Player.Init(Reader);
                    Player.Play();
                }
                break;

            case PlaybackState.Paused:
                Player.Play();
                break;

            case PlaybackState.Stopped:
            {
                try
                {
                    Reader.Dispose();
                }
                catch { }
                Reader = new AudioFileReader(SelectedItem.FullPath);
                Player.Init(Reader);
                Player.Play();
            }
            break;
            }
        }