Skip to content

Commit

Permalink
修复 AOT 遗留问题(搜索用户失败 / 原生播放器崩溃) (#986)
Browse files Browse the repository at this point in the history
* 修复 AOT 残留问题

* 修复原生播放器崩溃的问题
  • Loading branch information
Richasy authored Jan 23, 2025
1 parent 05b60ec commit be46c55
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@
<PropertyGroup>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">False</PublishReadyToRun>
<PublishAot Condition="'$(Configuration)' == 'Debug'">False</PublishAot>
<PublishAot Condition="'$(Configuration)' == 'Debug'">True</PublishAot>
<PublishAot Condition="'$(Configuration)' != 'Debug'">True</PublishAot>
<ApplicationIcon>Assets\logo.ico</ApplicationIcon>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ protected async override void OnControlLoaded()

/// <inheritdoc/>
protected override void OnApplyTemplate()
=> _playerElement = (MediaPlayerElement)GetTemplateChild("PlayerElement");
{
var rootGrid = GetTemplateChild("RootGrid") as Grid;
_playerElement = new MediaPlayerElement();
_playerElement.HorizontalAlignment = HorizontalAlignment.Stretch;
_playerElement.VerticalAlignment = VerticalAlignment.Stretch;
_playerElement.AreTransportControlsEnabled = false;
rootGrid.Children.Add(_playerElement);
}

/// <inheritdoc/>
protected override async void OnViewModelChanged(NativePlayerViewModel? oldValue, NativePlayerViewModel? newValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:NativePlayer">
<Grid Background="Black">
<MediaPlayerElement
x:Name="PlayerElement"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AreTransportControlsEnabled="False" />
</Grid>
<Grid x:Name="RootGrid" Background="Black" />
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<ItemsRepeater ItemsSource="{x:Bind ViewModel.Items, Mode=OneWay}" Layout="{StaticResource UserLayout}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="items:UserItemViewModel">
<components:UserCardControl Style="{StaticResource DefaultUserCardStyle}" ViewModel="{x:Bind}" />
<components:UserCardControl ViewModel="{x:Bind}" />
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected override async Task OnLoadPlayDataAsync()
await LoadDashVideoSourceAsync();
}

_element.SetMediaPlayer(Player);
_element?.SetMediaPlayer(Player);
}

/// <inheritdoc/>
Expand Down

0 comments on commit be46c55

Please sign in to comment.