示例#1
0
        private void InterpretStatus(string statusXml)
        {
            if (!_timeSource.CheckAccess())
            {
                _timeSource.Dispatcher.Invoke(() => InterpretStatus(statusXml));
                return;
            }

            try
            {
                VlcStatus newStatus = new VlcStatus(statusXml);

                if (newStatus.IsValid)
                {
                    if (!_previousStatus.IsValid || _previousStatus.Filename != newStatus.Filename)
                    {
                        FindFullFilename(newStatus.Filename);
                    }

                    if (!_previousStatus.IsValid || _previousStatus.PlaybackState != newStatus.PlaybackState)
                    {
                        if (newStatus.PlaybackState == VlcPlaybackState.Playing)
                        {
                            _timeSource.Play();
                        }
                        else
                        {
                            _timeSource.Pause();
                        }
                    }

                    if (!_previousStatus.IsValid || _previousStatus.Duration != newStatus.Duration)
                    {
                        _timeSource.SetDuration(newStatus.Duration);
                    }

                    if (!_previousStatus.IsValid || _previousStatus.Progress != newStatus.Progress)
                    {
                        _timeSource.SetPosition(newStatus.Progress);
                    }
                }

                _previousStatus = newStatus;
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Couldn't interpret VLC Status: " + exception.Message);
            }
        }
示例#2
0
        public VlcTimeSource(ISampleClock clock, VlcConnectionSettings connectionSettings)
        {
            _connectionSettings = connectionSettings;
            _previousStatus     = new VlcStatus {
                IsValid = false
            };

            _timeSource = new ManualTimeSource(clock, TimeSpan.FromMilliseconds(200));
            _timeSource.DurationChanged     += TimeSourceOnDurationChanged;
            _timeSource.IsPlayingChanged    += TimeSourceOnIsPlayingChanged;
            _timeSource.ProgressChanged     += TimeSourceOnProgressChanged;
            _timeSource.PlaybackRateChanged += TimeSourceOnPlaybackRateChanged;

            _clientLoop = new Thread(ClientLoop);
            _clientLoop.Start();
        }