1

I am using Kinect.Toolbox in my project, i need to show a message after the replay ends. Is there a way to get this moment?

actualy my code do the following

Stream recordStream = File.OpenRead(@"D:\recorded.FisioKinect");
this.Replay = new KinectReplay(recordStream);
this.Replay.ColorImageFrameReady += replay_ColorImageFrameReady;
this.Replay.Start();

and the replay_ColorImageFrameReady is here

void replay_ColorImageFrameReady(object sender, ReplayColorImageFrameReadyEventArgs e)
{
    if (this.Replay.IsFinished)
    {
        MessageBox.Show("End");
    }
    byte[] pixelData = new byte[e.ColorImageFrame.PixelDataLength];
    e.ColorImageFrame.CopyPixelDataTo(pixelData);
    // Other awesome stuff :)
}

Note that the Replay object have a property called IsFinished, but the replay_ColorImageFrameReady will not be raised if the Replay IsFinished, so, the message never will be shown.

The code of Kinect.Toolbox uses TPL and i dont know so much about TPL, i want to change the code of the Kinect.Toolbox to fire an event like OnReplayEnd

Ewerton
  • 4,046
  • 4
  • 30
  • 56
  • I don't know much about TPL either. How does it stop you from firing an event when Replay.Isfinished is set to true? – SimpleSimon Jan 11 '13 at 21:38
  • Yes @FrankSposaro, i dont touched the code i wrote since about one year, but the idea is the same as provided in the answer below. Edit the KinectReplay.cs (from Kinect Toolbox package) and create one EventHandler, read the code and find the moment where the replay ends, in that place, trigger the Event. So, in your class you will be able to handle that event – Ewerton Feb 09 '15 at 12:04

1 Answers1

0

You can build a structure like this:

In your KinectReplay.cs

add

public event EventHandler Closing;

protected virtual void OnClosing()
{
    EventHandler Closing = this.Closing;
    if (Closing != null)
        Closing(this, EventArgs.Empty);
}  

and trigger it wherever you want to use it.

replay.Closing += new EventHandler(replayMediaEnded);
bseh
  • 447
  • 7
  • 13