Skip to content

Commit

Permalink
恢复视频默认倍速设置项
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Jul 22, 2024
1 parent 49bd112 commit 3a4984a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
17 changes: 6 additions & 11 deletions src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,17 @@
<TextBlock Margin="0 16 0 8" FontSize="16" Visibility="Collapsed">使用FFmpeg播放时硬解视频</TextBlock>
<ToggleSwitch x:Name="swHardwareDecode" Visibility="Collapsed"></ToggleSwitch>-->

<!--<controls:SettingsCard Header="视频默认倍速"
<controls:SettingsCard Header="视频默认倍速"
Description="视频默认倍速">
<controls:SettingsCard.HeaderIcon>
<font:FontAwesome Icon="Solid_AngleDoubleRight"></font:FontAwesome>
</controls:SettingsCard.HeaderIcon>
<ComboBox x:Name="cbVideoSpeed" SelectedIndex="0" MinWidth="200">
<ComboBox.Items>
<ComboBoxItem Content="2.0x" ></ComboBoxItem>
<ComboBoxItem Content="1.5x" ></ComboBoxItem>
<ComboBoxItem Content="1.25x" ></ComboBoxItem>
<ComboBoxItem Content="1.0x"></ComboBoxItem>
<ComboBoxItem Content="0.75x" ></ComboBoxItem>
<ComboBoxItem Content="0.5x" ></ComboBoxItem>
</ComboBox.Items>
<ComboBox x:Name="cbVideoSpeed" SelectedIndex="0" MinWidth="200"
SelectedValuePath="Value"
DisplayMemberPath="Content"
ItemsSource="{x:Bind m_playSpeedMenuService.MenuItems}">
</ComboBox>
</controls:SettingsCard>-->
</controls:SettingsCard>

<controls:SettingsCard Header="播放完成自动切换下一P"
Description="播放完成自动切换下一P">
Expand Down
23 changes: 15 additions & 8 deletions src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 上介绍了“用户控件”项模板

Expand All @@ -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<PlaySettingsControlViewModel>();
m_playSpeedMenuService = App.ServiceProvider.GetRequiredService<PlaySpeedMenuService>();
this.InitializeComponent();
LoadPlayer();
}
Expand All @@ -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<double>(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<double>(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<bool>(SettingConstants.Player.HARDWARE_DECODING, true);
Expand Down

0 comments on commit 3a4984a

Please sign in to comment.