I'm writing a little application using C# and i want to play a standard XVID/AVI video on a Windows form. Is there an easy way to do this? The only examples i've se开发者_运维问答en are for Managed DirectX which is no longer supported.
It would be nice to do this with no dependencies as i would like to ship the exe as stand-alone. Any ideas where to start?
Yes, drop a WindowsMediaPlayer on the form and pass it the file. Make sure the DirectShowFilter is installed on the machine.
Also, you can use the VLC api to play any format you should so desire if you ever you can't find the filter.
Update:
You can't help but have dependencies here. However, that doesn't mean that you will have to deploy multiple executables. In your solution, any of the .dlls in your project will be packaged into your installer so that all you deploy is a single .msi file. To do so, you need to add a Setup Project to your solution. The windows media player is a COM object as is direct show so even there you will be using the com wrapper dll files. VLC uses a win32 .dll so you have to use platform invoke and place the assembly in your bin folder. Regardless, all of the necessary files will be packaged into your installer, so deployment will not be a problem.
Probably the easiest method will be to embed Windows Media Player into the form to play the video.
Keep in mind that the client would need either Windows Vista or Windows 7 to have support for XVID unless a proper decoder is installed first.
精彩评论