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);
                }
            }
    
        }
    }
    

      

  • 相关阅读:
    用外部表的方式查询当天数据库alert日志文件
    比较数据泵和exp/imp对相同数据导出/导入的性能差异
    理解Oracle TM和TX锁
    Rocky4.2下安装金仓v7数据库(KingbaseES)
    理解listagg函数
    sql*loader的直接加载方式和传统加载方式的性能差异
    Rocky4.2下安装达梦(DM)6数据库
    演示对sys用户和普通用户进行审计的示例
    演示一个通过触发器进行审计的示例
    演示一个使用db vault进行安全控制的示例
  • 原文地址:https://www.cnblogs.com/rainstorm/p/2883184.html
Copyright © 2011-2022 走看看