Business.PlayerBusiness.PrepareNextVideoAsync C# (CSharp) Метод

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

Prepares for playing the next video.
private PrepareNextVideoAsync ( int queuePos, int attempts ) : Task
queuePos int The video position to select. 0 for current, 1 for next.
attempts int The number of attemps already made, to avoid infinite loop.
Результат Task
        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;
        }