Пример #1
0
        private async void btnPlay_Click(object sender, EventArgs e)
        {

            if (this._play.CurrentStatus != MediaStatus.Stopped)
            {
                if (this._play.CurrentStatus == MediaStatus.Paused)
                {
                    // Is currently paused so start playing file and set the image to the pause image.
                    btnPlay.Image = MediaPlayer.Properties.Resources.pause;
                }
                if (this._play.CurrentStatus == MediaStatus.Playing)
                {
                    // Is currently playing a file so pause it and set the image to the play image.
                    btnPlay.Image = MediaPlayer.Properties.Resources.play;
                }

                this._play.Pause();

                return;
                
            }

            if (this._filePath == String.Empty || this._filePath == null)
            {

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    this._filePath = openFileDialog1.FileName;
                }
                else
                {
                    MessageBox.Show("You must select a video file.", "Select a file", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            _videoSettings = new Discover(this._filePath, MediaPlayer.Properties.Settings.Default.MPlayerPath);
            await _videoSettings.ExecuteAsync();
            this._play.Play(this._filePath);
            lblVideoLength.Text = TimeConversion.ConvertTimeHHMMSS(_videoSettings.Length);

            btnPlay.Image = MediaPlayer.Properties.Resources.pause;

            comboBoxAudioTracks.DisplayMember = "Name";
            comboBoxAudioTracks.ValueMember = "ID";
            comboBoxAudioTracks.DataSource = _videoSettings.AudioTracks;


            comboBoxSubtitles.DisplayMember = "Name";
            comboBoxSubtitles.ValueMember = "ID";
            comboBoxSubtitles.DataSource = _videoSettings.SubtitleList;

        }