zoukankan      html  css  js  c++  java
  • 用QuartzTypeLib.dll播放视频

    播放选定的文件
    
     
    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace MediaApp
    {
        public partial class Form1 : Form
        {
            private const int WS_CHILD = 0x40000000;
            private const int WS_CLIPCHILDREN = 0x2000000;
            private QuartzTypeLib.IMediaControl MyControl = null;
            private QuartzTypeLib.IVideoWindow MyWindow = null;
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                OpenFileDialog MyDialog = new OpenFileDialog();
                MyDialog.Filter = "Media Files|*.mpg;*.avi;*.wma;*.mov;*.wav;*.mp2;*.mp3|All Files|*.*";
                if (MyDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        QuartzTypeLib.FilgraphManager MyManager = new QuartzTypeLib.FilgraphManager();
                        if (MyControl != null) MyControl.Stop();//如果已经播放过,则先停止
                        MyManager.RenderFile(MyDialog.FileName);//加载音频、视频文件
                        MyWindow = (QuartzTypeLib.IVideoWindow)MyManager;
                        try//音频文件不需要用pictureBox1,所以会报错
                        {
                            MyWindow.Owner = (int)pictureBox1.Handle;
                            MyWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
                            MyWindow.SetWindowPosition(pictureBox1.ClientRectangle.Left,pictureBox1.ClientRectangle.Top,pictureBox1.ClientRectangle.Width,pictureBox1.ClientRectangle.Height);
                        }
                        catch { }
                        MyControl = (QuartzTypeLib.IMediaControl)MyManager;
                        MyControl.Run();
                    }
                    catch(Exception Mye)
                    {
                        MessageBox.Show(this,Mye.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    }
                }
            }
        }
    }
    
     
    
    播放指定的文件
    
     
    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            private const int WS_CHILD = 0x40000000;
            private const int WS_CLIPCHILDREN = 0x2000000;
            private QuartzTypeLib.IMediaControl MyControl = null;
            private QuartzTypeLib.IVideoWindow MyWindow = null;
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                try
                {
    
                    QuartzTypeLib.FilgraphManager MyManager = new QuartzTypeLib.FilgraphManager();
    
                    if (MyControl != null) MyControl.Stop();//如果已经播放过,则先停止
                    MyManager.RenderFile("Ending.mpg");//加载音频、视频文件
                    MyWindow = (QuartzTypeLib.IVideoWindow)MyManager;
                    try//音频文件不需要用pictureBox1,所以会报错
                    {
                        MyWindow.Owner = (int)pictureBox1.Handle;
                        MyWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
                        MyWindow.SetWindowPosition(pictureBox1.ClientRectangle.Left, pictureBox1.ClientRectangle.Top, pictureBox1.ClientRectangle.Width, pictureBox1.ClientRectangle.Height);
                    }
                    catch { }
                    MyControl = (QuartzTypeLib.IMediaControl)MyManager;
                    MyControl.Run();
    
                }
                catch (Exception Mye)
                {
                    MessageBox.Show(this, Mye.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
    
        }
    }
    

      

  • 相关阅读:
    .net(关于字符串的相等问题[比较重要])
    .net(基本数据类型,枚举类型,枚举字符串的相互转化)
    如何安全的读入一个整数或者浮点数
    .net(数组)
    什么是EAI?
    PowerShell 入门
    sql server 2005 如何删除前几条记录或重复记录
    如何查看客户端的IP地址,机器名,MAC地址,登陆名等信息
    sql server 2005 几个常用的存储过程或函数
    ASP.NET 母版页的加载顺序
  • 原文地址:https://www.cnblogs.com/rainstorm/p/2883184.html
Copyright © 2011-2022 走看看