Q:

How to play a video when a kinect track a skeleton

So, I want to make an event which will play a video when a kinect tracks a skeleton. I'm using visual studio 2013, Kinect for Windows, and kinect contrib template (VS2012). However, although that template is for 2012, it's still working in 2013.
Here's a link for Kinect Contrib Template : http://kinectcontrib.codeplex.com/releases/view/97477
And here's my code that I've tried :
This is my XAML :
<Window x:Class="KinectSkeletonApp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow"
    WindowState="Maximized" WindowStyle="None">
<Grid>
    <Image Name="videoImage"></Image>
    <Canvas Background="Transparent">
        <MediaElement x:Name="VideoControl" Height="527" Width="760" Visibility="Collapsed"
                      LoadedBehavior="Manual" UnloadedBehavior="Stop" />
    </Canvas>
</Grid>

This is my xaml.cs :
void runtime_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
    {
        bool receivedData = false;

        using (SkeletonFrame SFrame = e.OpenSkeletonFrame())
        {
            if (SFrame == null)
            {
                // The image processing took too long. More than 2 frames behind.
            }
            else
            {
                skeletonData = new Skeleton[SFrame.SkeletonArrayLength];
                SFrame.CopySkeletonDataTo(skeletonData);
                receivedData = true;
            }
        }

        if (receivedData)
        {
            Skeleton currentSkeleton = (from s in skeletonData
                                        where s.TrackingState == SkeletonTrackingState.Tracked
                                        select s).FirstOrDefault();

            if (currentSkeleton != null) //When Kinect detect a skeleton
            {
                //Test Event Video
                VideoControl.Visibility = Visibility.Visible;
                VideoControl.Source = new Uri("Videos/1.wmv");
                VideoControl.Play();
            }
            else //When there is no skeleton detected
            {
                //Test Event Video
                VideoControl.Visibility = Visibility.Collapsed;
                VideoControl.Stop();
            }
        }
    }

But what happened next is the video won't play. So, how to play the video when Kinect detects skeleton? Thanks.

A:

The runtime_SkeletonFrameReady will be triggered every 1/30 of a second. So every 1/30 of a second you are resetting the source and pressing play. So the video just restarts every 1/30 of a second and that's why you are probably not seeing the video play.
You need to check if the video control is already playing and adjust your play/stop code.

