Exemple #1
0
 public void Play()
 {
     if (_playback != null)
     {
         if (_playback.State == KStudioPlaybackState.Paused)
         {
             _playback.Resume();
         }
         return;
     }
     if (_kinect != null)
     {
         startKinect();
         return;
     }
 }
        /// <summary>
        /// Playback a clip
        /// </summary>
        /// <param name="filename">Path/name of the clip to be played.</param>
        private void PlaybackClip(string filename)
        {
            using (KStudioClient client = KStudio.CreateClient())
            {
                client.ConnectToService();

                KStudioEventStreamSelectorCollection streamCollection = new KStudioEventStreamSelectorCollection();

                using (KStudioPlayback playback = client.CreatePlayback(filename))
                {
                    // If the clip should not be evaluated from the begining.
                    // It should start paused.
                    if (_initialTime.Milliseconds > 0)
                    {
                        playback.StartPaused();
                        playback.SeekByRelativeTime(_initialTime);
                        playback.Resume();
                    }
                    else
                    {
                        playback.Start();
                    }

                    while (playback.State == KStudioPlaybackState.Playing && !finished)
                    {
                        Thread.Sleep(150);
                    }

                    // Finished the read of frames for calibration.
                    if (finished)
                    {
                        playback.Stop();
                    }
                }

                client.DisconnectFromService();
            }
        }
Exemple #3
0
        /// <summary>
        /// Run
        /// </summary>
        private void Run()
        {
            client.ConnectToService();

            using (KStudioPlayback play = client.CreatePlayback(path))
            {
                play.EndBehavior = KStudioPlaybackEndBehavior.Stop;
                play.Mode        = KStudioPlaybackMode.TimingEnabled;
                play.LoopCount   = loop;
                play.Start();

                while (play.State.Equals(KStudioPlaybackState.Playing) || play.State.Equals(KStudioPlaybackState.Paused))
                {
                    Thread.Sleep(33);

                    if (isPause && !play.State.Equals(KStudioPlaybackState.Paused))
                    {
                        play.Pause();
                    }

                    if (!isPause && play.State.Equals(KStudioPlaybackState.Paused))
                    {
                        play.Resume();
                    }

                    if (play.State.Equals(KStudioPlaybackState.Error))
                    {
                        throw new InvalidOperationException("KStudioPlayback Error");
                    }
                }

                play.Stop();
            }

            client.DisconnectFromService();
        }
Exemple #4
0
        public void Evaluate(int SpreadMax)
        {
            if (FInputPlay.IsChanged)
            {
                if (FInputPlay[0])
                {
                    string xefFilePath = @FInputFilename[0];

                    if (!string.IsNullOrEmpty(xefFilePath))
                    {
                        doPlay = true;
                        OneArgDelegate recording = new OneArgDelegate(this.PlayClip);
                        recording.BeginInvoke(xefFilePath, null, null);
                    }
                }
                else
                {
                    if (playback != null)
                    {
                        playback.Stop();
                    }
                }
            }
            if (FInputPause.IsChanged && (playback != null))
            {
                if (FInputPause[0])
                {
                    if ((playback.State == KStudioPlaybackState.Playing))
                    {
                        playback.Pause();
                    }
                }
                else
                {
                    if ((playback.State == KStudioPlaybackState.Paused))
                    {
                        playback.Resume();
                    }
                }
            }

            if (FInputStep[0])
            {
                if ((playback.State == KStudioPlaybackState.Playing))
                {
                    playback.Pause();
                }
                playback.StepOnce();
            }
            if (FInputSeek.IsChanged && (playback != null))
            {
                TimeSpan seekTime = TimeSpan.FromSeconds(FInputSeek[0]);
                playback.Pause();
                playback.SeekByRelativeTime(seekTime);
                playback.Resume();
            }
            if (playback != null)
            {
                FRecordDuration[0] = playback.CurrentRelativeTime.TotalSeconds;
                FRecord[0]         = playback.State.ToString();
            }
        }