Remove subtitle from mpv when all lines are deleted#11659
Merged
Conversation
RefreshMpv returned early when the subtitle had zero paragraphs, so deleting all lines never told mpv to drop the previously loaded subtitle file - the last shown lines stayed visible on the video. Now clear the subtitle from mpv (SubRemove) and reset cached state when the subtitle becomes empty. Fixes #11658 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #11658.
When the user deletes all subtitle lines, the deleted subtitles still appear burned on the video (mpv player).
Root cause
MpvReloader.RefreshMpvreturned early when the subtitle had zero paragraphs:Deleting all lines correctly marks the preview dirty and the timer calls
RefreshMpv, but this early return means mpv is never told to drop the previously loaded subtitle file — so the last-shown lines stay visible.(Deleting some lines already worked, because the non-empty path regenerated and reloaded the subtitle file.)
Fix
Before returning on an empty subtitle, if a subtitle was previously loaded into mpv, call
SubRemove()to clear it from the video and reset the cached state (temp file, hash, old text, prev subtitle). The guard ensuresSubRemove()only runs when something was actually loaded, so it doesn't fire on every 400 ms timer tick when nothing is present.Testing
dotnet build src/ui/UI.csproj— 0 warnings / 0 errors.🤖 Generated with Claude Code