VideoSurface Methods - Unity
SetVideo()
Manages video streams for both local and remote participants.
- 
For the Local Participant:
SetVideo(true): Enables the local webcam.SetVideo(false): Disables the local webcam.
 - 
For Remote Participants:
- 
SetVideo(true): Sends a request to the remote participant to enable their video.- The remote user receives an OnWebcamRequestedCallback event to accept/reject.
 
 - 
SetVideo(false): Disables the remote participant's video. 
 - 
 
Parameters
- 
status:
bool- Pass 
trueto enable the webcam. - Pass 
falseto disable the webcam. 
 - Pass 
 - 
CustomVideoStream:
object- 
Custom configuration for the stream settings. This parameter is optional.
- Default : 
videoEncoder=h240p_w320pfor Android & iOS. 
 - Default : 
 - 
Parameters:
- 
videoEncoder:
VideoEncoderConfig(Optional)- Default : 
h144p_w176pfor Android,h90p_w160pfor iOS 
 - Default : 
 - 
isMultiStream:
bool(Optional)- Default: 
true 
 - Default: 
 - 
videoDevice:
VideoDevice(Optional)- Default: Front camera
 
 
 - 
 
 - 
 
Note: The
customVideoStreamparameter is only available for local participants. If not provided, the default video configuration will be used.
Returns
void
Example
if (participant != null && participant.IsLocal)
{
    // Enable local webcam (default settings)
    participant.SetVideo(true);
    // To disable: participant.SetVideo(false);
    // To use custom settings:
    // CustomVideoStream customStream = new CustomVideoStream(VideoEncoderConfig.h720p_w1280p, false, selectedVideoDevice);
    // participant.SetVideo(true, customStream);
}
// --- Remote Participant ---
if (participant != null && !participant.IsLocal)
{
    // Request remote participant to enable their video
    participant.SetVideo(true);
    // To request disable: participant.SetVideo(false);
}
SetAudio()
Manages audio streams (microphone) for both local and remote participants.
- 
For the Local Participant:
SetAudio(true): Enables (unmutes) the local microphone.SetAudio(false): Disables (mutes) the local microphone.
 - 
For Remote Participants:
- 
SetAudio(true): Sends a request to the remote participant to enable their microphone.- The remote user receives an OnMicRequestedCallback event to accept/reject.
 
 - 
SetAudio(false): Disables the remote participant's microphone. 
 - 
 
Parameters
- status: 
bool- Pass 
trueto enable the microphone. - Pass 
falseto disable the microphone. 
 - Pass 
 
Returns
void
Example
// --- Local Participant ---
if (localParticipant != null && localParticipant.IsLocal)
{
    // Enable local microphone
    localParticipant.SetAudio(true);
    // To disable: localParticipant.SetAudio(false);
}
// --- Remote Participant ---
if (remoteParticipant != null && !remoteParticipant.IsLocal)
{
    // Request remote participant to enable their microphone
    remoteParticipant.SetAudio(true);
    // To request disable: remoteParticipant.SetAudio(false);
}
SetParticipant()
The SetParticipant() method is used to associate a specific participant with the VideoSurface. This allows the VideoSurface component to render video and manage stream events for that participant.
Parameters
- iParticipant: IParticipant
- The 
IParticipantobject containing the participant's ID and related information. 
 - The 
 
Returns
void
Example
// Called when a participant joins the meeting
private void OnParticipantJoined(IParticipant obj)
{
    Debug.Log("Participant Joined: " + obj.ParticipantName);
    // Instantiate a new video surface from prefab
    VideoSurface participant = Instantiate(_videoSurfacePrefab, _parent).GetComponentInChildren<VideoSurface>();
    // Specify that this surface uses RawImage for video rendering
    participant.SetVideoSurfaceType(VideoSurfaceType.RawImage);
    // Associate the participant with the video surface
    participant.SetParticipant(obj);
    // Enable stream rendering and callbacks
    participant.SetEnable(true);
}
SetVideoSurfaceType()
The SetVideoSurfaceType() method is used to define how the video stream will be rendered on the screen—either on a UI RawImage component or on a 3D Renderer component.
Parameters
- type: 
VideoSurfaceType- Specifies the rendering mode for the video stream.
Possible values:VideoSurfaceType.RawImage: Renders video on a UIRawImage(e.g., for canvas-based layouts).VideoSurfaceType.Renderer: Renders video on aRenderercomponent (e.g., for 3D objects).VideoSurfaceType.None: Disables video rendering.
 
 - Specifies the rendering mode for the video stream.
 
Returns
void
Usage
Call this method to explicitly configure the rendering type before associating a participant or setting a texture.
Example
// Called when a participant joins the meeting
private void OnParticipantJoined(IParticipant obj)
{
    Debug.Log("Participant Joined: " + obj.ParticipantName);
    // Instantiate a new video surface from prefab
    VideoSurface participant = Instantiate(_videoSurfacePrefab, _parent).GetComponentInChildren<VideoSurface>();
    // Specify that this surface uses RawImage for video rendering
    participant.SetVideoSurfaceType(VideoSurfaceType.RawImage);
    // Associate the participant with the video surface
    participant.SetParticipant(obj);
    // Enable stream rendering and callbacks
    participant.SetEnable(true);
}
SetEnable()
The SetEnable() method is used to enable or disable video rendering and associated participant stream callbacks on the VideoSurface.
Parameters
- status: 
bool- Pass 
trueto enable rendering and register stream callbacks. - Pass 
falseto stop rendering, unregister callbacks, and release the associated texture. 
 - Pass 
 
Returns
void
Usage
Use this method after calling SetParticipant() to start or stop stream rendering and event handling.
Example
// Called when a participant joins the meeting
private void OnParticipantJoined(IParticipant obj)
{
    Debug.Log("Participant Joined: " + obj.ParticipantName);
    // Instantiate a new video surface from prefab
    VideoSurface participant = Instantiate(_videoSurfacePrefab, _parent).GetComponentInChildren<VideoSurface>();
    // Specify that this surface uses RawImage for video rendering
    participant.SetVideoSurfaceType(VideoSurfaceType.RawImage);
    // Associate the participant with the video surface
    participant.SetParticipant(obj);
    // Enable stream rendering and callbacks
    participant.SetEnable(true);
}
PauseStream()
The PauseStream() method is used to pause a specific type of media stream (audio or video) for a remote participant.
Parameters
- kind: 
StreamKind- The type of stream to pause.
Possible values:StreamKind.AUDIOStreamKind.VIDEO
 
 - The type of stream to pause.
 
Returns
void
Example
// Pause the remote participant's audio stream
if (!participant.IsLocal)
{
    participant.PauseStream(StreamKind.AUDIO);
}
ResumeStream()
The ResumeStream() method is used to resume a specific type of media stream (audio or video) from a remote participant.
Parameters
- kind: 
StreamKind- The type of stream to resume.
Possible values:StreamKind.AUDIOStreamKind.VIDEO
 
 - The type of stream to resume.
 
Returns
void
Example
if (!participant.IsLocal)
{
    participant.ResumeStream(StreamKind.AUDIO);
}
Remove()
- It is used to remove a participant from the meeting.
 
Returns
void
Example
participant.Remove();
Got a Question? Ask us on discord

