public void SetTimePlayback(TimeSpan time) { if (Playback == null) { return; } TimeSpan playbackTime = _playback.CurrentRelativeTime; if (Convert.ToInt32(playbackTime.TotalSeconds) != Convert.ToInt32(time.TotalSeconds)) { Pause(); _playback.SeekByRelativeTime(time); } }
/// <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(); } }
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(); } }