From 3a4984af0e1150887ee583c440baebe44a01875c Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Mon, 22 Jul 2024 20:04:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E8=A7=86=E9=A2=91=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=8D=E9=80=9F=E8=AE=BE=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Settings/PlaySettingsControl.xaml | 17 +++++--------- .../Settings/PlaySettingsControl.xaml.cs | 23 ++++++++++++------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml b/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml index 6f97b1d1..182f2890 100644 --- a/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml +++ b/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml @@ -48,22 +48,17 @@ 使用FFmpeg播放时硬解视频 --> - + diff --git a/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml.cs index 55013533..73325db0 100644 --- a/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml.cs @@ -6,6 +6,7 @@ using BiliLite.Models.Common; using BiliLite.Services; using BiliLite.ViewModels.Settings; +using System.Linq; //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 @@ -14,10 +15,12 @@ namespace BiliLite.Controls.Settings public sealed partial class PlaySettingsControl : UserControl { private readonly PlaySettingsControlViewModel m_viewModel; + private readonly PlaySpeedMenuService m_playSpeedMenuService; public PlaySettingsControl() { m_viewModel = App.ServiceProvider.GetRequiredService(); + m_playSpeedMenuService = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); LoadPlayer(); } @@ -32,14 +35,18 @@ private void LoadPlayer() SettingService.SetValue(SettingConstants.Player.DEFAULT_VIDEO_TYPE, (int)cbVideoType.SelectedValue); }; //视频倍速 - //cbVideoSpeed.SelectedIndex = SettingConstants.Player.VideoSpeed.IndexOf(SettingService.GetValue(SettingConstants.Player.DEFAULT_VIDEO_SPEED, 1.0d)); - //cbVideoSpeed.Loaded += new RoutedEventHandler((sender, e) => - //{ - // cbVideoSpeed.SelectionChanged += new SelectionChangedEventHandler((obj, args) => - // { - // SettingService.SetValue(SettingConstants.Player.DEFAULT_VIDEO_SPEED, SettingConstants.Player.VideoSpeed[cbVideoSpeed.SelectedIndex]); - // }); - //}); + var speeds = m_playSpeedMenuService.MenuItems + .Select(x => x.Value) + .ToList(); + cbVideoSpeed.SelectedIndex = speeds + .IndexOf(SettingService.GetValue(SettingConstants.Player.DEFAULT_VIDEO_SPEED, 1.0d)); + cbVideoSpeed.Loaded += (sender, e) => + { + cbVideoSpeed.SelectionChanged += (obj, args) => + { + SettingService.SetValue(SettingConstants.Player.DEFAULT_VIDEO_SPEED, speeds[cbVideoSpeed.SelectedIndex]); + }; + }; //硬解视频 //swHardwareDecode.IsOn = SettingService.GetValue(SettingConstants.Player.HARDWARE_DECODING, true);