Web

This document describes how an anchor publishes audio/video streams. "Publishing" refers to turning on the mic and camera to make the audio heard and video seen by other users in the room.



Step 1. Enter Room

For detailed directions, see Enter Room.

Step 2. Turn on camera

Use the trtc.startLocalVideo() API to turn on the camera and publish it to the room.
// To preview the camera image, you need to place an HTMLElement in the DOM, which can be a div tag, assuming its id is local-video.
const view = 'local-video';
await trtc.startLocalVideo({ view });

Step 3. Turn on microphone

Use the trtc.startLocalAudio() API to turn on the microphone and publish it to the room.
await trtc.startLocalAudio();

Step 4. Turn off camera/microphone

Use the trtc.stopLocalVideotrtc.stopLocalAudio to turn off camera/microphone.