user15995014
user15995014

Reputation:

Syncing HTML5 Vidoes Between Devices

So I am using video.js as my video player on my website, but was curious if there was a way (either using video.js or another video player) to be able to sync a video between all devices on the website?

For example, if Person A, Person B and Person C is viewing this video on my website, it would sync their video up so they are at the same time, and if either of them pauses then all three people see their video pause? A lot like Netflix Party / Youtube Party for videos. I am quite new to JS

Upvotes: 0

Views: 728

Answers (1)

reticivis
reticivis

Reputation: 616

It's possible to set and read the current time of a video in JavaScript with HTMLMediaElement.currentTime. You can also play/pause and check if its playing with either the paused attribute or the pause/play events.

You will need some form of backend to keep track of when all of this happens and to relay the appropriate time/events to everyone watching which is outside the scope of basic DOM JS (though there are JS based backends if that's your thing).

You'll probably need some form of live two-way connection like a websocket.

Upvotes: 1

Related Questions