C#使用directx播放视频

来源:互联网 发布:下载360root软件 编辑:程序博客网 时间:2024/04/20 03:01


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;using Microsoft.DirectX;using Microsoft.DirectX.DirectPlay;using Microsoft.DirectX.DirectDraw;using Microsoft.DirectX.AudioVideoPlayback;using Microsoft.DirectX.Direct3D;namespace test_demo{    public partial class Form1 : Form    {        public Video MyVideo;                public Form1()        {            InitializeComponent();        }               private void button1_Click(object sender, EventArgs e)        {          //  CoInitialize();            int height = panel1.Height;            int width = panel1.Width;            // 如果存在打开的Video文件,释放它            if (MyVideo != null)            {                MyVideo.Dispose();            }            MyVideo = new Video("d:\\temp\\bmw.mpg");            MyVideo.Owner = panel1;            panel1.Width = width;            panel1.Height = height;            MyVideo.Play();                       // MyVideo.Pause();           // MessageBox.Show("ok");        }    }}



原创粉丝点击