Пример #1
0
 public void EnrichCurrentTrack([NotNull] ContextTrack track)
 {
     if (_isPlayingQueue)
     {
         var b = _state.ConnectState.Track;
         ProtoUtils.EnrichTrack(b, track);
     }
     else
     {
         int index   = (int)GetCurrentTrackIndex();
         var current = Tracks[index];
         ProtoUtils.EnrichTrack(current, track);
         Tracks[index]             = current;
         _state.ConnectState.Track = ProtoUtils.ConvertToProvidedTrack(current);
     }
 }
Пример #2
0
        public void UpdateState()
        {
            if (_isPlayingQueue)
            {
                _state.ConnectState.Track = ProtoUtils.ConvertToProvidedTrack(_queue.First.Value);
                _queue.RemoveFirst();
            }
            else
            {
                _state.ConnectState.Track = ProtoUtils.ConvertToProvidedTrack(Tracks[(int)GetCurrentTrackIndex()]);
            }

            UpdateLikeDislike();

            UpdateTrackDuration();
            UpdatePrevNextTracks();
        }
Пример #3
0
        private void UpdatePrevNextTracks()
        {
            var index = GetCurrentTrackIndex();

            _state.ConnectState.PrevTracks.Clear();
            for (var i = (int)Math.Max(0, index - MaxPrevTracks); i < index; i++)
            {
                _state.ConnectState.PrevTracks.Add(ProtoUtils.ConvertToProvidedTrack(Tracks[i]));
            }

            _state.ConnectState.NextTracks.Clear();
            _state.ConnectState.NextTracks.AddRange(_queue.Select(ProtoUtils.ConvertToProvidedTrack));


            for (var i = (int)index + 1; i < Math.Min(Tracks.Count, index + 1 + MaxNextTracks); i++)
            {
                _state.ConnectState.NextTracks.Add((ProtoUtils.ConvertToProvidedTrack(Tracks[i])));
            }
        }