How to play avivideo in C # And make the background transparent

Source: Internet
Author: User
  • How to play avivideo in C # And make the background transparent
  • 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.

  • 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.