TRTC.isSupported().then(checkResult => {// Not supported, guide the user to use a supported browser(Chrome 56+, Edge 80+, Firefox 56+, Safari 11+).if (!checkResult.result) {}// Not support to publish videoif (!checkResult.detail.isH264EncodeSupported) {}// Not support to subscribe videoif (!checkResult.detail.isH264DecodeSupported) {}});




const cameraList = await TRTC.getCameraList();const hasCameraDevice = cameraList.length > 0;if (!hasCameraDevice) {// User has not any camera.}
try {// Capture and play camera, not need to publish streamawait trtc.startLocalVideo({ view: 'camera-video-view-id', publish: false });} catch(error) {// Common reasons: NotAllowedError or NotReadableError}
// You can get the cameraId from the camera list you got in fisrt step.if (cameraList[1]) {try {await trtc.updateLocalVideo({ option: { cameraId: cameraList[1].deviceId } });} catch(error) {// Common reasons: NotAllowedError or NotReadableError, same with step 2.}}
await trtc.stopLocalVideo();
const microphoneList = await TRTC.getMicrophoneList();const hasMicrophoneDevice = micList.length > 0;if (!hasMicrophoneDevice) {// User has not any microphone.}
try {// Capture microphoneawait trtc.startLocalAudio({ publish: false });trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {event.result.forEach(({ userId, volume }) => {// When userId is an empty string, it represents the volume of the local microphone.const isMe = userId === '';if (isMe) {// show a volume bar based on the value of volume.}})});trtc.enableAudioVolumeEvaluation(500);} catch(error) {// Common reasons: NotAllowedError or NotReadableError}
// You can get the microphoneId from the microphone list you got in fisrt step.if (microphoneList[1]) {try {await trtc.updateLocalAudio({ option: { microphoneId: microphoneList[1].deviceId } });} catch(error) {// Common reasons: NotAllowedError or NotReadableError, same with step 2.}}
// You need to stop microphone when the testing finished.await trtc.stopLocalAudio();// disable audio-volume eventtrtc.enableAudioVolumeEvaluation(-1);
const speakerList = await TRTC.getSpeakerList();if (speakerList.length === 0) {// User has not speaker.}
<audio id="audio-player" src="xxxxx" controls></audio>
const audioElement = document.getElementById('audio-player');if (speakerList[1]) {audioElement.sinkId = speakerList[1].deviceId;}
피드백