Jump to content
  • Advertisement
Sign in to follow this  
ericmaslowski

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

This topic is 3650 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.Stop();
m_video_2.Dispose();
GC.Collect();
GC.WaitForPendingFinalizers();
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_video_1.Play();
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()
{
Application.EnableVisualstyles();
Application.SetCompatibleTextRenderingDefault(false);
VideoPanel vp = new VideoPanel();
Application.Run(vp);
}
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;
	video_PlayMovie(m_filenames[m_current_video]);
	return;
}
Any ideas? Any help would really be appreciated. Thanks Eric

Share this post


Link to post
Share on other sites
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!