/// <summary> /// Stores the provided video resolution string into the store. /// If the provided resolution is no part of the available video resolutions /// the store operation will not be executed and NO will be returned. /// </summary> /// <param name="resolution">resolution the string to be stored.</param> /// <returns> YES/NO depending on success.</returns> public bool StoreVideoResolutionSetting(string resolution) { if (!AvailableVideoResolutions.Contains(resolution)) { return(false); } _settingStore.VideoResolution = resolution; return(true); }
/// <summary> /// Invoked when <see cref="PropertyChanged"/> is activated /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WndwInfoSelector_PropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case "VideoInfo": //Check that audio can be extracted if (VideoInfo.Count(info => info.CanExtractAudio) == 0) { AudioDownloadingEnabled = false; } //Add all the extensions to the extension list foreach (VideoInfo element in VideoInfo) { if (!AvailableVideoFormats.Contains(element.VideoExtension)) { AvailableVideoFormats.Add(element.VideoExtension); } } //Sort the format list AvailableVideoFormats.OrderBy(format => format); //Set the selected video extension SelectedVideoExtension = AvailableVideoFormats[0]; //Add all the audio extensions to the extension list foreach (VideoInfo element in VideoInfo) { if (!AvailableAudioFormats.Contains(element.AudioExtension)) { AvailableAudioFormats.Add(element.AudioExtension); } } //Sort the list AvailableAudioFormats.OrderBy(format => format); //Set the selected audio extension SelectedAudioExtension = AvailableAudioFormats[0]; break; case "SelectedVideoFormat": //Get all the videos with the selected format IEnumerable <VideoInfo> validVideos = VideoInfo.Where(format => format.VideoExtension == SelectedVideoExtension) .OrderBy(res => res.Resolution) .Distinct(); //Clear the current resolutions AvailableVideoResolutions.Clear(); //Add the resolutions to the list foreach (VideoInfo element in validVideos) { AvailableVideoResolutions.Add(element.Resolution); } //Select the highest res SelectedVideoResolution = AvailableVideoResolutions.Last(); break; case "SelectedAudioFormat": //Because audio bitrate selection is used in the Video info selection, only update it if the user //Is in the audio download tab if (SelectedDownloadType == DownloadType.Audio) { //The list of audio that we can download IEnumerable <VideoInfo> validAudios = null; try { //Get all the videos with the selected audio format validAudios = VideoInfo.Where(format => format.AudioExtension == SelectedAudioExtension && format.CanExtractAudio) .OrderBy(bitrate => bitrate.AudioBitrate) .Distinct(); } catch { } //Clear the current bitrates AvailableAudioBitrates.Clear(); //Add the bitrates to the list foreach (VideoInfo element in validAudios) { AvailableAudioBitrates.Add(element.AudioBitrate); } //Select the highest bitrate SelectedAudioBitrate = AvailableAudioBitrates.Last(); } break; //We need to reset the selectable audio bitrates, as may have been updated when SelectedVideoResolution changes case "SelectedDownloadType": //Check that the audio download tab is selected if (SelectedDownloadType == DownloadType.Audio) { //Get all the videos with the selected audio format IEnumerable <VideoInfo> validAudios = VideoInfo.Where(format => format.AudioExtension == SelectedAudioExtension && format.CanExtractAudio) .OrderBy(bitrate => bitrate.AudioBitrate) .Distinct(); //Clear the current bitrates AvailableAudioBitrates.Clear(); //Add the bitrates to the list foreach (VideoInfo element in validAudios) { AvailableAudioBitrates.Add(element.AudioBitrate); } //Select the highest bitrate SelectedAudioBitrate = AvailableAudioBitrates.Last(); } else { //Get all the videos with the selected resolution IEnumerable <VideoInfo> validAudios = VideoInfo.Where(format => format.Resolution == SelectedVideoResolution && format.VideoExtension == SelectedVideoExtension) .OrderBy(bitrate => bitrate.AudioBitrate) .Distinct(); //Clear the current bitrates AvailableAudioBitrates.Clear(); //Add the bitrates to the list foreach (VideoInfo element in validAudios) { AvailableAudioBitrates.Add(element.AudioBitrate); } //Select the highest bitrate SelectedAudioBitrate = AvailableAudioBitrates.Last(); } break; //Change the available audio bitrates based on the resolution and format of the video selected case "SelectedVideoResolution": if (SelectedDownloadType == DownloadType.Video) { //Get all the videos with the selected resolution IEnumerable <VideoInfo> validAudios = VideoInfo.Where(format => format.Resolution == SelectedVideoResolution && format.VideoExtension == SelectedVideoExtension) .OrderBy(bitrate => bitrate.AudioBitrate) .Distinct(); //Clear the current bitrates AvailableAudioBitrates.Clear(); //Add the bitrates to the list foreach (VideoInfo element in validAudios) { AvailableAudioBitrates.Add(element.AudioBitrate); } //Select the highest bitrate SelectedAudioBitrate = AvailableAudioBitrates.Last(); } break; } }
private void RegisterStoreDefaults() { NSData codecData = NSKeyedArchiver.ArchivedDataWithRootObject(AvailableVideoCodecs.First()); ARDSettingsStore.SetDefaultsForVideoResolution(AvailableVideoResolutions.FirstOrDefault(), codecData, null, false, false, true); }