Feat: auto-copy subtitles to clipboard#3705
Open
SecretX33 wants to merge 3 commits intoclsid2:developfrom
Open
Feat: auto-copy subtitles to clipboard#3705SecretX33 wants to merge 3 commits intoclsid2:developfrom
SecretX33 wants to merge 3 commits intoclsid2:developfrom
Conversation
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.
Summary
Adds a toggleable feature that automatically copies the current subtitle line to the system clipboard when it changes during playback. Useful for language learning workflows with tools like Clipboard Inserter.
How to enable it
By default, the new feature has no default keybind to minimize impact. Users that want to use this feature can perform the following steps.
How I implemented it
The implemention uses
SearchSubs()to find current subtitle segment, extracts text viaGetStrW()(stripping SSA by passingfalseto this function do some minor HTML tag stripping after), before copying the result to the clipboard. It acquires them_csSubLocklock before reading the current subtitle text (read notes).Notes
I tried to follow existing coding standards and patterns as much as possible, but I'm not a C++ expert so there is most likely things I could have done better. If you spot any issues or points that I can improve, please let me know.
Things I'm unsure about and/or might need to change
25as the FPS of the current file when callingSearchSubs, since I didn't know exactly how to get it from the player.m_csSubLock(subtitle lock) onOnGetSubtitlesfunction before interacting withpRTS. I'm not sure if locking was necessary in the new logic I added, but just to be safe I added it there.sync.batscript to sync the resources, it erased all their data for some reason, keeping only the first ~20 lines of each resource file. I have no idea why this happened, so I reverted its changes.git config core.autocrlf truebefore creating the commits.Video
I recorded a short video showing the feature in action.
https://www.youtube.com/watch?v=hA3oJpeMTNE
History
I'm opening this PR to add a feature that I've personally been missing in MPC-HC for a long time.
881 days ago, I opened an issue requesting this feature I didn't have enough C++ knowledge to develop. Now I've have gathered enough knowledge to be able to code it myself.
This feature existed in some other video players, but MPC-HC is the one I like the most and the one I'm most familiar with. I thought it'd make sense to not only add this feature to MPC-HC in a personal build, but also share it so others people that are learning other languages like me can also use it instead of having to fallback to other (inferior) video players.