微軟多媒體 API 函式庫,提供標準介面與顯示卡、音效卡、輸入裝置互動。抽象硬體差異,開發者呼叫統一 API 即可操作各種裝置組合,避免回到 DOS 時代為每張卡寫驅動。
.NET Framework SDK 不含 DirectX SDK,需另行下載:
https://download.microsoft.com/download/a/c/d/acdfb557-266f-4af4-8673-6ab8009b4ddd/dxsdk_apr2005.exe
安裝後於 C:\Windows\Microsoft.NET\Managed DirectX 產生 9 對 DLL/XML,對應 10 個命名空間。
| 命名空間 | 描述 |
|---|---|
| Microsoft.DirectX | 公用類別與數學結構 |
| Microsoft.DirectX.Direct3D | 3D 圖形與輔助庫 |
| Microsoft.DirectX.DirectDraw | Direct Draw (舊版,不建議使用) |
| Microsoft.DirectX.DirectPlay | 多人遊戲網路 API |
| Microsoft.DirectX.DirectSound | 音效支援 |
| Microsoft.DirectX.DirectInput | 輸入裝置 (滑鼠、搖桿) |
| Microsoft.DirectX.AudioVideoPlayback | 視訊/音頻播放 (本文重點) |
| Microsoft.DirectX.Diagnostics | 疑難排解 |
| Microsoft.DirectX.Security | 存取安全性 |
| Microsoft.DirectX.Security.Permissions | 存取安全權限 |
Audio、Video、TextureRenderEventArgs。| 屬性 | 描述 |
|---|---|
| Audio | 取得視訊中的音訊物件 |
| Caption | 播放視窗標題 |
| CurrentPosition | 目前播放位置 |
| DefaultSize | 預設視訊尺寸 |
| Fullscreen | 全螢幕播放 |
| IsCursorHidden | 滑鼠游標隱藏狀態 |
| Owner | 播放宿主組件 (關鍵) |
| Paused/Playing/Stopped | 播放狀態旗標 |
| SeekingCaps | 搜尋能力 |
| Size | 播放尺寸 |
| State | 完整播放狀態 |
| StopPosition | 停止位置 |
| 方法 | 描述 |
|---|---|
| HideCursor/ShowCursor | 隱藏/顯示滑鼠 |
| Open | 載入檔案到 Video 物件 |
| Pause/Play/Stop | 暫停/播放/停止 |
| SeekCurrentPosition/SeekStopPosition | 跳轉播放/停止位置 |
| Video | 建構新 Video 實例 |
掌握上述基礎,即可進入實作階段 (第 2 篇起)。