Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

修复按下空格键有时无法播放/暂停的问题 #870

Merged
merged 2 commits into from
Mar 21, 2022
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 @@ -65,6 +65,7 @@ public partial class BiliPlayerTransportControls
private DispatcherTimer _danmakuTimer;
private DispatcherTimer _cursorTimer;
private DispatcherTimer _normalTimer;
private DispatcherTimer _focusTimer;
private DanmakuView _danmakuView;
private ToggleButton _fullWindowPlayModeButton;
private ToggleButton _fullScreenPlayModeButton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public BiliPlayerTransportControls()
InitializeDanmakuTimer();
InitializeCursorTimer();
InitializeNormalTimer();
InitializeFocusTimer();

_normalTimer.Start();
_focusTimer.Start();
}

/// <summary>
Expand Down Expand Up @@ -406,6 +408,8 @@ private void CheckCurrentPlayerMode()
default:
break;
}

_playPauseButton.Focus(FocusState.Programmatic);
}

private void OnDanmakuListAdded(object sender, List<DanmakuElem> e)
Expand Down Expand Up @@ -510,6 +514,8 @@ private async void OnPlaybackStateChangedAsync(MediaPlaybackSession sender, obje
_danmakuView.ResumeDanmaku();
Hide();
}

_playPauseButton.Focus(FocusState.Programmatic);
});
}

Expand Down Expand Up @@ -548,6 +554,16 @@ private void InitializeNormalTimer()
}
}

private void InitializeFocusTimer()
{
if (_focusTimer == null)
{
_focusTimer = new DispatcherTimer();
_focusTimer.Interval = TimeSpan.FromSeconds(5);
_focusTimer.Tick += OnFocusTimerTick;
}
}

private void InitializeDanmaku(List<DanmakuElem> elements)
{
var list = new List<DanmakuModel>();
Expand Down Expand Up @@ -759,6 +775,14 @@ private void OnNormalTimerTick(object sender, object e)
}
}

private void OnFocusTimerTick(object sender, object e)
{
if (ViewModel.PlayerDisplayMode != PlayerDisplayMode.Default)
{
_playPauseButton.Focus(FocusState.Programmatic);
}
}

private void OnInteractionControlManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
_manipulationVolume = 0;
Expand Down