Keep two VLC players in sync during pause, seek forward/back etc.
| ␣ | spacebar |
pause both |
| ← | left arrow |
jump back 10 sec |
| → | right arrow |
jump fwd 10 sec |
| fn | fn key |
sync your local video's playtime to match the other computer's |
| ` | backtick |
push your local video's playtime to the other computer |
- Git clone this repo down to both computers.
- Duplicate the
.env.local.TEMPLATEfile into.env.local(dropping.TEMPLATE). - Turn on VLC HTTP Interface (see Step 1 below), set the password, and update
VLC_PASSWORDin your.env.local. Probably need to restart VLC after turning the HTTP interface on for the first time. - Make sure you have
buninstalled to run the script. - Install the js dependencies with
bun install. - Get the other device's local IP address: each device's IP prints to the console (🟡
yellow) whenever the script starts. SetOTHER_IPin.env.local. - Start the script with
bun run script.ts.
Another way to get device's local IP on Macs: Wifi button in Mac menu bar -> "Wifi Settings" -> Details, scroll to bottom.
This is a node script to listen for keyboard events and send commands to VLC on both laptops.
VLC Media Player includes a feature called VLC HTTP interface, which can be used to control VLC remotely. This interface allows you to send commands to VLC via HTTP requests, making it possible to play, pause, seek, and perform other actions from a remote application or script.
Here's a high-level overview of this synchronization solution:
First, ensure that the HTTP interface is enabled on both instances of VLC.
- Open VLC.
- Go to Tools > Preferences (or VLC > Preferences on Mac).
- Show settings: All.
- Under Interface, select Main interfaces and ensure that the Web checkbox is checked.
- Expand the Main interfaces option and select Lua.
- Set the Lua HTTP. Password to something you'll remember (this is required for remote control).
Find out the IP addresses of both computers on your local network. This is needed to send commands to VLC from one device to another.
This script listens for spacebar, left arrow, and right arrow key presses to control play/pause and seek operations on VLC. It sends the commands to both VLC instances running on the specified IP addresses.
- Make sure you replace
'your_vlc_password'with the actual password you've set for the VLC HTTP interface. - Update the OTHER_IP address to match the other device.
- This script uses global key hooks, which means it will respond to these keys regardless of which application is currently focused. Be mindful of this when running the script.
- Ensure VLC is configured correctly on both laptops to accept commands via its HTTP interface, as described in the previous VLC setup steps.
This script offers a flexible and efficient way to synchronize video playback controls across multiple devices, utilizing familiar keyboard shortcuts.
