Skip to content

Feat: auto-copy subtitles to clipboard#3705

Open
SecretX33 wants to merge 3 commits intoclsid2:developfrom
SecretX33:subtitles
Open

Feat: auto-copy subtitles to clipboard#3705
SecretX33 wants to merge 3 commits intoclsid2:developfrom
SecretX33:subtitles

Conversation

@SecretX33
Copy link

@SecretX33 SecretX33 commented Dec 26, 2025

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.

  1. Go to Options → Keys
  2. Find "Auto-Copy Subtitle to ClipboardClipboard"
  3. Assign a hotkey
  4. Press the hotkey during playback to toggle (OSD shows On/Off status)

How I implemented it

The implemention uses SearchSubs() to find current subtitle segment, extracts text via GetStrW() (stripping SSA by passing false to this function do some minor HTML tag stripping after), before copying the result to the clipboard. It acquires the m_csSubLock lock 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

  • I hardcoded 25 as the FPS of the current file when calling SearchSubs, since I didn't know exactly how to get it from the player.
  • I'm also not sure if the logic I added should actually be somewhere else and just invoked in that place or not.
  • I saw that the code acquires the lock m_csSubLock (subtitle lock) on OnGetSubtitles function before interacting with pRTS. I'm not sure if locking was necessary in the new logic I added, but just to be safe I added it there.
  • Should I have added an option in the options menu to enable/disable this feature, or is it too niche to be worth it and keeping it as a "keybind-only option" is fine?
  • When I tried running the sync.bat script 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.
  • When commiting, Git or my IDE updated some lines that apparently had different line breaks, so that is why there are some "empty lines/no change lines" in the changes. Yes, I did set git config core.autocrlf true before 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.

@clsid2 clsid2 closed this Dec 26, 2025
@clsid2 clsid2 reopened this Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants