TRTCVideoStreamType
parameter to TRTCVideoStreamTypeSub
when calling the startScreenCapture
API.TRTCVideoStreamType
parameter to TRTCVideoStreamTypeBig
when calling the startScreenCapture
API.getScreenCaptureSources
to get a list of sharable sources, which is returned via the response parameter sourceInfoList
.getScreenCaptureSources
includes desktop windows.import TRTCCloud from 'trtc-electron-sdk';const rtcCloud = new TRTCCloud();// https://web.sdk.qcloud.com/trtc/electron/doc/en-us/trtc_electron_sdk/TRTCCloud.html#getScreenCaptureSourcesconst screenList = rtcCloud.getScreenCaptureSources();
pauseScreenCapture
pauses screen capturing and displays the image at the moment it is paused. Remote users see the paused video image until screen capturing is resumed.import TRTCCloud, {Rect, TRTCScreenCaptureProperty, TRTCVideoStreamType, TRTCVideoEncParam,TRTCVideoResolution, TRTCVideoResolutionMode} from 'trtc-electron-sdk';const rtcCloud = new TRTCCloud();// https://web.sdk.qcloud.com/trtc/electron/doc/zh-cn/trtc_electron_sdk/TRTCCloud.html#getScreenCaptureSourcesconst screenList = rtcCloud.getScreenCaptureSources();// https://web.sdk.qcloud.com/trtc/electron/doc/zh-cn/trtc_electron_sdk/Rect.htmlconst captureRect = new Rect(0, 0, 0, 0);// https://web.sdk.qcloud.com/trtc/electron/doc/zh-cn/trtc_electron_sdk/TRTCScreenCaptureProperty.htmlconst property = new TRTCScreenCaptureProperty(true, true, true, 0, 0, false);if (screenList.length > 0) {rtcCloud.selectScreenCaptureTarget(screenList[0], captureRect, property)}const screenshareDom = document.querySelector('screen-dom');// https://web.sdk.qcloud.com/trtc/electron/doc/zh-cn/trtc_electron_sdk/TRTCVideoEncParam.htmlconst encParam = new TRTCVideoEncParam(TRTCVideoResolution.TRTCVideoResolution_1920_1080,TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape,15,2000,0,false);rtcCloud.startScreenCapture(screenshareDom, TRTCVideoStreamType.TRTCVideoStreamTypeSub, encParam);
encParam
) of the startScreenCapture
API to set the video quality of screen sharing (see step 2), including resolution, bitrate, and frame rate. We recommend the following settings:Clarity | Resolution | Frame Rate | Bitrate |
HD+ | 1920 x 1080 | 10 | 2000 kbps |
HD | 1280 x 720 | 10 | 600 Kbps |
SD | 960 × 720 | 10 | 400 Kbps |
import TRTCCloud, {TRTCVideoStreamType} from 'trtc-electron-sdk';const rtcCloud = new TRTCCloud();const remoteDom = document.querySelector('.remote-user');function onUserSubStreamAvailable(userId, available) {if (available === 1) {rtcCloud.startRemoteView(userId, remoteDom, TRTCVideoStreamType.TRTCVideoStreamTypeSub);} else {rtcCloud.stopRemoteView(userId, TRTCVideoStreamType.TRTCVideoStreamTypeSub);}}rtcCloud.on('onUserSubStreamAvailable', onUserSubStreamAvailable);
SourceTypeWindow
) is shared, if the window size changes, will the resolution of the video stream change accordingly?setSubStreamEncoderParam
API to set encoding parameters for screen sharing or specify the parameters when calling the startScreenCapture
API.