From b503517552a877f11fa0face35bbeed57d03ea49 Mon Sep 17 00:00:00 2001 From: Predidit <34627277+Predidit@users.noreply.github.com> Date: Wed, 22 Jul 2026 18:14:38 +0800 Subject: [PATCH] draft --- .../lib/src/player/native/player/real.dart | 6 ++++- media_kit/test/src/player/player_test.dart | 23 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/media_kit/lib/src/player/native/player/real.dart b/media_kit/lib/src/player/native/player/real.dart index 5363cf541..31b96b45f 100644 --- a/media_kit/lib/src/player/native/player/real.dart +++ b/media_kit/lib/src/player/native/player/real.dart @@ -2328,6 +2328,11 @@ class NativePlayer extends PlatformPlayer { // Set --vid=no by default to prevent redundant video decoding. // [VideoController] internally sets --vid=auto upon attachment to enable video rendering & decoding. if (!test) 'vid': 'no', + // The OSC is a built-in Lua script and may be unavailable in libmpv + // builds compiled without Lua. Set it as an initialization option so + // supported builds disable it before scripts are loaded, while builds + // without the option can safely ignore it. + if (!configuration.osc) 'osc': 'no', }; if (Platform.isAndroid && @@ -2423,7 +2428,6 @@ class NativePlayer extends PlatformPlayer { properties.addAll( { if (!configuration.osc) ...{ - 'osc': 'no', 'osd-level': '0', }, 'title': configuration.title, diff --git a/media_kit/test/src/player/player_test.dart b/media_kit/test/src/player/player_test.dart index 30e711179..47a92bdc3 100644 --- a/media_kit/test/src/player/player_test.dart +++ b/media_kit/test/src/player/player_test.dart @@ -101,6 +101,29 @@ void main() { addTearDown(player.dispose); }, ); + test( + 'player-configuration-osc-disabled-does-not-log-property-not-found', + () async { + final player = Player( + configuration: const PlayerConfiguration(osc: false), + ); + var hasOscPropertyError = false; + final subscription = player.stream.log.listen((event) { + if (event.text.contains('_setProperty(osc')) { + hasOscPropertyError = true; + } + }); + + await player.platform?.waitForPlayerInitialization; + await Future.delayed(Duration.zero); + + expect(hasOscPropertyError, isFalse); + + await subscription.cancel(); + await player.dispose(); + }, + skip: UniversalPlatform.isWeb, + ); test( 'player-open-playable-media', () async {