From 79ccebf16050b1d7d98daccbd1c792ae8d3ab2ba Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Thu, 20 Oct 2022 22:30:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=85=88=E8=A7=A3=E6=9E=90=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E7=BC=96=E7=A0=81=E9=A1=BA=E5=BA=8F=E4=B8=BAAV1?= =?UTF-8?q?=E3=80=81HEVC=E3=80=81AVC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi/Services/Utils.cs | 85 ++++++++------------------------------- 1 file changed, 16 insertions(+), 69 deletions(-) diff --git a/DownKyi/Services/Utils.cs b/DownKyi/Services/Utils.cs index b3e055a..732f305 100644 --- a/DownKyi/Services/Utils.cs +++ b/DownKyi/Services/Utils.cs @@ -89,40 +89,6 @@ namespace DownKyi.Services } } - /// - /// 设置音质 - /// - /// - /// - /// - private static ObservableCollection GetAudioQualityFormatList_old(PlayUrl playUrl, int defaultAudioQuality) - { - List audioQualityFormatList = new List(); - - if (playUrl.Dash.Audio == null) - { - return new ObservableCollection(); - } - - foreach (PlayUrlDashVideo audio in playUrl.Dash.Audio) - { - // 音质id大于设置画质时,跳过 - if (audio.Id > defaultAudioQuality) { continue; } - - Quality audioQuality = Constant.GetAudioQualities().FirstOrDefault(t => { return t.Id == audio.Id; }); - if (audioQuality != null) - { - ListHelper.AddUnique(audioQualityFormatList, audioQuality.Name); - } - } - - audioQualityFormatList.Sort(new StringLogicalComparer()); - audioQualityFormatList.Reverse(); - - return new ObservableCollection(audioQualityFormatList); - } - - /// /// 设置音质 /// @@ -244,52 +210,33 @@ namespace DownKyi.Services VideoQuality selectedVideoQuality = videoQualityList.FirstOrDefault(t => t.Quality == video.Id); if (selectedVideoQuality == null) { continue; } - if (videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].VideoCodecList.Count == 1) - { - // 当获取的视频没有设置的视频编码时,执行 - videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].SelectedVideoCodec = videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].VideoCodecList[0]; - } - // 设置选中的视频编码 - //switch (videoCodecs) - //{ - // case VideoCodecs.AVC: - // if (videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].VideoCodecList.Contains("H.264/AVC")) - // { - // videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].SelectedVideoCodec = "H.264/AVC"; - // } - // break; - // case VideoCodecs.HEVC: - // if (videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].VideoCodecList.Contains("H.265/HEVC")) - // { - // videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].SelectedVideoCodec = "H.265/HEVC"; - // } - // break; - // case VideoCodecs.NONE: - // break; - // default: - // break; - //} string videoCodecsName = codeIds.FirstOrDefault(t => t.Id == videoCodecs).Name; if (videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].VideoCodecList.Contains(videoCodecsName)) { videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].SelectedVideoCodec = videoCodecsName; } + else + { + // 当获取的视频没有设置的视频编码时 + foreach (Quality codec in codeIds) + { + if (videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].VideoCodecList.Contains(codec.Name)) + { + videoQualityList[videoQualityList.IndexOf(selectedVideoQuality)].SelectedVideoCodec = codec.Name; + } + + if (codec.Id == videoCodecs) + { + break; + } + } + } } return videoQualityList; } - /// - /// 根据输入的字符串判断是AVC还是HEVC - /// - /// - /// - //internal static string GetVideoCodecName(string origin) - //{ - // return origin.Contains("avc") ? "H.264/AVC" : origin.Contains("hev") ? "H.265/HEVC" : origin.Contains("dvh") || origin.Contains("hvc") ? "Dolby Vision" : ""; - //} - } }