[英]Twilio 2.7.2 Programmable Video Camera Stays On
I have had a nightmare of a time attempting to stop the video tracks and turn off the camera.我曾做过一次噩梦,试图停止视频轨道并关闭相机。 Can ANYONE tell me what I am missing here?
任何人都可以告诉我我在这里缺少什么吗? Snippet below is the event handler for when a room is disconnected.
下面的代码段是房间断开连接时的事件处理程序。 The code executes fine, but the camera stays on.
代码执行良好,但相机保持开启状态。 Thanks in advance.
提前致谢。
this.roomObj.once('disconnected', (room: Room, error) => { // if (error) { // console.log(`An error has occurred with the room connection: ${error}`); // } room.localParticipant.tracks.forEach(publication => { publication.track.stop(); const attachedElements = publication.track.detach(); attachedElements.forEach(element => { element.stop(); element.remove(); }); room.localParticipant.videoTracks.forEach(video => { const trackConst = [video][0].track; trackConst.stop(); // <- error trackConst.detach().forEach(element => { element.stop(); element.remove(); }); room.localParticipant.unpublishTrack(trackConst); }); let element = this.remoteVideo1Container.nativeElement; while (element.firstChild) { element.removeChild(element.firstChild); } let localElement = this.localVideo.nativeElement; while (localElement.firstChild) { localElement.removeChild(localElement.firstChild); } //this.router.navigate(['thanks']); }); }, (error) => { alert(error.message); });
I triggered a full page redirect to shut off the camera with window.location.replace
rather than using react-router-dom
's <Redirect to={} />
to fully shut off the camera.我触发了一个完整的页面重定向以使用
window.location.replace
关闭相机,而不是使用react-router-dom
的<Redirect to={} />
来完全关闭相机。 This may not be possible in your case, and there maybe a better solution.在您的情况下这可能是不可能的,并且可能有更好的解决方案。
If you could use the same route that you were going to anyway.如果您可以使用无论如何都要去的相同路线。 If you weren't planning on changing page, though my solution won't be of much use.
如果您不打算更改页面,尽管我的解决方案不会有太大用处。
But having an issue with shutting off the desktop camera light in react, I figured I would share my solution.但是在反应中关闭桌面摄像头灯时遇到问题,我想我会分享我的解决方案。 I can delete or remove this post if this answer displeases anyone or once a Twilio rep (or some mystery person) comes by with a better response.
如果此答案令任何人不悦,或者一旦 Twilio 代表(或某个神秘人物)提出更好的回复,我可以删除或删除此帖子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.