Not so long ago I had the need to synchronize video on two computers. Googling ready solutions did nothing, so I decided to implement this service on my own. The
VLC program was selected as the video viewer. I decided to share the results of work with you. I think that there will be people to whom this program will be useful.
Why is it needed?
- You want to watch a movie with friends / acquaintances together, but it's too lazy to go to each other or to the cinema.
- It is necessary to display the same video on multiple monitors connected to different computers.
- You need to control the video playback remotely.
How it works?
The program consists of two parts: client and server. The server part runs on one of the computers and plays the role of an echo server with a small feature: messages received from one of the clients are sent to all connected clients except himself. The client part, in turn, runs on each computer with a working vlc player and controls the operation of the vlc on the one hand and communicates with the server on the other. If a user clicks a pause on one of the computers, the client part processes this event and immediately sends it to the server. The server sends this event to all other clients and on other computers, playback also stops. A similar process occurs during a run to play or rewind.
You can also join the server using a regular telnet client and control playback using the console, sending certain commands to the server. The commands are as follows:
1. pause - pauses playback
2. start - starts playback from the current moment.
3. seek - changes the current position to N milliseconds from the beginning (example: seek 60000)
4. play - starts playback starting at the position of N milliseconds from the beginning.
')
The programs require a Linux family of operating systems or Cygwin under Windows with the glib-2.0 and dbus-glib-1 libraries installed.
How to start?
Yes, very simple:
./server 0.0.0.0 9888
./client 192.168.0.5 9888
Where 0.0.0.0 is the address of the network interface (in this case, all interfaces) on which the server will be running, 192.168.0.5 is the address of the server, 9888 is the port (any other can be specified, but the same one). Any of the applications can be regularly stopped using the Ctrl + C combination. If for some reason the client program does not start, check whether the server is running (as well as the correctness of its address) and the vlc player. If everything started, you can safely open the desired video on computers and press play on any of them.
Also in the vlc, you must enable the ability to control via d-bus. This is done here: Tools -> Settings -> Show Settings: All -> Interface -> Controls -> Tick on “d-bus control interface”. You may need to restart vlc.
Download the source code
here , the compiled version
here .