[.net] Video playback trouble

Started by
3 comments, last by alex_myrpg 16 years, 10 months ago
Hello... I have some video troubles in a C# form. I am trying to play an .AVI file in a panel. Mysteriously, it used to work fine, but I decided to re-write some of the code. Now, the video playback no longer works, but I can still hear the audio. I am certain I did not change any code that would affect the video playback. What is going wrong? Here's the code: using Microsoft.DirectX.AudioVideoPlayback; try { int height = videoPanel.Height; int width = videoPanel.Width; video = new Video(Application.StartupPath + "\\test.avi"); video.Owner = videoPanel; videoPanel.Width = width; videoPanel.Height = height; video.Play(); } catch (Exception exc) { // } This is called on form load. I tried calling it from clicking on buttons and such, but I still received the same undesired effect (audio but no video).
Advertisement
Maybe the form hasn't displayed yet? Try doing a this.Show() this.Refresh() before your video code.
I would recommend to stay well clear of Microsoft.DirectX.AudioVideoPlayback. I used it with a DirectX application a couple years ago (and it hasn't changed since then) - and found it to be ridden with nasty bugs that you can't even hack your way around. I would recommend trying DirectShow.NET (http://sourceforge.net/project/showfiles.php?group_id=136334), which is essentially a rewrite of DirectX.AudioVideoPlayback plus *a lot* more (well they're both managed wrappers for DirectShow). You can download the samples package where you'll find an example of just what you need. Hope that helps...
Hi, and thank you for both of your replies.
I would like to keep this as simple as possible without downloading any external packages, and yes the form has loaded since I mentioned I tried loading the video from a button command. Is there any way I can work around downloading a different package?

I understand your point... actually you just only need to reference *one* DLL file for this DirectShow.NET library, and then copy over the sample code and configure it, but if you want to go even simpler perhaps MCI is a good bet.
This is a good short intro: http://dotnet.org.za/deon/articles/3057.aspx
For more detail on the commands, try here: http://www.geocities.com/smigman.geo/mci/avi.html
It's in VB but it's pretty straight-forward so I hope you'll be able to interpret it. If not, let me know and maybe I can give you some examples.
MCI really is a pretty efficient and simple method for playing video/music so long as the video is not mixed in with a DirectX application or anything. Well I hope that helps anyway...

This topic is closed to new replies.

Advertisement