TRTCMediaMixingManager

TRTCMediaMixingManager

Local media mixing manager

Constructor

new TRTCMediaMixingManager()

Methods

setDisplayParams(windowID, region)

Set preview parameters for mixed-stream video

Examples
// Display in HTML Element
import TRTCCloud from 'trtc-electron-sdk';

const trtcCloud = TRTCCloud.getTRTCShareInstance({
  isIPCMode: true
});

const mediaMixingManager = trtcCloud.getMediaMixingManager();

const windowID = 0; // Use Electron API BrowserWindow.getNativeWindowHandle()
const previewDOM = document.getElementById("preview-local-mixed-media-stream");
mediaMixingManager.setDisplayParams(windowID, previewDOM);
// Display in a rectangle section
import TRTCCloud from 'trtc-electron-sdk';

const trtcCloud = TRTCCloud.getTRTCShareInstance({
  isIPCMode: true
});

const mediaMixingManager = trtcCloud.getMediaMixingManager();

const windowID = 0; // Use Electron API BrowserWindow.getNativeWindowHandle()
const previewDOM = document.getElementById("preview-local-mixed-media-stream");
const domRect = previewDOM.getBoundingClientRect();
const rect = {
  left: domRect.left * window.devicePixelRatio,
  right: domRect.right * window.devicePixelRatio,
  top: domRect.top * window.devicePixelRatio,
  bottom: domRect.bottom * window.devicePixelRatio
};

mediaMixingManager.setDisplayParams(windowID, previewDOM);
Parameters:
Name Type Description
windowID Number | Uint8Array required

The window ID at the operating system level, which can be obtained with Electron API BrowserWindow.getNativeWindowHandle()

region HTMLElement | Rect | null required

The HTML element or Rectangle area to display local mixed-stream video

  • If you pass in an HTMLElement element, the SDK will display the local mixed-stream video within the HTMLElement element. It also supports clicking to select, moving, and scaling the media source, and supports triggering right-click menu events. The HTMLElement element must be a block element.
  • If you pass in a Rect display area, the SDK will display the local mixed-stream video within the area specified by Rect. It does not support clicking to select, moving, and scaling the media source, nor does it support triggering right-click menu events. You can implement these features on your web page yourself.
  • If you pass in null, the SDK will stop displaying the local mixed-stream video.

addMediaSource(mediaSource) → {Promise.<Rect>}

Add media source

Parameters:
Name Type Description
mediaSource TRTCMediaSource required

Media source data

Returns:
Type
Promise.<Rect>

removeMediaSource(mediaSource) → {Promise.<void>}

Remove media source

Parameters:
Name Type Description
mediaSource TRTCMediaSource required

Media source data

Returns:
Type
Promise.<void>

updateMediaSource(mediaSource) → {Promise.<void>}

Update media source

Parameters:
Name Type Description
mediaSource TRTCMediaSource required

Media source data

Returns:
Type
Promise.<void>

setCameraCaptureParam(cameraID, params)

Set camera capturing parameter

Parameters:
Name Type Description
cameraID string required

Camera device ID

params TRTCCameraCaptureParams required

Camera capturing parameters

startPublish() → {Promise.<void>}

Start publishing mixing video

Returns:
Type
Promise.<void>

stopPublish() → {Promise.<void>}

Stop publishing mixing video

Returns:
Type
Promise.<void>

updatePublishParams(params) → {Promise.<void>}

Update mixing video encoding parameter

Parameters:
Name Type Description
params TRTCMediaMixingEncParam required

Mixing video encoding parameter and background color.

Returns:
Type
Promise.<void>

on(event, func)

Add event listener

Parameters:
Name Type Description
event TRTCMediaMixingEvent required

Event name

func function required

Event listener functon

off(event, func)

Remove event listener

Parameters:
Name Type Description
event TRTCMediaMixingEvent required

Event name

func function required

Event listener functon