热点推荐:ASP.Net | ADO.Net | VB.Net | Web服务器 | Access | MSSQL | MySQL | Oracle | .Net控件 | Win 9x | Win 2000 | Win 2003 | DOS | Unix | 注册表 | 应用其它 | 安装调试 | 基本操作 | 使用技巧 | 系统优化 |故障处理 | 个性风格 | 病毒安全 | 专杀工具
您现在的位置: 中华IT技术网 >> 开发语言 >> WINDOWS编程 >> 正文
全文
小记一下DirectX里的Video和Audio
作者:1024k    文章来源:本站原创    点击数:    更新时间:2007-9-22

原本是DX里的一个例子,我觉得还可以,就COPY出来,想改改看。结果让我大失所望。
最简单要求,就是对音频文件和视频文件可以定位查找,本来它的Video和Audio类都提供了Seek方法,但它们根本不能工作,每次Seek后,都回到0的位置上。后来用Reflector来看它的源代码,结果也是不尽人意,很多底层的代码没有办法反射出来。特别是DX里的一些接口,根本无法查看。最后也只好先暂停了。
本来还想着,要是DX在.Net下封装的比较好的话,我就可以少用C++的COM组件了,直接用C#来写组件也方便多了。没想到MS的托管DX确实还不够完善,我看可能要等以后的版本了。不过它的MediaPlay的SDK还是不错的,有机会也看看。

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.AudioVideoPlayback;

namespace Webb.DirectX.Debug2
{
    /**//// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class AVPlayer : System.Windows.Forms.Form
    {

        private string filterText = "Video Files (*.avi; *.qt; *.mov; *.mpg; *.mpeg; *.m1v; *.wmv)|*.avi; *.qt; *.mov; *.mpg; *.mpeg; *.m1v; *.wmv|" +
            "Audio files (*.wav; *.mpa; *.mp2; *.mp3; *.au; *.aif; *.aiff; *.snd; *.wma)|*.wav; *.mpa; *.mp2; *.mp3; *.au; *.aif; *.aiff; *.snd; *.wma|" +
            "MIDI Files (*.mid, *.midi, *.rmi)|*.mid; *.midi; *.rmi|" +
            "Image Files (*.jpg, *.bmp, *.gif, *.tga)|*.jpg; *.bmp; *.gif; *.tga|" +
            "All Files (*.*)|*.*";

        private Video ourVideo = null;
        private Audio ourAudio = null;

        Winforms variables#region Winforms variables

        /**//// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;
        private System.Windows.Forms.MainMenu mnuMain;
        private System.Windows.Forms.OpenFileDialog ofdOpen;
        private System.Windows.Forms.MenuItem menuItem3;
        private System.Windows.Forms.MenuItem mnuFile;
        private System.Windows.Forms.MenuItem mnuOpen;
        private System.Windows.Forms.MenuItem menuItem1;
        private System.Windows.Forms.MenuItem mnuPlay;
        private System.Windows.Forms.MenuItem mnuStop;
        private System.Windows.Forms.MenuItem mnuPause;
        private System.Windows.Forms.MenuItem menuItem2;
        private System.Windows.Forms.MenuItem mnuFull;
        private System.Windows.Forms.ToolBar toolBar1;
        private System.Windows.Forms.ToolBarButton toolBarButton1;
        private System.Windows.Forms.ToolBarButton toolBarButton2;
        private System.Windows.Forms.ToolBarButton toolBarButton3;
        private System.Windows.Forms.ToolBarButton toolBarButton4;
        private System.Windows.Forms.ToolBarButton toolBarButton5;
        private System.Windows.Forms.MenuItem mnuExit;
        #endregion

        public AVPlayer()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            OpenFile();
        }

        private bool _IsVideo = false;

        /**//// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            CleanupObjects();
            if( disposing )
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        Windows Form Designer generated code#region Windows Form Designer generated code
        /**//// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.mnuMain = new System.Windows.Forms.MainMenu();
            this.mnuFile = new System.Windows.Forms.MenuItem();
            this.mnuOpen = new System.Windows.Forms.MenuItem();
            this.menuItem3 = new System.Windows.Forms.MenuItem();
            this.mnuExit = new System.Windows.Forms.MenuItem();
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            this.mnuPlay = new System.Windows.Forms.MenuItem();
            this.mnuStop = new System.Windows.Forms.MenuItem();
            this.mnuPause = new System.Windows.Forms.MenuItem();
            this.menuItem2 = new System.Windows.Forms.MenuItem();
            this.mnuFull = new System.Windows.Forms.MenuItem();
            this.ofdOpen = new System.Windows.Forms.OpenFileDialog();
            this.toolBar1 = new System.Windows.Forms.ToolBar();
            this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
            this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
            this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
            this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
            this.toolBarButton5 = new System.Windows.Forms.ToolBarButton();
            this.SuspendLayout();
            //
            // mnuMain
            //
            this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                                    this.mnuFile,
                                &nb

[1] [2] [3] [4] [5] [6] 下一页

  • 上一篇文章:
  • 下一篇文章: 没有了
  • 相关文章
    最新更新
    编辑推荐
    热门图片
    频道大全
    文章阅读排行
    周排行
    月排行