public void RemoveRequests(MediaTrack MediaTrack)
 {
     foreach (var request in _requests.Where(r => r.MediaTrack.TrackInfo == MediaTrack.TrackInfo).ToList())
     {
         _requests.Remove(request);
     }
 }
        private void BeginGetChunk_Completed(IAsyncResult asyncResult)
        {
            var        downloadRequest = (DownloadRequest)asyncResult.AsyncState;
            MediaTrack track           = downloadRequest.MediaTrack;

            ChunkResult chunk = track.TrackInfo.EndGetChunk(asyncResult);

            NotifyRequestSuccessful(downloadRequest);
            DownloadCompleted(this, downloadRequest.MediaTrack, downloadRequest.ChunkTimestamp, chunk);
        }
        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);
            }
        }
 public DownloadRequest(MediaTrack mediaTrack, TimeSpan timestamp)
 {
     MediaTrack = mediaTrack;
     ChunkTimestamp = timestamp;
 }
        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);
            }
        }
 public void RemoveRequests(MediaTrack MediaTrack)
 {
     foreach (var request in _requests.Where(r => r.MediaTrack.TrackInfo == MediaTrack.TrackInfo).ToList())
     {
         _requests.Remove(request);
     }
 }
 public DownloadRequest(MediaTrack mediaTrack, TimeSpan timestamp)
 {
     MediaTrack     = mediaTrack;
     ChunkTimestamp = timestamp;
 }
        private void ChunkDownloadManager_ChunkDownloadCompleted(ChunkDownloadManager downloadManager, MediaTrack track,
                                                                 TimeSpan timestamp, ChunkResult result)
        {
            try
            {
                var dataChunk = track.ParentStream.DataChunks.First(i => i.Timestamp == timestamp);

                if (result.Result == ChunkResult.ChunkResultState.Succeeded)
                {
                    var downloadResult = new StreamDownloadResult
                                             {
                                                 DataChunk = dataChunk,
                                                 Stream = result.ChunkData,
                                                 Type = track.ParentStream.Type
                                             };

                    DownloadStreamDataCompleted.IfNotNull(i => i(this, track, downloadResult));
                }
                else
                {
                    Exception err = result.Error ?? new DownloadStreamDataTimeOutException();

                    DownloadStreamDataFailed.IfNotNull(i => i(this, track, dataChunk, err));
                }
            }
            catch (Exception ex)
            {
                DownloadStreamDataFailed.IfNotNull(i => i(this, track, null, ex));
            }
        }
        private void ChunkDownloadManager_ChunkDownloadExceededMaximumRetryAttempts(ChunkDownloadManager chunkDownloadManager, MediaTrack mediaTrack, TimeSpan chunkTimestamp)
        {
            SendLogEntry(KnownLogEntryTypes.SmoothStreamingMediaElementDownloadExceededMaximumRetryAttempts, LogLevel.Error);

            DownloadStreamDataFailed.IfNotNull(i => i(this, mediaTrack, null, new DownloadStreamDataTimeOutException()));
        }
 private void ChunkDownloadManager_RetryingChunkDownload(ChunkDownloadManager chunkDownloadManager, MediaTrack mediaTrack, TimeSpan chunkTimestamp)
 {
     SendLogEntry(KnownLogEntryTypes.SmoothStreamingMediaElementDownloadRetry);
 }