private void OnDownloadStatusChanged(Feed feed, DownloadState downloadState, double percentage)
        {
            var finishedCount = 0;
            var downloadCount = 0;
            var average = 0.0;
            var entry = feed as YoutubeEntry;
            if (downloadState == DownloadState.Deleted) {
                if (entry != null) { entry.OnEntryDownloadStatusChange = null; Entries.Remove(entry); }
                return;
            }
            foreach (var en in Entries) {
                if (en.DownloadState == DownloadState.Ready || en.DownloadState == DownloadState.Error) finishedCount++;
                if (!(en.DownloadState == DownloadState.Ready || en.DownloadState == DownloadState.Error || en.DownloadState == DownloadState.Initialized)) downloadCount++;
                average += en.Percentage;
            }
            average = average/Entries.Count;

            if (OnListDownloadStatusChange != null) {
                DownloadState = downloadState;
                if (downloadState == DownloadState.DownloadProgressChanged)  Percentage = average;
                if (downloadCount == 0 && finishedCount == Entries.Count) DownloadState = DownloadState.AllFinished;
                if (Entries.Count == 1 && downloadState == DownloadState.TitleChanged)  Title = Entries[0].Title;
                OnListDownloadStatusChange(this, feed, DownloadState, Percentage);
            }
            if (downloadCount < PoolSize) DownloadFirst();
        }
 private void OnAudioConversionStatusChange(Feed feed, DownloadState downloadState, double percentage)
 {
     UpdateStatus(downloadState, percentage);
 }
示例#3
0
 private void UpdateStatus(Feed downloadItems, Feed entry, DownloadState downloadState, double percentage)
 {
     try {
         switch (downloadState) {
             case DownloadState.AllStart:
                 ProgressBar.Value = 0;
                 break;
             case DownloadState.AllFinished:
                 Log.Text = "DONE!";
                 ProgressBar.Value = 0;
                 downloadItems.Entries.Clear();
                 return;
             case DownloadState.UpdateCache:
                 _cacheManager.Save();
                 return;
             case DownloadState.DownloadProgressChanged:
                 ProgressBar.Value = percentage;
                 break;
             case DownloadState.TitleChanged:
                 MixpanelTrack("Download", new {entry.Title, Guid = _settings.ApplicationConfiguration.Guid});
                 break;
         }
         Log.Text = (entry != null) ? entry.ToString() : "";
     }
     catch {}
 }
示例#4
0
 private void OnDownloadStatusChange(Feed downloadItems, Feed entry, DownloadState downloadState, double percentage)
 {
     try {
         Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => UpdateStatus(downloadItems, entry, downloadState, percentage)));
     } catch {}
 }