How to play an AVI video in C # and make the background transparent

Source: Internet
Author: User
Tags manual

In C # programming, because a function needs to play a small section of the AVI format of the short film, the result of looking for a half-day also did not fix how to play. So I check on the Internet Ah! Looking for half a day finally found a way to play the file.

His way is to first use the following command for the media Player control: Msdxm.ocx generates MediaPlayer.dll and AxMediaPlayer.dll. The command is: AxImp c:\winnt\system32\msdxm.ocx and often ActiveX controls in Msdxm.ocx are not registered! Then run regsvr32 msdxm.ocx Manual registration to generate the required dynamic connection library files.

But I found that the MediaPlayer control he used was a lot of media files that could be played. But it doesn't satisfy the situation I need. My situation is to use C # to play a small section of AVI file, and the background to be transparent, not black, or other colors, I looked for a half-day can not find any way to make MediaPlayer playback of the file for the transparent state, very depressed!

But then I found that other use VB program can realize this function, let me very happy, so I opened the VB code for a detailed view, found in VB has a control for animation can play AVI file, and it has a property option is to make the background transparent. Just to meet my needs. But this is also an OCX control, so I first found the control, the location is: C:\WINDOWS\SYSTEM32\COMCT32.ocx, and then I run regsvr32 manual registration, after registration I will be in the environment to quote, The following figure:

(However, later I found that this is not regsvr32 registration, because.) NET early already registered, depressed in ~~~~~~~~~~~~~~)

Then drag the control into the form, make the layout, set its property autoplay to true, and then write the following sentence in your code:

private void Form1_Load(object sender, System.EventArgs e)
{
this.axAnimation1.Open(Application.StartupPath + @"\FILECOPY.AVI");
}

This will automatically play this small section of AVI file when the form is loaded.

In fact, this problem is not very difficult, mainly I am not particularly familiar with the COM component. As long as you are familiar with the functions of these components, as well as the principle of operation, it is bound to greatly improve the efficiency of our programming.

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.