How to make a video play in a multiplayer lobby?
I am trying to make something like a movie theater using photon and I need help with how to make a video clip play in a multiplayer lobby so that all participants see the same thing at the same time.
Answer by GetLitGames · Mar 16 at 02:08 PM
Unity has a VideoPlayer that you can use. It will render onto a material or render texture. It will take a URL but not a YouTube URL unfortunately because YouTube blocks that type of usage. The VideoPlayer has a property that you can set the current position of the video from the start of the video in milliseconds (or some similarly small measurement). You just need to send an RPC to all the clients with a string of the URL to start the videos playing. It is more complicated than that because of network delays. Once the video has started playing, you will want the Master Client to send another RPC to the clients shortly thereafter telling them what position it is currently at and along with a UTC time stamp (something that includes milliseconds). The clients receiving the message will look at the video position sent by the Master Client and calculate the UTC time difference from the timestamp sent along with the RPC to then set the current position of it's local Video Player to be the same as the Master Client's video position. The Master Client should keep sending that same RPC message every so often (once a minute or so) telling the clients it's position and the clients only need to apply it if they see that they are outside of a range of time (maybe half a second or something) because you don't want to make the video stutter from constant updates - as long as you are within a certain time delta of less than a second you don't want to do anything.
Thank you so much for helping me out. Can you please explain a bit about "sending an RPC", its my first time working with multiplayer and videos
Just sending an RPC is pretty simple if you use the example in the documenation. I'm not sure how far you are using Photon but you will need to download PUN2 and read the documentation since there would be a lot to learn in order to get your multiplayer working. I recommend doing their tutorials. https://doc.photonengine.com/en-us/pun/current/gameplay/rpcsandraiseevent
Well this is my first time working with photon so I didn't know, than you for providing the links
Your answer
Follow this Question
Related Questions
IK Is Not Working in a Multiplayer App Using Final IK/VRIK 0 Answers
PhotonOnSerializeView() Only working sometimes 0 Answers
Multiplayer Photon ERROR!!! 0 Answers
[HELP]Player pick-up with Photon 0 Answers
PhotonMono spawns instead of player. 0 Answers