diff --git a/lib/mpv/player/player_native.dart b/lib/mpv/player/player_native.dart index 96fb3506..eceaafcf 100644 --- a/lib/mpv/player/player_native.dart +++ b/lib/mpv/player/player_native.dart @@ -1,5 +1,7 @@ +import 'dart:async'; import 'dart:io' show Platform; +import 'package:flutter/widgets.dart'; import 'package:flutter/services.dart'; import '../models.dart'; @@ -99,6 +101,14 @@ class PlayerNative extends PlayerBase { // Show the video layer await setVisible(true); + // Linux: wait one frame so texture populate() runs and creates MPV render context before loadfile. + if (Platform.isLinux) { + WidgetsBinding.instance.scheduleFrame(); + final c = Completer(); + WidgetsBinding.instance.addPostFrameCallback((_) => c.complete()); + await c.future; + } + // Set HTTP headers for Plex authentication and profile if (media.headers != null && media.headers!.isNotEmpty) { final headerList = media.headers!.entries.map((e) => '${e.key}: ${e.value}').toList();