Play video in multiplayer room

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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

Tobias
2022-12-07 09:51:47

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...

Lingkail
2022-12-08 04:53:22

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?

Tobias
2022-12-21 15:11:29

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