Skip to content

Commit

Permalink
fix main() is not executed when debugging #125 #183
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Dec 21, 2024
1 parent 4c107cd commit 2e2ad8a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/src/video_player_mdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ class MdkVideoPlayerPlatform extends VideoPlayerPlatform {
_decoders = vd[Platform.operatingSystem];
}

// delay: ensure log handler is set in main(), blank window if run with debugger.
// registerWith() can be invoked by dart_plugin_registrant.dart before main. when debugging, won't enter main if posting message from native to dart(new native log message) before main?
Future.delayed(const Duration(milliseconds: 0), () {
_setupMdk();
});

_prevImpl ??= VideoPlayerPlatform.instance;
VideoPlayerPlatform.instance = MdkVideoPlayerPlatform();
}

static void _setupMdk() {
mdk.setLogHandler((level, msg) {
if (msg.endsWith('\n')) {
msg = msg.substring(0, msg.length - 1);
Expand Down Expand Up @@ -190,10 +201,6 @@ class MdkVideoPlayerPlatform extends VideoPlayerPlatform {
_globalOpts?.forEach((key, value) {
mdk.setGlobalOption(key, value);
});

// if VideoPlayerPlatform.instance.runtimeType.toString() != '_PlaceholderImplementation' ?
_prevImpl ??= VideoPlayerPlatform.instance;
VideoPlayerPlatform.instance = MdkVideoPlayerPlatform();
}

@override
Expand Down

0 comments on commit 2e2ad8a

Please sign in to comment.