void Update()
    {
        if (!saverPlayer)
        {
            return;
        }

        bool bPlayerActive = saverPlayer.IsPlaying();

        if (bPlayerActive)
        {
            if (KinectInterop.PollBodyFrame(sensorData, ref bodyFrame, ref kinectToWorld, false))
            {
                for (int i = 0; i < sensorData.bodyCount; i++)
                {
                    if (bodyFrame.bodyData [i].bIsTracked != 0)
                    {
                        lastUserTime = Time.realtimeSinceStartup;
                        break;
                    }
                }

                lock (sensorData.bodyFrameLock)
                {
                    sensorData.bodyFrameReady = false;
                }
            }
        }
        else
        {
            if (KinectManager.Instance.GetUsersCount() > 0)
            {
                lastUserTime = Time.realtimeSinceStartup;
            }
        }

        bool bUserFound = (Time.realtimeSinceStartup - lastUserTime) < userLostMaxTime;

        if (!bPlayerActive && !bUserFound)
        {
            saverPlayer.StartPlaying();
        }
        else if (bPlayerActive && bUserFound)
        {
            saverPlayer.StopRecordingOrPlaying();
            KinectManager.Instance.ClearKinectUsers();
        }
    }
    void Update()
    {
        // alternatively, use the keyboard
        //if(Input.GetButtonDown("Jump"))  // start or stop recording
        if (_Record)   // start or stop recording
        {
            _Record = false;

            if (saverPlayer)
            {
                if (!saverPlayer.IsRecording())
                {
                    saverPlayer.StartRecording();
                }
                else
                {
                    saverPlayer.StopRecordingOrPlaying();
                }
            }
        }

        //if (Input.GetButtonDown("Fire1"))  // start or stop playing
        if (_Play)   // start or stop playing
        {
            _Play = false;
            if (saverPlayer)
            {
                if (!saverPlayer.IsPlaying())
                {
                    saverPlayer.StartPlaying();
                }
                else
                {
                    saverPlayer.StopRecordingOrPlaying();
                }
            }
        }
    }
    void Update()
    {
        if (speechManager == null)
        {
            speechManager = SpeechManager.Instance;
        }

        if (speechManager != null && speechManager.IsSapiInitialized())
        {
            if (speechManager.IsPhraseRecognized())
            {
                string sPhraseTag = speechManager.GetPhraseTagRecognized();

                switch (sPhraseTag)
                {
                case "RECORD":
                    if (saverPlayer)
                    {
                        saverPlayer.StartRecording();
                    }
                    break;

                case "PLAY":
                    if (saverPlayer)
                    {
                        saverPlayer.StartPlaying();
                    }
                    break;

                case "STOP":
                    if (saverPlayer)
                    {
                        saverPlayer.StopRecordingOrPlaying();
                    }
                    break;
                }

                speechManager.ClearPhraseRecognized();
            }
        }

        // alternatively, use the keyboard
        if (Input.GetButtonDown("Jump"))         // start or stop recording
        {
            if (saverPlayer)
            {
                if (!saverPlayer.IsRecording())
                {
                    saverPlayer.StartRecording();
                }
                else
                {
                    saverPlayer.StopRecordingOrPlaying();
                }
            }
        }

        if (Input.GetButtonDown("Fire1"))         // start or stop playing
        {
            if (saverPlayer)
            {
                if (!saverPlayer.IsPlaying())
                {
                    saverPlayer.StartPlaying();
                }
                else
                {
                    saverPlayer.StopRecordingOrPlaying();
                }
            }
        }
    }