Using DirectX to achieve video playback in C #

Source: Internet
Author: User

Many people first contact with DirectX is through the game, as for installation, upgrade DirectX is nothing more than to meet the needs of game operation. Direct x is actually a library of Windows platform Multimedia API functions, which provides a standard interface to interact with graphics cards, sound cards, input devices, and so on. Without this set of standard API libraries, you would need to write different code for each video card, for each combination of sound cards, and for each type of keyboard, mouse, and joystick. This is not back to the previous DOS era. To solve this problem, Microsoft has launched DirectX. DirectX abstracts from specific hardware and converts a set of generic instructions to specific commands for hardware. In this way, the development language can manipulate each video card, each combination of sound card and each type of keyboard, mouse and joystick, by invoking the unified standard Direct x function library.

I. Direct X SDK 9.0 Installation and Class Library introduction:

The. Net FrameWork SDK does not contain the direct X SDK, so for the sake of completing the following article,

You must first download and install the direct X SDK. The specific download address is: Http://download.microsoft.com/download/a/c/d/acdfb557-266f-4af4-8673-6ab8009b4ddd/dxsdk_apr2005.exe. This version is the English version of the 20,054 month launch. This does not prevent the following programs from being implemented. After you install Direct X, there is a directory with "C:\WINDOWS\Microsoft.NET\Managed DirectX" in which there should be nine DLL files and nine XML files in the directory. Nine DLL files roughly correspond to the 10 namespaces in DirectX. In programming, you use the namespaces to provide support for input devices, sounds, network playback, graphics, and so on. The namespace defined in Direct X SDK 9.0 and its primary role are detailed as shown in table 01:

/tr>
namespace description
microsoft.directx common class and mathematical structure
3d Graphics and helper libraries
direct Draw Graphics API. This is a legacy namespace and you don't need to use it now.
network APIs for multiplayer games
Voice support
input device support (for example, mouse and joystick)
play video and audio (for example, play the respective video animation files on the computer)
microsoft.directx.diagnostics
microsoft.directx.security Access security
Access security permissions

Table 01:direct the defined namespaces in X SDK9.0 and their primary role

Direct x is very informative, and this is just one of the small applications that uses Visual C # to invoke the SDK in direct X to play a video file as an example, using only namespaces in the program Microsoft.DirectX.AudioVideoPlayback ". Three classes are defined in the Microsoft.DirectX.AudioVideoPlayback namespace: "Audio", "video" and "Texturerendereventargs". The first two classes are the most common and are used to support audio and video, respectively. The common properties defined in the Microsoft.DirectX.AudioVideoPlayback namespace and their specific effects are shown in table 02:

/tr>
description
audio
caption
Get or set the current location of the playback video
Get the default video size to play video
Gets or sets whether the video file plays in Full-screen mode
State of the mouse when getting video playback: Hide or display
Get or set the host component for video playback
Gets whether the current playback state is paused
Gets whether the current playback state is playing.
seekingcaps
size retrieves and sets The size of the video for playback.
state
stopped
stopposition > Get the stop of the playback video Play location

Table 02:microsoft.directx.audiovideoplayback Common attributes defined in namespaces and their specific functions

The common methods defined in Microsoft.DirectX.AudioVideoPlayback namespaces and their specific effects are shown in table 03:

/tr> for the current video playback.
method description
hidecursor that is currently playing video."
open
pause
play
seekcurrentposition search goes to the established multicast Drop position
Displays the mouse
stop
video

Table 03:microsoft.directx.audiovideoplayback Common attributes defined in namespaces and their specific functions

With these basics in the background, let's begin by introducing the specific implementation of Visual C # calling Direct X to play video files.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.