fix(player): spacebar unpause no longer plays first episode

This commit is contained in:
edde746
2025-12-30 20:12:14 +01:00
parent 8b89529ac8
commit b36e585fd7
2 changed files with 14 additions and 12 deletions
+5 -1
View File
@@ -41,6 +41,8 @@ class _SeasonDetailScreenState extends State<SeasonDetailScreen> with ItemUpdata
List<PlexMetadata> _episodes = [];
bool _isLoadingEpisodes = false;
bool _watchStateChanged = false;
// Capture keyboard mode once at init to avoid rebuild dependency
bool _initialKeyboardMode = false;
/// Get the correct PlexClient for this season's server
PlexClient? _getClientForSeason(BuildContext context) {
@@ -55,6 +57,8 @@ class _SeasonDetailScreenState extends State<SeasonDetailScreen> with ItemUpdata
super.initState();
// Initialize the client once in initState
WidgetsBinding.instance.addPostFrameCallback((_) {
// Capture keyboard mode once to avoid rebuild dependency when mode changes
_initialKeyboardMode = InputModeTracker.isKeyboardMode(context);
_client = _getClientForSeason(context);
_loadEpisodes();
});
@@ -165,7 +169,7 @@ class _SeasonDetailScreenState extends State<SeasonDetailScreen> with ItemUpdata
client: _client,
isOffline: widget.isOffline,
localPosterPath: localPosterPath,
autofocus: index == 0 && InputModeTracker.isKeyboardMode(context),
autofocus: index == 0 && _initialKeyboardMode,
onTap: () async {
await navigateToVideoPlayerWithRefresh(
context,
+9 -11
View File
@@ -1237,18 +1237,16 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
final key = event.logicalKey;
final isPlayPauseKey = _isPlayPauseKey(event);
// Handle play/pause via focus when navigation is enabled (TV/gamepad)
// When navigation is disabled, the global handler (_handleGlobalKeyEvent) handles it
if (_videoPlayerNavigationEnabled || isMobile) {
if (_isPlayPauseActivation(event)) {
widget.player.playOrPause();
_showControlsWithFocus(requestFocus: _videoPlayerNavigationEnabled);
return KeyEventResult.handled;
}
// Swallow other play/pause events (e.g., key up/repeat) to prevent focus side effects
if (isPlayPauseKey) {
return KeyEventResult.handled;
// Always consume play/pause keys to prevent propagation to background routes
// On TV/mobile, handle play/pause here; on desktop, the global handler does it
if (isPlayPauseKey) {
if (_videoPlayerNavigationEnabled || isMobile) {
if (_isPlayPauseActivation(event)) {
widget.player.playOrPause();
_showControlsWithFocus(requestFocus: _videoPlayerNavigationEnabled);
}
}
return KeyEventResult.handled;
}
// Handle Back/Escape: show controls if hidden, navigate back if visible