c# 如何制作RealPlayer 视频播放器

 

c# 如何制作RealPlayer 视频播放器

主要介绍了如何使用 RealPlayer G2 Control 控件

那么我们怎么获得到这个控件呢,很简单,操作方法如下

右单击工具箱对话框的【所有Windows窗体】标签页,在弹出浮动菜单中选择“选择项”则弹出【选择工具箱项】对话框在该对话框中切换到【Com 组件】标签页,

在列表试图中选择 RealPlayer G2 Control 选项 然后确定

则会自动在工具箱对话框【所有Windows窗体】标签页上新增加一个axRealAudiol控件像页面中拖动就可以了,

但是要注意:在默认状态下RealPlayer G2 Control控件不显示视频界面。 需要设置:

CtlControls 属性为”IMAGEWINDOW,CONTROLPANEL,STATUSBAR“后才能显示视频界面。

我简单做了一个样式大家可以看一下,实现了一些简单的操作,

代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

private void Form1_Load(object sender, EventArgs e)
        {
 
        }

private void button10_Click(object sender, EventArgs e)
        {
            //浏览
            OpenFileDialog mydol = new OpenFileDialog();
            if (mydol.ShowDialog() == DialogResult.OK)
            {
                this.axRealAudio1.Source=mydol.FileName;
            }
        }

private void button11_Click(object sender, EventArgs e)
        {
            //播放
            if (this.axRealAudio1.CanPlay())
            {
                this.axRealAudio1.DoPlay();
            }
        }

private void button12_Click(object sender, EventArgs e)
        {
            //停止
            if (this.axRealAudio1.CanStop())
            {
                this.axRealAudio1.DoStop();
            }
        }

private void button13_Click(object sender, EventArgs e)
        {
            //暂停
            if (this.axRealAudio1.CanPlayPause())
            {
                this.axRealAudio1.DoPlayPause();
            }
        }

private void button14_Click(object sender, EventArgs e)
        {
          //无声
            if (this.button14.Text == "无声")
            {
                this.axRealAudio1.SetMute(true);
                this.button14.Text = "有声";
            }
            else
            {
                this.axRealAudio1.SetMute(false);
                this.button14.Text="无声";
            }
        }

}
}

上一篇:JS遍历对象或者数组


下一篇:C#基础(四)