Skip to content

Commit

Permalink
播放控件中新增章节看点列表
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Sep 21, 2024
1 parent d668fe7 commit 20b7f8c
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 9 deletions.
Binary file added src/BiliLite.UWP/Assets/Icon/icon_view_point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@
<ItemGroup>
<Content Include="Assets\GeeTest\bili_gt.html" />
<Content Include="Assets\GeeTest\gt.js" />
<Content Include="Assets\Icon\icon_view_point.png" />
<Content Include="Assets\Icon\ic_play.png" />
<Content Include="Assets\Icon\icon_share.png" />
<Content Include="Assets\Icon\ic_live_center_gold_recharge.png" />
Expand Down
61 changes: 53 additions & 8 deletions src/BiliLite.UWP/Controls/PlayerControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
xmlns:fa="using:FontAwesome5" xmlns:player="using:BiliLite.Modules.Player"
xmlns:common="using:BiliLite.Models.Common"
xmlns:player1="using:BiliLite.Models.Common.Player"
xmlns:modules="using:BiliLite.Modules"
d:DesignHeight="800"
d:DesignWidth="1000">
<UserControl.Resources>
Expand Down Expand Up @@ -410,7 +411,7 @@
<TextBlock Margin="0 4 0 0">弹幕同屏密度(0为不限制) <Run Text="{x:Bind Path=DanmuSettingMaxNum.Value,Mode=OneWay,Converter={StaticResource numberToStringConvert}}"/></TextBlock>
<Slider x:Name="DanmuSettingMaxNum" Value="0" Minimum="0" Maximum="50" StepFrequency="1"></Slider>
<TextBlock Margin="0 4 0 0">
弹幕字体
弹幕字体
</TextBlock>
<AutoSuggestBox QueryIcon="Accept" x:Name="DanmuSettingFont"></AutoSuggestBox>

Expand Down Expand Up @@ -446,7 +447,7 @@
<TextBlock Foreground="White" >合并重复弹幕</TextBlock>
</ToggleSwitch.Header>
</ToggleSwitch>

</Grid>
<TextBlock Margin="0 8">屏蔽等级(0为不屏蔽) <Run Text="{x:Bind Path=DanmuSettingShieldLevel.Value,Mode=OneWay,Converter={StaticResource numberToStringConvert}}"/>级</TextBlock>
<Slider x:Name="DanmuSettingShieldLevel" Minimum="0" Maximum="10" StepFrequency="1"></Slider>
Expand Down Expand Up @@ -605,10 +606,10 @@
DoubleTapped="Grid_DoubleTapped">
<!--播放器-->
<local:Player x:Name="Player" PlayStateChanged="Player_PlayStateChanged" PlayMediaEnded="Player_PlayMediaEnded" PlayMediaError="Player_PlayMediaError" ChangeEngine="Player_ChangeEngine" PlayMediaOpened="Player_PlayMediaOpened"/>

<!--字幕-->
<Border x:Name="BorderSubtitle" Visibility="Collapsed" Opacity="{Binding ElementName=SubtitleSettingOpacity,Path=Value,Mode=OneWay}" Padding="3 4 8 4" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0 0 0 24">

</Border>
<!--弹幕-->
<Grid>
Expand Down Expand Up @@ -666,7 +667,7 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

<Grid x:Name="VirtualProgressBar"
Visibility="{x:Bind m_viewModel.ShowVideoBottomVirtualProgressBar}">
<Grid.RowDefinitions>
Expand Down Expand Up @@ -702,9 +703,15 @@
<TextBlock x:Name="TopTitle" VerticalAlignment="Center" Foreground="White" FontSize="18" Margin="12 0" TextTrimming="CharacterEllipsis">第一集</TextBlock>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock x:Name="TopOnline" Foreground="White" FontSize="16" VerticalAlignment="Center" Margin="12 0"></TextBlock>

<Button x:Name="TopBtnViewPoints"
Visibility="{x:Bind m_viewModel.ShowViewPointsBtn,Mode=OneWay}"
Click="TopBtnViewPoints_OnClick" Background="Transparent" Padding="0" Width="48" Height="48">
<Image Width="28" Height="28" Source="/Assets/Icon/icon_view_point.png" ></Image>
</Button>

<Button x:Name="TopBtnSettingDanmaku" Click="TopBtnSettingDanmaku_Click" Background="Transparent" Padding="0" Width="48" Height="48">
<Image Width="28" Height="28" Source="/Assets/Icon/icon_danmaku_setting.png" ></Image>

</Button>
<Button x:Name="TopBtnScreenshot" Click="TopBtnScreenshot_Click" Background="Transparent" Padding="0" Width="48" Height="48">
<Button.KeyboardAccelerators>
Expand Down Expand Up @@ -887,7 +894,7 @@
</StackPanel>
</Grid>
</Grid>

