AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

playing a video

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

playing a video

Postby kathsunil » Sun Feb 22, 2009 4:47 am

I'm writing a program that tracks a moving objects in a mpeg file. I'm new to c# and programming. I cannot get to play the video. For right now I want to play the video in a picture box and cature new and old video frame to compare the movements. Here is my code so far that does not work.

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
How do I get to play the video in the picture box?? }

private void button1_Click(object sender, EventArgs e)
{
videoSource = new FileVideoSource(videoFile);
//videoSource.
//videoSource.NewFrame += new AForge.Video.NewFrameEventHandler(video_NewFrame);
videoSource.Start();


}

private void video_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
{
Bitmap bitmap = eventArgs.Frame;
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{

openFileDialog.Filter = "Video (.mpeg)|*.mpeg|(.avi)|*.avi|ALL Files (*.*)|*.*";

if (openFileDialog.ShowDialog() == DialogResult.OK)
{
videoFile = openFileDialog.FileName;

}

}
Help anyone please:
kathsunil
 
Posts: 4
Joined: Wed Feb 18, 2009 6:56 pm

Re: playing a video

Postby andrew.kirillov » Sun Feb 22, 2009 7:14 am

Hello,

If you use 1.7.0 version of AForge.NET Framework, then you may take a look at Motion Detection sample, which plays videos.

If you are familiar working with SVN, then you mat try getting 2.0 branch and build it on your own. There you will find "Player" sample - just plays videos or USB web cameras. Also in 2.0 there is VideoSourcePlayer control, which will do all the work for you.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to AForge.NET Framework

cron