DownloadVideoAsync() приватный Метод

private DownloadVideoAsync ( Business.DownloadItem downloadInfo, Business.DownloadItem fileInfo, EventHandler callback ) : Task
downloadInfo Business.DownloadItem
fileInfo Business.DownloadItem
callback EventHandler
Результат Task
        /// <summary>
        /// Prepares for playing the next video.
        /// </summary>
        /// <param name="queuePos">The video position to select. 0 for current, 1 for next.</param>
        /// <param name="attempts">The number of attemps already made, to avoid infinite loop.</param>
        /// <returns>Whether the file is downloading.</returns>
        private async Task <bool> PrepareNextVideoAsync(int queuePos, int attempts)
        {
            bool FileExists = false;

            if (nextVideo != null)
            {
                FileExists = File.Exists(Settings.NaturalGroundingFolder + nextVideo.FileName);
            }

            if (!FileExists)
            {
                // If file doesn't exist and can't be downloaded, select another one.
                if (!Settings.SavedFile.AutoDownload || nextVideo == null || nextVideo.DownloadUrl.Length == 0)
                {
                    await SelectNextVideoAsync(queuePos, false, attempts + 1).ConfigureAwait(false);
                }
                // If file doesn't exist and can be downloaded, download it.
                else if (nextVideo != null && nextVideo.DownloadUrl.Length > 0)
                {
                    Application.Current.Dispatcher.Invoke(() => PlaylistChanged?.Invoke(this, new EventArgs()));
                    await downloadManager.DownloadVideoAsync(nextVideo, queuePos, Download_Complete).ConfigureAwait(false);

                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
 private async Task DownloadFile(VideoListItem item, DownloadAction action)
 {
     if (Manager != null && item != null && item.MediaId != null)
     {
         Media ItemData = PlayerAccess.GetVideoById(item.MediaId.Value);
         if (ItemData != null)
         {
             SetStatus(item, VideoListItemStatusEnum.Downloading, null);
             await Manager.DownloadVideoAsync(ItemData, -1,
                                              (sender, e) => {
                 SetStatus(item, e.DownloadInfo.IsCompleted ? VideoListItemStatusEnum.Done : VideoListItemStatusEnum.Failed);
             }, action, null);
         }
     }
 }