I've read all the comments on the site on this topic but still can't get this to work.

I am using Directx to play video in c#. This is working ok, but I can't work out how to trigger the Video.Ending event.

In the InitialiseComponent I have

this.MyVideo = new Microsoft.DirectX.AudioVideoPlayback.Video(filename);

and

// MyVideo
//
this.MyVideo.Ending += new System.EventHandler(this.MyVideo_Ending);

This is the error message I get.

Warning 1   Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located.  F:\Personal\New Folder\Event Recorder\Event Recorder\MediaForm.Designer.cs  134 0

Here is my method

private void MyVideo_Ending(object sender, System.EventArgs e)
{
btnPlay.Text = "Play";
}

Any suggestion welcome. I thought I understood event handlers but I'm obviously missing something.
Thank you

Its possible that doing it in the initialize component section may not be helping, but.. normally I wouldnt use this.MyVideo_Ending, it would just be MyVideo_Ending

do this:

video.Ending += new EventHandler(audio_Ending);
video.Audio.Ending += new EventHandler(audio_Ending); // This mybe seems to kill the bug !

do this:

video.Ending += new EventHandler(audio_Ending);
video.Audio.Ending += new EventHandler(audio_Ending); // This mybe seems to kill the bug !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.