From 06d69a5fce6ffbd13e8985dbbef88386f93439c7 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Tue, 27 Jan 2026 16:16:16 +0100 Subject: [PATCH] fix: COMMAND_FAILED error on videos with external subtitles --- lib/screens/video_player_screen.dart | 6 +++++- windows/runner/mpv/mpv_plugin.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/screens/video_player_screen.dart b/lib/screens/video_player_screen.dart index 4befef04..cfc3f20e 100644 --- a/lib/screens/video_player_screen.dart +++ b/lib/screens/video_player_screen.dart @@ -814,7 +814,11 @@ class VideoPlayerScreenState extends State with WidgetsBindin if (player != null && mounted) { await player!.play(); final pos = player!.state.position; - await player!.seek(pos.inMilliseconds > 0 ? pos : Duration.zero); + try { + await player!.seek(pos.inMilliseconds > 0 ? pos : Duration.zero); + } catch (e) { + appLogger.w('Non-critical seek after subtitle load failed', error: e); + } // Fallback if playbackRestart doesn't fire Future.delayed(const Duration(seconds: 3), () { diff --git a/windows/runner/mpv/mpv_plugin.cpp b/windows/runner/mpv/mpv_plugin.cpp index 0c7fff87..6f07f97a 100644 --- a/windows/runner/mpv/mpv_plugin.cpp +++ b/windows/runner/mpv/mpv_plugin.cpp @@ -208,9 +208,11 @@ void MpvPlayerPlugin::HandleMethodCall( // Use async command to prevent UI blocking during network operations // Move result into shared_ptr for safe capture in callback auto result_ptr = std::make_shared>>(std::move(result)); - player_->CommandAsync(command_args, [result_ptr](int error) { + std::string cmd_name = command_args.empty() ? "unknown" : command_args[0]; + player_->CommandAsync(command_args, [result_ptr, cmd_name](int error) { if (error < 0) { - (*result_ptr)->Error("COMMAND_FAILED", "MPV command failed"); + (*result_ptr)->Error("COMMAND_FAILED", + "MPV command failed: " + cmd_name + " (error " + std::to_string(error) + ")"); } else { (*result_ptr)->Success(); }