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

      

  • 相关阅读:
    用户及文件权限管理
    Linux基础操作及概念
    监督学习和非监督学习
    基于仿生算法的智能系统I
    9.Dijkstra求最短路 II 堆优化的Dijkstra
    8.Dijkstra求最短路 I 朴素Dijkstra
    7.有向图的拓扑序列 拓扑排序
    6.树与图的广度优先遍历 图中点的层次
    5.树的重心 树与图的深度优先遍历
    4.八数码 BFS
  • 原文地址:https://www.cnblogs.com/rainstorm/p/2883184.html
Copyright © 2011-2022 走看看