diff --git a/lib/services/video_pip_manager.dart b/lib/services/video_pip_manager.dart index 3746ded7..f462f79e 100644 --- a/lib/services/video_pip_manager.dart +++ b/lib/services/video_pip_manager.dart @@ -20,6 +20,25 @@ class VideoPIPManager { final supported = await PipService.isSupported(); if (!supported) return; - await PipService.enter(width: _playerSize?.width.toInt(), height: _playerSize?.height.toInt()); + // Try to get actual video dimensions from MPV + int? width; + int? height; + + try { + final dwidth = await player.getProperty('dwidth'); + final dheight = await player.getProperty('dheight'); + if (dwidth != null && dheight != null) { + width = int.tryParse(dwidth); + height = int.tryParse(dheight); + } + } catch (_) { + // Fall through to use viewport size + } + + // Fall back to viewport size if video dimensions unavailable + width ??= _playerSize?.width.toInt(); + height ??= _playerSize?.height.toInt(); + + await PipService.enter(width: width, height: height); } }