コード例 #1
0
 /// <summary>
 /// 播放xef视频
 /// </summary>
 /// <param name="filePath">xef视频路径</param>
 public void PlaybackClip(object filePath)
 {
     ///以前的方法,不能加骨骼上去
     #region
     using (KStudioClient PlayClient = KStudio.CreateClient())
     {
         PlayClient.ConnectToService();
         using (KStudioPlayback playback = PlayClient.CreatePlayback((string)filePath))
         {
             playback.LoopCount = 0;
             playback.Start();
             Flag2 = 0;
             while (playback.State == KStudioPlaybackState.Playing)
             {
             }
             if (playback.State == KStudioPlaybackState.Error)
             {
                 Flag2 = 1;
                 throw new InvalidOperationException("Error: Playback failed!");
             }
             Flag2 = 1;
             playback.Stop();
             playback.Dispose();
         }
         PlayClient.DisconnectFromService();
         System.Windows.Forms.MessageBox.Show("回放结束");
     }
     #endregion
 }
コード例 #2
0
        private void PlayClip(string filePath)
        {
            using (KStudioClient client = KStudio.CreateClient())
            {
                client.ConnectToService();


                KStudioPlaybackFlags flags = KStudioPlaybackFlags.IgnoreOptionalStreams;
                playback = client.CreatePlayback(filePath, flags);
                using (playback)
                {
                    playback.PropertyChanged += Recording_PropertyChanged;
                    playback.StateChanged    += Playback_StateChanged;
                    playback.LoopCount        = 10000;
                    playback.Start();

                    FRecordTotalDuration[0] = playback.Duration.TotalSeconds;

                    while ((playback.State == KStudioPlaybackState.Playing) || (playback.State == KStudioPlaybackState.Paused) && (doPlay))
                    {
                        Thread.Sleep(50);
                    }
                    playback.Stop();
                }
                client.DisconnectFromService();
            }
        }
        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();
            }
        }
コード例 #4
0
        public void PlaybackClip()
        {
            using (KStudioClient client = KStudio.CreateClient())
            {
                client.ConnectToService();

                using (KStudioPlayback playback = client.CreatePlayback(filePath))
                {
                    playback.LoopCount = loopCount;
                    playback.Start();

                    while (done == false && playback.State == KStudioPlaybackState.Playing)
                    {
                        Thread.Sleep(30);
                    }

                    if (playback.State == KStudioPlaybackState.Error)
                    {
                        throw new InvalidOperationException("Error: Playback failed!");
                    }

                    playback.Stop();
                    // Reset the value of done
                    done = false;
                }

                client.DisconnectFromService();
            }
        }
コード例 #5
0
 public void stopPlayback()
 {
     if (_playback != null)
     {
         Pause();
         _playback.Stop();
     }
 }
コード例 #6
0
        /// <summary>
        /// Playback a list of clips
        /// </summary>
        /// <param name="filename">ObservableCollection of VideoModel objects that contains Filename of the clip to be played.</param>
        private void PlaybackClip(ObservableCollection <VideoModel> videos)
        {
            using (KStudioClient client = KStudio.CreateClient())
            {
                client.ConnectToService();
                KStudioEventStreamSelectorCollection streamCollection = new KStudioEventStreamSelectorCollection();
                VideoModel video;
                int        i = 0;

                while (i < videos.Count)
                {
                    video = videos[i];

                    if (!string.IsNullOrEmpty(video.Filename))
                    {
                        _status = "Playing " + video.Filename + " - " + (i + 1) + "/" + videos.Count;

                        using (KStudioPlayback playback = client.CreatePlayback(video.Filename))
                        {
                            _isPlaying = true;
                            _stop      = false;

                            // We can use playback.StartPaused() and SeekRelativeTime to start the clip at
                            // a specific time.
                            playback.Start();


                            while (playback.State == KStudioPlaybackState.Playing)
                            {
                                Thread.Sleep(150);

                                if (_stop)
                                {
                                    playback.Stop();
                                    break;
                                }
                            }

                            _isPlaying = false;

                            if (_stop)
                            {
                                return;
                            }
                        }
                    }
                    i++;
                }
                client.DisconnectFromService();
            }
        }
コード例 #7
0
        private void stopButton_Click(object sender, RoutedEventArgs e)
        {
            if (playback != null)
            {
                playback.Stop();
                playback = null;
            }

            if (playThread != null)
            {
                playThread.Abort();
                playThread = null;
            }
        }
コード例 #8
0
        public void CloseRecording()
        {
            OnRecordingStopped();

            if (playback != null)
            {
                playback.Stop();
                playback.Dispose();
                playback = null;
            }
            if (client != null)
            {
                client.DisconnectFromService();
                client.Dispose();
                client = null;
            }

            LogConsole.WriteLine("Recording stopped");
        }
コード例 #9
0
        /// <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();
            }
        }
コード例 #10
0
        public Task PlayClip(string filePath, uint loopCount = 0)
        {
            if (IsRecording || IsPlaying)
            {
                return(null);
            }

            _stopRequested = false;
            Task t = Task.Run(() =>
            {
                _playing = true;
                using (KStudioClient client = KStudio.CreateClient())
                {
                    client.ConnectToService();

                    using (KStudioPlayback playback = client.CreatePlayback(filePath))
                    {
                        playback.LoopCount = loopCount;
                        playback.Start();
                        while (playback.State == KStudioPlaybackState.Playing)
                        {
                            if (_stopRequested)
                            {
                                playback.Stop();
                            }
                            Thread.Sleep(50);
                        }
                    }

                    client.DisconnectFromService();
                }
                Thread.Sleep(100);
                _playing = false;
            });

            return(t);
        }
コード例 #11
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();
        }
コード例 #12
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();
            }
        }