Ejemplo n.º 1
0
 void _displayTimer_Tick(object sender, object e)
 {
     try
     {
         if (_controller.IsValid && _controller.Playlist != null && _player.CurrentState == MediaElementState.Playing)
         {
             _data.CurrentBandwidth = _controller.GetLastMeasuredBandwidth();
         }
     }
     catch (Exception Ex) { }
 }
        void _clocktimer_Tick(object sender, object e)
        {
            _timeNow = DateTime.Now;

            try
            {
                if (_player.CurrentState == MediaElementState.Playing && _controller != null && _controller.IsValid)
                {
                    if (_controller.Playlist.IsLive == false)
                    {
                        _timePlayed = _player.Position.Subtract(_initialPlaybackPosition);
                    }

                    else
                    {
                        _timeLive = _player.Position;
                        if (_initialPlaybackPosition != default(TimeSpan))
                        {
                            _timePlayed = _player.Position.Subtract(_initialPlaybackPosition);
                        }

                        var sw = _controller.Playlist.SlidingWindow;
                        if (sw != null)
                        {
                            _player.StartTime    = sw.StartTimestamp;
                            _player.EndTime      = sw.EndTimestamp;
                            _player.LivePosition = sw.LivePosition;
                        }

                        //System.Diagnostics.Debug.WriteLine(string.Format("Player Position : {0}, Sliding Window Start : {1}, Sliding Window End : {2}, Live Position : {3}", _player.Position, sw.StartTimestamp, sw.EndTimestamp, sw.LivePosition));
                    }
                    if (_controller.IsValid)
                    {
                        _currentBandwidth = _controller.GetLastMeasuredBandwidth();
                    }
                }
            }
            catch (Exception Ex)
            {
            }


            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("TimeNow"));
                PropertyChanged(this, new PropertyChangedEventArgs("TimePlayed"));
                PropertyChanged(this, new PropertyChangedEventArgs("TimeLive"));
                PropertyChanged(this, new PropertyChangedEventArgs("CurrentBandwidth"));
            }
        }