</Grid>
<Grid x:Name="MiniControl" Visibility="Collapsed" VerticalAlignment="Bottom">
<Grid.Background>
Expand Down Expand Up @@ -915,11 +922,49 @@
</StackPanel>
<ProgressBar VerticalAlignment="Bottom" Foreground="White" Value="{Binding ElementName=BottomProgress,Path=Value,Mode=OneWay}" Maximum="{Binding ElementName=BottomProgress,Path=Maximum,Mode=OneWay}"></ProgressBar>
</Grid>

</Grid>
<HyperlinkButton x:Name="BottomImageBtnPlay" Visibility="Collapsed" Margin="24 100" Width="80" Height="80" Click="BottomBtnPlay_Click" VerticalAlignment="Bottom" HorizontalAlignment="Right" >
<Image Source="ms-appx:///Assets/Icon/ic_play.png"></Image>
</HyperlinkButton>

<!--看点列表-->
<Grid x:Name="ViewPointsGrid"
Visibility="{x:Bind m_viewModel.ShowViewPointsView,Mode=OneWay}"
Tapped="ViewPointsGrid_OnTapped"
Background="Transparent">
<Grid
Width="320"
HorizontalAlignment="Right"
Background="#C8000000">
<ListView
SelectionMode="Single"
ItemsSource="{x:Bind m_viewModel.ViewPoints,Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="modules:PlayerInfoViewPoint">
<ListViewItem>
<StackPanel Margin="0 8 0 8" Orientation="Horizontal" Tapped="ViewPoint_OnTapped"
Background="Transparent">
<Image Source="{x:Bind ImgUrl}" Width="120"></Image>
<StackPanel Orientation="Vertical"
Margin="8 0 0 0"
Width="172">
<TextBlock Text="{x:Bind Content}"
TextWrapping="Wrap"></TextBlock>
<TextBlock>
<Run Text="{x:Bind From,Converter={StaticResource progress}}"></Run>
-
<Run Text="{x:Bind To,Converter={StaticResource progress}}"></Run>
</TextBlock>
</StackPanel>
</StackPanel>
</ListViewItem>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>

<Button x:Name="BtnFoucs" Width="0" Height="0" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="-8 -8 0 0" Background="Transparent" BorderThickness="0"></Button>
</Grid>
</SplitView>
Expand Down
24 changes: 23 additions & 1 deletion src/BiliLite.UWP/Controls/PlayerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,8 +1506,13 @@ private async Task GetPlayerInfo()
}
}

TopOnline.Text = await playerHelper.GetOnline(CurrentPlayItem.avid, CurrentPlayItem.cid);
if (player_info.ViewPoints != null && player_info.ViewPoints.Any())
{
m_viewModel.ViewPoints = player_info.ViewPoints;
m_viewModel.ShowViewPointsBtn = true;
}

TopOnline.Text = await playerHelper.GetOnline(CurrentPlayItem.avid, CurrentPlayItem.cid);
}

public async Task ReportHistory(double progress = double.NaN)
Expand Down Expand Up @@ -2914,5 +2919,22 @@ private void Player_SizeChanged(object sender, SizeChangedEventArgs e)
// 更新画面比例
Player.SetRatioMode(PlayerSettingRatio.SelectedIndex);
}

private void TopBtnViewPoints_OnClick(object sender, RoutedEventArgs e)
{
m_viewModel.ShowViewPointsView = true;
}

private void ViewPointsGrid_OnTapped(object sender, TappedRoutedEventArgs e)
{
m_viewModel.ShowViewPointsView = false;
}

private void ViewPoint_OnTapped(object sender, TappedRoutedEventArgs e)
{
if (!(sender is FrameworkElement element)) return;
if (!(element.DataContext is PlayerInfoViewPoint viewPoint)) return;
SetPosition(viewPoint.From);
}
}
}
22 changes: 22 additions & 0 deletions src/BiliLite.UWP/Modules/Player/PlayerVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,29 @@ public class PlayerInfo
/// 互动视频信息
/// </summary>
public InteractionModel interaction { get; set; }

/// <summary>
/// 章节看点信息
/// </summary>
[JsonProperty("view_points")]
public List<PlayerInfoViewPoint> ViewPoints { get; set; }
}

public class PlayerInfoViewPoint
{
public int Type { get; set; }

public long From { get; set; }

public long To { get; set; }

public string Content { get; set; }

public string ImgUrl { get; set; }

public string LogoUrl { get; set; }
}

public class PlayerOnlineInfo
{
public string total { get; set; }
Expand Down
7 changes: 7 additions & 0 deletions src/BiliLite.UWP/ViewModels/PlayControlViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using BiliLite.Models.Common;
using BiliLite.Services;
using BiliLite.Modules;

namespace BiliLite.ViewModels
{
Expand All @@ -13,5 +14,11 @@ public class PlayControlViewModel: BaseViewModel
public bool ShowVideoBottomVirtualProgressBar =>
SettingService.GetValue(SettingConstants.UI.SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR,
SettingConstants.UI.DEFAULT_SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR);

public bool ShowViewPointsView { get; set; }

public bool ShowViewPointsBtn { get; set; }

public List<PlayerInfoViewPoint> ViewPoints { get; set; }
}
}

0 comments on commit 20b7f8c

Please sign in to comment.