public void AddRequest(MediaTrack track, TimeSpan chunkTimestamp)
        {
            var request = new DownloadRequest(track, chunkTimestamp);

            _requests.Add(request);
            NotifyRequestAdded();

            if (ChunkDownloadStrategy == ChunkDownloadStrategy.AsNeeded && !_refreshTimer.IsEnabled)
            {
                _refreshTimer.Start();
                _mediaPlugin.SeekCompleted += new Action <IMediaPlugin>(_mediaPlugin_SeekCompleted);
            }
        }
        protected override RetryQueueRequest NextRequest()
        {
            DownloadRequest next = null;

            switch (ChunkDownloadStrategy)
            {
            case Primitives.ChunkDownloadStrategy.AsNeeded:
                next = _requests.WhereAfterPosition(_mediaPlugin.Position - TimeSpan.FromSeconds(3), 1).FirstOrDefault();
                if (next != null && next.ChunkTimestamp > _mediaPlugin.Position + TimeSpan.FromMilliseconds(DefaultAsNeededWindowMillis))
                {
                    next = null;
                }
                next = next ?? _requests.WhereAfterPosition(_mediaPlugin.Position - TimeSpan.FromMilliseconds(DefaultAsNeededWindowMillis), 1).LastOrDefault();
                if (next != null && next.ChunkTimestamp > _mediaPlugin.Position + TimeSpan.FromMilliseconds(DefaultAsNeededWindowMillis))
                {
                    next = null;
                }
                break;

            case Primitives.ChunkDownloadStrategy.AggressiveFuture:
                next = _requests.WhereAfterPosition(_mediaPlugin.Position - TimeSpan.FromSeconds(3), 1).FirstOrDefault();
                break;

            case Primitives.ChunkDownloadStrategy.AggressiveFromStart:
                next = _requests.WhereAfterPosition(_mediaPlugin.Position - TimeSpan.FromSeconds(3), 1).FirstOrDefault();
                next = next ?? _requests.FirstOrDefault();
                break;

            case Primitives.ChunkDownloadStrategy.AggressiveFromCurrent:
                next = _requests.WhereAfterPosition(_mediaPlugin.Position - TimeSpan.FromSeconds(3), 1).FirstOrDefault();
                next = next ?? _requests.LastOrDefault();
                break;
            }
            if (next != null)
            {
                _requests.Remove(next);
            }

            return(next);
        }
        public void AddRequest(MediaTrack track, TimeSpan chunkTimestamp)
        {
            var request = new DownloadRequest(track, chunkTimestamp);
            _requests.Add(request);
            NotifyRequestAdded();

            if (ChunkDownloadStrategy == ChunkDownloadStrategy.AsNeeded && !_refreshTimer.IsEnabled)
            {
                _refreshTimer.Start();
                _mediaPlugin.SeekCompleted += new Action<IMediaPlugin>(_mediaPlugin_SeekCompleted);
            }
        }