Constructor
new TRTCMediaMixingManager()
Methods
setDisplayParams(windowID, viewOrRegion)
设置混流视频预览参数
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
操作系统层的窗口 ID,Electron 下可以通过 Electron API BrowserWindow.getNativeWindowHandle() 接口获取 |
viewOrRegion |
HTMLElement | Rect | null |
required
本地混流视频显示位置
|
addMediaSource(mediaSource) → {Promise.<Rect>}
添加媒体源
Parameters:
Name | Type | Description |
---|---|---|
mediaSource |
TRTCMediaSource |
required
媒体源信息 |
Returns:
- Type
- Promise.<Rect>
removeMediaSource(mediaSource) → {Promise.<void>}
删除媒体源
Parameters:
Name | Type | Description |
---|---|---|
mediaSource |
TRTCMediaSource |
required
媒体源信息 |
Returns:
- Type
- Promise.<void>
updateMediaSource(mediaSource) → {Promise.<void>}
更新媒体源
Parameters:
Name | Type | Description |
---|---|---|
mediaSource |
TRTCMediaSource |
required
媒体源信息 |
Returns:
- Type
- Promise.<void>
setCameraCaptureParam(cameraID, params)
设置摄像头采集参数
Parameters:
Name | Type | Description |
---|---|---|
cameraID |
string |
required
摄像头 ID |
params |
TRTCCameraCaptureParams |
required
摄像头采集参数 |
startPublish() → {Promise.<void>}
开始推流
Returns:
- Type
- Promise.<void>
stopPublish() → {Promise.<void>}
停止推流
Returns:
- Type
- Promise.<void>
updatePublishParams(params) → {Promise.<void>}
更新本地混流编码参数
Parameters:
Name | Type | Description |
---|---|---|
params |
TRTCMediaMixingEncParam |
required
推流视频编码参数、背景色等参数 |
Returns:
- Type
- Promise.<void>
on(event, func)
注册事件监听
Parameters:
Name | Type | Description |
---|---|---|
event |
TRTCMediaMixingEvent |
required
事件名称 |
func |
function |
required
事件回调函数 |
off(event, func)
取消事件监听
Parameters:
Name | Type | Description |
---|---|---|
event |
TRTCMediaMixingEvent |
required
事件名 |
func |
function |
required
事件回调函数 |