Exemple #1
0
 public void OnViewLoaded()
 {
     // Select last used format
     SelectedFormat = !string.IsNullOrWhiteSpace(_settingsService.LastFormat) && AvailableFormats.Contains(_settingsService.LastFormat)
         ? _settingsService.LastFormat
         : AvailableFormats.FirstOrDefault();
 }
        protected DownloadSetupViewModelBase(IViewModelFactory viewModelFactory, DownloadService downloadService)
        {
            _viewModelFactory = viewModelFactory;
            _downloadService  = downloadService;

            // Default format
            SelectedFormat = AvailableFormats.FirstOrDefault();
        }
        protected override void OnViewLoaded()
        {
            base.OnViewLoaded();

            // Select last used format
            SelectedFormat = AvailableFormats.Contains(_settingsService.LastFormat)
                ? _settingsService.LastFormat
                : AvailableFormats.FirstOrDefault();
        }
Exemple #4
0
        protected override void OnViewLoaded()
        {
            base.OnViewLoaded();

            // Persist preferences
            SelectedFormat = AvailableFormats.Contains(_settingsService.LastFormat)
                ? _settingsService.LastFormat
                : AvailableFormats.FirstOrDefault();
        }
        public void OnViewLoaded()
        {
            SelectedFormat =
                !string.IsNullOrWhiteSpace(_settingsService.LastFormat) &&
                AvailableFormats.Contains(_settingsService.LastFormat, StringComparer.OrdinalIgnoreCase)
                    ? _settingsService.LastFormat
                    : AvailableFormats.FirstOrDefault();

            SelectedVideoQualityPreference = _settingsService.LastVideoQualityPreference;
        }
Exemple #6
0
        private async Task LoadVideoInfo(bool validateUrl)
        {
            Exception getVideosException = null;
            await DialogHost.Show(new WaitDialog(), "NewDownloadDialogHost",
                                  (DialogOpenedEventHandler)(async(sender, e) =>
            {
                if (validateUrl)
                {
                    if (!await IsValidVideoUrl(Url))
                    {
                        InvalidUrl = true;
                        e.Session.Close();
                        return;
                    }
                }

                await DataService.GetVideoAsync(Url, (res, ex) =>
                {
                    if (ex != null)
                    {
                        getVideosException = ex;
                    }
                    else if (res.Videos.Length > 0)
                    {
                        ResultItem = res.Videos[0];
                        VideoFormat = AvailableFormats.First();
                        // Set default save path
                        if (ResultItem != null)
                        {
                            VideoSavePath =
                                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                             GetVideoFileName());
                        }
                    }
                    else if (res.Playlists.Length > 0)
                    {
                        // ResultItem = new VideoPlaylist(res.Playlists[0]);
                        // VideoSavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), MakeValidFileName(ResultItem.Title));
                        ResultItem = null;
                        AddError("Playlists are not supported yet.", () => Url);
                    }
                    else
                    {
                        ResultItem = null;
                        NoResultFound = true;
                    }
                });
                e.Session.Close();
            }));

            if (getVideosException != null)
            {
                await ShowExceptionDialog(getVideosException, "Loading video info failed!");

                AddError("An error occured.", () => Url);
                return;
            }

            if (ResultItem is VideoPlaylist)
            {
                await((VideoPlaylist)ResultItem).FillItemsInfo(DataService);
                RaisePropertyChanged(() => AvailableFormats);
            }

            if (AvailableFormats != null)
            {
                VideoFormat = AvailableFormats.FirstOrDefault();
            }
        }