async toggleVideoCam() {
if (this.rtc.localVideoTrack) {
await this.rtc.client.localVideoTrack.setEnabled(false);
this.rtc.localVideoTrack.close();
document.getElementById('localvideo').remove();
} else {
await this.rtc.client.localVideoTrack.setEnabled(true);
const playerContainer = document.createElement('div');
const userIdContainer = document.createElement('span');
userIdContainer.className = 'user-id-holder';
playerContainer.className = 'localUserVideo';
let liveStreamContainer = document.querySelector('.videoTracks-container');
playerContainer.id = 'localvideo';
userIdContainer.innerHTML = 'local video';
playerContainer.append(userIdContainer);
if (!document.getElementById(playerContainer.id)) {
liveStreamContainer.append(playerContainer);
// Play the local audio and video tracks
// SDK dynamically creates a player in the container for playing the local video track
this.rtc.localVideoTrack.play(playerContainer);
}
}
}
现在我要切换发布localVideoTrack
怎么办?
是的,我在localVideoTrack上添加了setEnabled方法,但无法读取未定义的setEnabled属性。
答案 0 :(得分:0)
您可以简单地使用适当的布尔值在本地轨道上调用 @echo off
echo Changing the Directory to Blue Prism Automate
cd C:\Program Files\Blue Prism Limited\Blue Prism Automate
echo Triggering CSM Validation Process and Storing the Session ID
for /f %%i in ('AutomateC.exe /resource BWD14195034 /port 8215 /sso /run "CSMValidationInput"') do set RESULT=%%i
For /f "delims=:" %%A in ("%RESULT%") do Set Session_ID = %%A
echo %Session_ID%
Pause
方法来切换发布轨道。 https://agoraio-community.github.io/AgoraWebSDK-NG/api/en/interfaces/ilocalvideotrack.html#setenabled
答案 1 :(得分:0)
第一件事是您必须将 await 与 setenabled 方法一起使用,第二件事是客户端对象中不存在轨道。
try {
if (this.rtc.localVideoTrack) await rtc.localVideoTrack.setEnabled(true); // This is used to publish camera
} catch (error) {
console.log(error, 'error');
}
}
else {
try {
if (this.rtc.localVideoTrack) await rtc.localVideoTrack.setEnabled(false); // With this you can close camera
} catch (error) {
console.log(error, 'error');
}
}