NewVideoSample event

Mar 21, 2010 at 10:11 PM

I was wondering when the NewVideoSample event fires. 

I thought maybe it was raised when EnabbleSampleGrabbing was toggled to true.

I want to get the bitmap from VideoSampleArgs.

Thanks in advance,


Mar 22, 2010 at 12:51 AM

WOW!  We can actually get the source code!   Ultra wicked cool!

Sorry for my child-like enthusiasm...I'm new to this.  I have a form with video from my web cam!  I've played around with VB for a while and C# doesn't look at all as cryptic as C++ so having some source to gander the guts is very helpful to the learning process.

And Jer,  a hand-shake and a smack on the southern cheeks for the kit man....really generous of you to share.  Thanks man!

Mar 22, 2010 at 9:25 AM
Yeah the source is all there for you to use and abuse!  I can't think why you would not be getting the bitmaps, but some breakpoints in the code might give a clue.  I believe I only support 24bit RGB color spaces when enable sample grabbing is on, so it _might_ be an issue with that...but really it can be a zillion things ;).  If you find out more info I might be able to help you figure it out!

Mar 23, 2010 at 4:23 AM

Hey, thanks for the reply.   Here's what I found in my fumbling around.

1) When i downloaded the source and made a change...I have no clue how to get the "all-inclusive" .dll with the WPFMediaKitDirectShow.Interop namespace etc.  I realised this after a build.  Inserted a refernce in my app to the DirectShow 2005 dll ...Anyway...

2)The change i made in VideoCaptureElement.cs (in green below) gives me the event in my wpf vb app:

public override void EndInit()





//added by jam



Which is unchanged by me as:

protected override void InitializeMediaPlayer()



VideoCapturePlayer.NewVideoSample += PlayerNewVideoSample;


It took me a while to find what the "+=" means in this context :(     I take it as "When the VidieoCapturePlayer.NewVideoSample event fires, handle it with PlayerNewVideoSample"

I have an integer incrementing by 1 when the event fires and a msgbox to tell me what that number was in Window.Closing; and it was incremented!!   So I have an to get with grabbing the bitmap.

I'm having fun with this...Thanks again!

Mar 23, 2010 at 6:07 AM

Ok this is weird:

I re-referenced the downloaded dll just to event fire. (NewVideoSample)

I removed the reference to the downloaded dll and added my (new) build dll's with my change commented out (aka, no change) and i got the event. (NewVideoSample)

The only reason I made the change (addition) in the first place is because the InitializeMediaPlayer() method is protected (what i understand; can't call it in my app) and the only refernces to the method found using "find all references" (via right click in vs 2008) listed the base class and another derived class (MediaSeekingElement.cs) which i dont use.

Just me thinking outloud via keyboard.