diff --git a/lib/mpv/player/platform/player_linux.dart b/lib/mpv/player/platform/player_linux.dart index ae0c5737..c18c97bd 100644 --- a/lib/mpv/player/platform/player_linux.dart +++ b/lib/mpv/player/platform/player_linux.dart @@ -2,11 +2,8 @@ import '../player_native.dart'; /// Linux implementation of [Player]. /// -/// Uses libmpv with OpenGL rendering via GtkGLArea. -/// The mpv video is rendered to a GtkGLArea positioned behind -/// the Flutter view using a GtkOverlay, with transparent regions -/// in the Flutter UI allowing the video to show through. +/// Uses libmpv with FlTextureGL — video is rendered to an offscreen FBO +/// and composited GPU-side via Flutter's Texture widget. class PlayerLinux extends PlayerNative { - @override - int? get textureId => null; // Uses GtkGLArea, not Flutter texture + // textureId is set during initialize() via PlayerNative } diff --git a/lib/mpv/player/player_native.dart b/lib/mpv/player/player_native.dart index 5c570c9f..b5e61824 100644 --- a/lib/mpv/player/player_native.dart +++ b/lib/mpv/player/player_native.dart @@ -6,9 +6,15 @@ import '../font_loader.dart'; import '../models.dart'; import 'player_base.dart'; -/// Shared native implementation of [Player] for iOS, macOS, and Android (MPV fallback). -/// Uses MPVKit via platform channels with Metal rendering (Apple) or native window (Android). +/// Shared native implementation of [Player] for iOS, macOS, Android (MPV fallback), and Linux. +/// Uses MPVKit via platform channels with Metal rendering (Apple), native window (Android), +/// or FlTextureGL (Linux). class PlayerNative extends PlayerBase { + int? _textureIdValue; + + @override + int? get textureId => _textureIdValue; + static const _methodChannel = MethodChannel('com.plezy/mpv_player'); static const _eventChannel = EventChannel('com.plezy/mpv_player/events'); @@ -32,8 +38,14 @@ class PlayerNative extends PlayerBase { if (initialized) return; try { - final result = await methodChannel.invokeMethod('initialize'); - initialized = result == true; + final result = await methodChannel.invokeMethod('initialize'); + if (result is int) { + // Linux: initialize returns the texture ID + _textureIdValue = result; + initialized = true; + } else { + initialized = result == true; + } if (!initialized) { throw Exception('Failed to initialize player'); } diff --git a/lib/mpv/video.dart b/lib/mpv/video.dart index 5389f9a0..f2cd2b09 100644 --- a/lib/mpv/video.dart +++ b/lib/mpv/video.dart @@ -74,7 +74,14 @@ class _VideoState extends State