Пример #1
0
        /// <summary>
        /// 播放
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPlay_Click(object sender, EventArgs e)
        {
            //设置按钮状态
            btnPlay.Enabled  = false;
            btnPause.Enabled = true;
            btnStop.Enabled  = true;
            btnLast.Enabled  = true;
            btnNext.Enabled  = true;

            if (!media_is_open)
            {
                VlcPlayerCore.PlayFile(MediaUrl);
            }
            trPlayerProgress.SetRange(0, (int)VlcPlayerCore.Duration());
            VlcPlayerCore.SetPlayTime(trPlayerProgress.Value);
            VlcPlayerCore.Play();
            trPlayerProgress.Value = (int)VlcPlayerCore.GetPlayTime();

            tmrProgress.Start();

            is_playinig   = true;
            media_is_open = true;

            lblVideoName.Text = Path.GetFileNameWithoutExtension(MediaUrl);
            lblVideoName.Show();
            lblVideoName.BringToFront();

            if (StartEvent != null)
            {
                StartEvent(this, new EventArgs());
            }
        }
Пример #2
0
        /// <summary>
        /// 设置媒体文件
        /// </summary>
        /// <param name="url"></param>
        public void SetMediaUrl(string urls)
        {
            MediaUrl = urls;

            VlcPlayerCore.PlayFile(MediaUrl);
            trPlayerProgress.SetRange(0, (int)VlcPlayerCore.Duration());
            trPlayerProgress.Value = 0;
            tmrProgress.Start();

            is_playinig   = true;
            media_is_open = true;

            lblVideoName.Text = Path.GetFileNameWithoutExtension(MediaUrl);
            lblVideoName.Show();

            //设置按钮状态
            btnPlay.Enabled  = true;
            btnPause.Enabled = false;
            btnStop.Enabled  = false;
            btnLast.Enabled  = false;
            btnNext.Enabled  = false;

            btnPlay.PerformClick();
        }