fix(android): guard desktop fullscreen calls

This commit is contained in:
edde746
2026-05-24 07:22:56 +02:00
parent dcd0b03096
commit f1a02ade17
3 changed files with 18 additions and 12 deletions
@@ -102,7 +102,7 @@ extension _VideoPlayerCompanionRemoteMethods on VideoPlayerScreenState {
void _cycleAudioTrack() => _trackManager?.cycleAudioTrack();
Future<void> _toggleFullscreen() async {
if (PlatformDetector.isMobile(context)) return;
if (!PlatformDetector.isDesktopOS()) return;
await FullscreenStateManager().toggleFullscreen();
}
}
@@ -28,6 +28,8 @@ class FullscreenStateManager extends ChangeNotifier with WindowListener {
/// Toggle fullscreen state, handling maximized-to-fullscreen transition on Windows/Linux
Future<void> toggleFullscreen() async {
if (!PlatformDetector.isDesktopOS()) return;
if (Platform.isMacOS) {
final isCurrentlyFullscreen = await MacOSWindowService.isFullscreen();
if (isCurrentlyFullscreen) {
@@ -62,6 +64,8 @@ class FullscreenStateManager extends ChangeNotifier with WindowListener {
/// Enter fullscreen, preserving maximized state on Windows/Linux for restoration on exit.
Future<void> enterFullscreen() async {
if (!PlatformDetector.isDesktopOS()) return;
if (Platform.isMacOS) {
await MacOSWindowService.enterFullscreen();
} else if (Platform.isWindows) {
@@ -77,6 +81,8 @@ class FullscreenStateManager extends ChangeNotifier with WindowListener {
/// Exit fullscreen, restoring maximized state if needed
Future<void> exitFullscreen() async {
if (!PlatformDetector.isDesktopOS()) return;
if (Platform.isMacOS) {
await MacOSWindowService.exitFullscreen();
} else if (Platform.isWindows) {
@@ -293,14 +293,14 @@ extension _PlexVideoControlsVisibilityMethods on _PlexVideoControlsState {
}
Future<void> _toggleFullscreen() async {
if (!PlatformDetector.isMobile(context)) {
await FullscreenStateManager().toggleFullscreen();
}
if (!PlatformDetector.isDesktopOS()) return;
await FullscreenStateManager().toggleFullscreen();
}
/// Exit fullscreen if the window is actually fullscreen (async check).
/// Used by ESC handler on Windows/Linux to avoid relying on _isFullscreen flag.
Future<void> _exitFullscreenIfNeeded() async {
if (!Platform.isWindows && !Platform.isLinux) return;
if (await windowManager.isFullScreen()) {
await FullscreenStateManager().exitFullscreen();
}
@@ -318,14 +318,14 @@ extension _PlexVideoControlsVisibilityMethods on _PlexVideoControlsState {
/// Toggle always-on-top window mode (desktop only)
Future<void> _toggleAlwaysOnTop() async {
if (!PlatformDetector.isMobile(context)) {
final newValue = !_isAlwaysOnTop;
await windowManager.setAlwaysOnTop(newValue);
if (!mounted) return;
_setControlsState(() {
_isAlwaysOnTop = newValue;
});
}
if (!PlatformDetector.isDesktopOS()) return;
final newValue = !_isAlwaysOnTop;
await windowManager.setAlwaysOnTop(newValue);
if (!mounted) return;
_setControlsState(() {
_isAlwaysOnTop = newValue;
});
}
/// Show controls and optionally focus play/pause on keyboard input (desktop only)