Play video in multiplayer room
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Play video in multiplayer room
Lingkail
2022-12-07 08:17:05
Below are the video script, when I joining with others player in a same room, and I play the video in a screen, but it only can view in my own side and the others player can't view it.
It that Photon Pun 2 support this function?
Or I need to make some changes in the script. Please help me, thank you.
// Examples of VideoPlayer function
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//using UnityEditor;
using UnityEngine.Video;
using SFB;
using System;
public class Video : MonoBehaviour
{
public void OnFileSelectButtonDown()
{
string [] FilePath = OpenFile();
var vp = GetComponent<VideoPlayer>();
if (vp.isPlaying)
vp.Stop();
vp.url = "file://" + FilePath[0];
vp.Play();
}
public string [] OpenFile()
{
//string [] FilePath;
var extensions = new[]
{
new ExtensionFilter("Movie Files", "mp4", "mov", "avi"),
};
var FilePath = StandaloneFileBrowser.OpenFilePanel("Select Movie File", "", extensions, true);
return FilePath;
}
}
Comments
You could (e.g.) send an event to tell others to show the video, too. This would be the "networking" part of playing a video for everyone in a room...
Tobias 2022-12-07T09:51:47+00:00
You could (e.g.) send an event to tell others to show the video, too. This would be the "networking" part of playing a video for everyone in a room...
Sorry... I still cannot get it. Is it means that I need to implement the RaiseEvent method in it?
Sorry for the late reply.
You need to somehow signal the action to everyone in the room. Via the network.
Pressing a button is still something you do locally in Unity, even if you added PUN or any other networking solution. It does not sync everything magically.
The few things you need to signal to others need to be added into your code and the receivers of such events need to react accordingly.
Back to top