Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复岛播放器初始化时的父窗口选择 #709

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace BiliCopilot.UI.Controls.Core;
/// </summary>
public sealed partial class IslandPlayer : LayoutControlBase<IslandPlayerViewModel>
{
private readonly Window _parentWindow;
private Window _parentWindow;
private MpvPlayerWindow _playerWindow;
private MpvPlayerOverlayWindow _overlayWindow;
private double _scale;
Expand All @@ -27,7 +27,6 @@ public sealed partial class IslandPlayer : LayoutControlBase<IslandPlayerViewMod
public IslandPlayer()
{
DefaultStyleKey = typeof(IslandPlayer);
_parentWindow = this.Get<AppViewModel>().ActivatedWindow;
}

/// <summary>
Expand Down Expand Up @@ -57,6 +56,7 @@ protected override void OnApplyTemplate()
/// <inheritdoc/>
protected override async void OnControlLoaded()
{
_parentWindow = ViewModel.AttachedWindow;
InitializeLayoutPoints();
if (_playerWindow is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ public abstract partial class PlayerViewModelBase
/// 视频标题.
/// </summary>
public string Title { get; set; }

/// <summary>
/// 播放器关联的窗口.
/// </summary>
public Window AttachedWindow { get; set; }
}
#pragma warning restore SA1600 // Elements should be documented
#pragma warning restore SA1401 // Fields should be private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public Task CloseAsync()
{
IsPaused = true;
_isClosed = true;
AttachedWindow = default;
if (_smtc is not null)
{
_smtc.DisplayUpdater.ClearAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ protected PlayerPageViewModelBase()
PlayerType.Island => new IslandPlayerViewModel(),
_ => new NativePlayerViewModel(),
};

Player.AttachedWindow = this.Get<AppViewModel>().ActivatedWindow;
}
}
Loading