private void PlayClip(string filePath, bool startpaused)
        {
            using (KStudioClient client = KStudio.CreateClient())
            {
                client.ConnectToService();

                KStudioPlaybackFlags flags = KStudioPlaybackFlags.IgnoreOptionalStreams;
                try
                {
                    playback = client.CreatePlayback(filePath, flags);
                }
                catch (Exception ex)
                {
                    FLogger.Log(LogType.Debug, ex.ToString());
                }
                using (playback)
                {
                    playback.PropertyChanged += Playback_PropertyChanged;
                    playback.StateChanged    += Playback_StateChanged;

                    playback.LoopCount              = 0;
                    playback.InPointByRelativeTime  = TimeSpan.FromSeconds(FInputInPoint[0]);
                    playback.OutPointByRelativeTime = TimeSpan.FromSeconds(Math.Min(FInputOutPoint[0], playback.Duration.TotalSeconds));
                    var kStudioMetadata = playback.GetMetadata(KStudioMetadataType.Public);

                    if (startpaused)
                    {
                        playback.StartPaused();
                    }
                    else
                    {
                        playback.Start();
                    };

                    FRecordTotalDuration[0] = playback.Duration.TotalSeconds;

                    while ((playback.State == KStudioPlaybackState.Playing) || (playback.State == KStudioPlaybackState.Paused) && (doPlay))
                    {
                        if (doStep)
                        {
                            if ((playback.State == KStudioPlaybackState.Playing))
                            {
                                playback.Pause();
                            }
                            if (playback.State == KStudioPlaybackState.Paused)
                            {
                                playback.StepOnce();
                                Thread.Sleep(20);
                            }
                            doStep = false;
                        }
                        Thread.Sleep(20);
                    }
                    playback.Stop();
                }

                playback = null;
                client.DisconnectFromService();
            }
        }
        /// <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();
            }
        }