Advertisement Jump to content
Sign in to follow this  

[.net] Looping/Switching Video Crashes - Managed DirectX

This topic is 3712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, I'm really at a loss here. I can not seem to get my video app to loop a video. I'm using AudioVideoPlayback and followed the many tutorials out there in getting the basics setup. I can easily switch videos when it's tied to a keypress, but if I want a video to automatically start over or jump to a new one when finished playing ("Ending" event) then Application.Run() throws a null exception. I have tried: - double buffering the loading/unloading of my video files to give the old one enough time to dispose. - forced garbage collection with waiting until it's done - catching dispose even and waiting until it's done (infinite loop) Goal: - I just want to have a few movies (predefined) that I can cycle through with key presses and if a key isn't pressed they are played in sequence. This is my video create/destroy code:
// kill the current, which should be 2
if (m_video_2 != null)
m_video_2 = null;

// create new video in 1
m_video_1 = new Video(filename);
m_video_1.Owner = this;
m_video_1.Size = this.Size;
m_video_1.Ending += new EventHandler(video_Ending);
m_use_first = false;
The app crashes at Run() below but only when trying to play/switch in "Ending" event for the video:
static void Main()
VideoPanel vp = new VideoPanel();
For completeness, here's my "Ending" event handler:
private void video_Ending(object sender, EventArgs e)
	// go to next video in sequence
	if (m_current_video == (m_num_videos - 1))
	{ m_current_video = 0; video_PlayMovie(m_filenames[0]); return; }

	m_current_video += 1;
Any ideas? Any help would really be appreciated. Thanks Eric

Share this post

Link to post
Share on other sites
Perhaps the callback is on another thread? You could try a BeginInvoke() so it runs on the form's thread?

Personally I would recommend you use DirectShowNet instead as AudioVideoPlayback is a very limited (and buggy) and is essentially a wrapper for DirectShow anyway.

Share this post

Link to post
Share on other sites
Thanks for the reply. Unfortunately setting up delegates and using Invoke/BeginInvoke didn't seem to help. I'll take a look now into DirectShowNET. Thanks for the tip.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!