羽铉

导航

 

这些天对directx有兴趣了,开始慢慢学,先学基础,找了好些资料,为毛都写的辣么长呢,学习精简下来就几行。

安装个directx sdk,在win10里面文件夹C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0

把Microsoft.DirectX.AudioVideoPlayback.dll、Microsoft.DirectX.dll、Microsoft.DirectX.DirectDraw.dll等dll文件复制到exe生成文件夹里bin\debug

添加引用,就是在“引用”点右键,“浏览”,找到那几个dll就行了。

cs里面加上

using Microsoft.DirectX;
using Microsoft.DirectX.DirectSound;
using Microsoft.DirectX.AudioVideoPlayback;

再放2个按钮,一个播放音频,一个播放视频

 private Audio ourAudio = null;
 private Video ourVideo = null;
 private void button1_Click(object sender, EventArgs e)
 {
    ourAudio = new Audio("abc.mp3");
    ourAudio.Volume = 0; //设置音量,最大值为0;
    ourAudio.Play(); //播放        
  }

  private void button2_Click(object sender, EventArgs e)
  {
     ourVideo = new Video("5.avi");
     ourVideo.Owner = panel1;
     panel1.Width = 300;
     panel1.Height = 200;
     ourVideo.Play();
  }


完事。虽然支持的格式少点。

就这么简单,慢慢学。。。。

还有注意一点那个app.config文件

改一下:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
</configuration>

 红色的部分,不改不能运行

 

写了个基本图像例子 https://pan.baidu.com/s/1cCI5T8

其他基本操作放http://www.haolizi.net/example/view_10469.html

http://www.haolizi.net/example/view_10450.html

这里了

 

posted on 2017-02-04 12:56  羽铉  阅读(1063)  评论(0编辑  收藏  举报