diff --git a/lib/screens/video_player_screen.dart b/lib/screens/video_player_screen.dart index f1214be5..146e1f51 100644 --- a/lib/screens/video_player_screen.dart +++ b/lib/screens/video_player_screen.dart @@ -1154,7 +1154,13 @@ class VideoPlayerScreenState extends State with WidgetsBindin final isInPip = _videoPIPManager!.isPipActive.value; // Only handle exit - entry is handled by onBeforeEnterPip callback if (!isInPip) { + final restoreAmbient = _videoFilterManager!.hadAmbientLightingBeforePip; _videoFilterManager!.exitPipMode(); + // Restore ambient lighting if it was active before PiP + if (restoreAmbient) { + _videoFilterManager!.clearPipAmbientLightingFlag(); + _restoreAmbientLighting(); + } } } diff --git a/lib/services/video_filter_manager.dart b/lib/services/video_filter_manager.dart index 7eb43aa2..9ad1c732 100644 --- a/lib/services/video_filter_manager.dart +++ b/lib/services/video_filter_manager.dart @@ -26,6 +26,9 @@ class VideoFilterManager { /// Store the boxFitMode before entering PiP so it can be restored int? _prePipBoxFitMode; + /// Store whether ambient lighting was active before entering PiP + bool? _prePipAmbientLighting; + /// Ambient lighting service reference - when active, video-aspect-override is managed by ambient lighting AmbientLightingService? ambientLightingService; @@ -75,6 +78,11 @@ class VideoFilterManager { /// Force contain mode for PiP (no cropping/stretching) void enterPipMode() { + // Disable ambient lighting for PiP — it wastes space on blurred borders + if (ambientLightingService?.isEnabled == true) { + _prePipAmbientLighting = true; + ambientLightingService!.disable(); + } if (_boxFitMode != 0) { _prePipBoxFitMode = _boxFitMode; _boxFitMode = 0; // Contain mode @@ -91,6 +99,14 @@ class VideoFilterManager { } } + /// Whether ambient lighting was active before entering PiP + bool get hadAmbientLightingBeforePip => _prePipAmbientLighting == true; + + /// Clear the pre-PiP ambient lighting flag after restore + void clearPipAmbientLightingFlag() { + _prePipAmbientLighting = null; + } + /// Update player size when layout changes void updatePlayerSize(Size size) { // Check if size actually changed to avoid unnecessary updates