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;
}