
TRTCCloud to set the subscription mode. TRTC provides two subscription modes:setDefaultStreamRecvMode, the automatic subscription mode will apply. If you want to use the manual subscription mode, make sure you call setDefaultStreamRecvMode before enterRoom.muteRemoteAudio("denny", true) to mute the remote user denny and then call muteRemoteAudio("denny", false) to unmute denny.import TRTCCloud from 'trtc-electron-sdk';const rtcCloud = new TRTCCloud();// For details, see https://web.sdk.qcloud.com/trtc/electron/doc/zh-cn/trtc_electron_sdk/TRTCCloud.html#muteRemoteAudio// Mute the user “denny”rtcCloud.muteRemoteAudio('denny', true);// Unmute the user with ID dennyrtcCloud.muteRemoteAudio('denny', false);
startRemoteView to play the video of a remote user, but only after you pass in a view object to the SDK as the rendering control for the user's video.startRemoteView is userId of the remote user, the second is the stream type of the user, and the third is the view object to be passed in. Here, the second parameter streamType has three valid values:enableEncSmallVideoStream). The original and lower quality streams cannot be played at the same time.stopRemoteView API to stop playing back the video of one remote user or call the stopAllRemoteView API to stop playing back videos of all remote users.// For details, see https://web.sdk.qcloud.com/trtc/electron/doc/zh-cn/trtc_electron_sdk/TRTCCloud.html#startRemoteViewimport TRTCCloud, { TRTCVideoStreamType } from 'trtc-electron-sdk';const cameraView = document.querySelector('.user-dom');const screenView = document.querySelector('.screen-dom');const rtcCloud = new TRTCCloud();// Play back the camera (primary stream) image of `denny`rtcCloud.startRemoteView('denny', cameraView, TRTCVideoStreamType.TRTCVideoStreamTypeBig);// Play back the screen sharing (substream) image of `denny`rtcCloud.startRemoteView('denny', screenView, TRTCVideoStreamType.TRTCVideoStreamTypeSub);// Play back the lower quality video of `denny` (The original and lower quality streams cannot be played back at the same time)rtcCloud.startRemoteView('denny', cameraView, TRTCVideoStreamType.TRTCVideoStreamTypeSmall);// Stop playing back the camera image of `denny`rtcCloud.stopRemoteView('denny', TRTCVideoStreamType.TRTCVideoStreamTypeBig);// Stop playing back the videos of all remote usersrtcCloud.stopAllRemoteView();
setRemoteRenderParams)setRemoteRenderParams to set the video image fill mode, rotation angle, and mirror mode.// For details, see https://web.sdk.qcloud.com/trtc/electron/doc/zh-cn/trtc_electron_sdk/TRTCCloud.html#setRemoteRenderParams// Set the fill mode for the primary stream of the remote user `denny` to fill, and flip the image horizontallyimport TRTCCloud, {TRTCRenderParams, TRTCVideoStreamType, TRTCVideoRotation,TRTCVideoFillMode, TRTCVideoMirrorType} from 'trtc-electron-sdk';const param = new TTRTCRenderParams(TRTCVideoRotation.TRTCVideoRotation0,TRTCVideoFillMode.TRTCVideoFillMode_Fill,TRTCVideoMirrorType.TRTCVideoMirrorType_Enable);const rtcCloud = new TRTCCloud();rtcCloud.setRemoteRenderParams('denny', TRTCVideoStreamType.TRTCVideoStreamTypeBig, param);
onUserAudioAvailable(userId,boolean) to be notified when a remote user turns their mic on/off.onUserVideoAvailable(userId,boolean) to be notified when a remote user turns their camera on/off.
You can listen for onUserSubStreamAvailable(userId,boolean) to be notified when a remote user enables/disables screen sharing.onRemoteUserEnterRoom(userId). When a remote user exits the current room, you can get the user’s ID and the reason for their exit from onRemoteUserLeaveRoom(userId, reason).onRemoteUserEnter/LeaveRoom only notifies you about the room entry/exit of anchors. This prevents frequent notifications when there are a large audience in the room.mCameraUserList, mMicrophoneUserList, and mUserList are used to maintain the following information:import TRTCCloud from 'trtc-electron-sdk';let openCameraUserList = [];let openMicUserList = [];let roomUserList = [];function onUserVideoAvailable(userId, available) {if (available === 1) {openCameraUserList.push(userId);} else {openCameraUserList = openCameraUserList.filter((item) => item !== userId);}}function onUserAudioAvailable(userId, available) {if (available === 1) {openMicUserList.push(userId);} else {openMicUserList = openMicUserList.filter((item) => item !== userId);}}function onRemoteUserEnterRoom(userId) {roomUserList.push(userId);}function onRemoteUserLeaveRoom(userId, reason) {roomUserList = roomUserList.filter((item) => item !== userId);}const rtcCloud = new TRTCCloud();rtcCloud.on('onUserVideoAvailable', onUserVideoAvailable);rtcCloud.on('onUserAudioAvailable', onUserAudioAvailable);rtcCloud.on('onRemoteUserEnterRoom', onRemoteUserEnterRoom);rtcCloud.on('onRemoteUserLeaveRoom', onRemoteUserLeaveRoom);
denny, you can call muteRemoteAudio("denny", true), and the SDK will stop pulling the audio data of denny. In this mode, less traffic is used. However, it will be slow to resume audio playback because the SDK needs to restart the audio data pull process.setRemoteAudioVolume("denny", 0), which sets the playback volume of the remote user denny to zero. Because this API doesn't involve network operations, it takes effect very quickly.muteRemoteAudio("denny", true) to mute the remote user denny, other users in the room can still hear denny.
To completely disable the audio of denny, you need to change the way their audio is published. For more information, see Publishing Audio/Video Streams.Feedback