1

プロジェクトでKinect.Toolboxを使用していますが、再生の終了後にメッセージを表示する必要があります。この瞬間を得る方法はありますか?

実際に私のコードは次のことをします

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

そしてreplay_ColorImageFrameReadyはここにあります

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 :)
}

ReplayオブジェクトにはIsFinishedというプロパティがありますが、Replay IsFinishedの場合、replay_ColorImageFrameReadyは発生しないため、メッセージは表示されないことに注意してください。

Kinect.ToolboxのコードはTPLを使用していますが、TPLについてはあまり詳しくありません。Kinect.Toolboxのコードを変更して、OnReplayEndなどのイベントを発生させたいと考えています。

4

1 に答える 1

0

次のような構造を構築できます。

KinectReplay.csで

追加

public event EventHandler Closing;

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

使用したい場所でトリガーします。

replay.Closing += new EventHandler(replayMediaEnded);
于 2013-04-27T21:53:14.030 に答える