In C # programming, because a function needs to play a short clip in AVI format, the results are not fixed after a long time. So I checked it online! After searching for a long time, I finally found a method to play the file.
The following command is used to generate MediaPlayer. dll and AxMediaPlayer. dll for the Media Player control msdxm. ocx. Command: aximp c: \ winnt \ system32 \ msdxm. ocx, while ActiveX controls in msdxm. ocx are not registered! Run regsvr32 msdxm. ocx to manually register and generate the required dynamic connection library file.
However, I found that the MediaPlayer control he used can play many media files, but it cannot meet my needs. I use C # To play a short AVI file, and the background should be transparent, rather than black, or other colors, I have been searching for a long time and cannot find any way to make the MediaPlayer file transparent. It is very depressing!
But then I found that other programs using VB could implement this function, which made me very happy. So I opened the VB code for a thorough view, it is found that there is a control in VB that can play the AVI file for Animation, and there is an attribute option to make the background transparent. Meets my needs. however, this is also an OCX control, so I first find the control, the location is: C: \ WINDOWS \ SYSTEM32 \ COMCT32.ocx, then I run regsvr32 for manual registration, after registration, I will reference it in the environment, for example:
(However, I later found that this was not registered with regsvr32, because. NET has already been registered, and it is depressing ~~~~~~~~~~~~~~)
Drag the control into the form, deploy it, set its property AutoPlay to true, and write the following sentence in the Code:
Private void Form1_Load (object sender, System. EventArgs e)
{
This. axAnimation1.Open (Application. StartupPath + @ "\ FILECOPY. AVI ");
}
In this way, when the form is loaded, the AVI file is automatically played.
In fact, this problem is not very difficult, mainly because I am not particularly familiar with COM components. as long as you are familiar with the functions and running principles of these components, the programming efficiency will be greatly improved.