|
Post by account_disabled on Jan 4, 2024 4:25:36 GMT -6
start.js这些应该是我们董事会的所有主要组成部分。谢谢你陪我这么久。我跳过了一些将事物连接在一起的行;要查看完整代码,请查看GitHub 存储库。 添加视频聊天 现在是时候解决我们回顾委员会的视频聊天部分了。 通过 WebRTC 进行视频聊天 通过 WebRTC 进行视频聊天。 回顾就是人们互相交谈。如果没有沟通,即使是最好的建议和反馈也将无法使用。 我们来谈谈 WebRTC 如果您从事网络技术工作,您很可能会遇到过 WebRTC。这是一个令人兴奋的新标准,它允许我们直接在浏览器之间传输音频、视频甚至数据流,而无需通过服务器路由它们。 Deepstream 中的 WebRTC Deepstream 中的 WebRTC。(查看大图) 然而,就浏览器 API 而言,WebRTC 是最复杂。 的 API之一。尽管它是一种点对点协议,但它仍然需要服务器。所有这一切的原因是,为了连接两个浏览器,两个浏览器都必须知道另一个浏览器在哪里——这比听起来要复杂得多。 想象一下一个朋友询问你的地址。你回答,“我在卧室”——让他们找出你的卧室 Whatsapp 号码列表 在哪栋房子里,你的房子在哪条街上,那条街在哪个城镇等等。一旦他们能够可靠地找到您的卧室,您仍然需要提供一份门窗清单,他们必须尝试查看是否有门窗打开。 Deepstream试图将所有这些抽象出来,并将 WebRTC 简化为两个概念:电话簿和通话。我们将使用两者来创建一个视频聊天室,使我们的团队能够讨论回顾板上发生的事情。 连接流 浏览器中的视频以MediaStream. 这些流是音频和视频信号的组合,可以在video元素中播放或通过互联网发送给其他人。 您可以从网络摄像头或麦克风检索流,也可以通过 WebRTC 从其他用户检索流,或者在captureStream完全支持后,甚至可以从canvas元素检索流。 获取本地网络摄像头流 让我们从本地网络摄像头和麦克风流开始。可以使用getUserMedia- 来检索它,但问题立即开始。getUserMedia现已存在一段时间了,但 API 仍未完全标准化,因此仍以供应商为前缀。但帮助就在眼前。官方 WebRTC 计划维护一个适配器脚本,该脚本可以规范浏览器差异并及时了解 API 更改。您可以在 GitHub 上找到它。 安装后,检索本地视频和音频流并在video标签中播放它就像这样简单:每当应用程序请求访问用户的网络摄像头或麦克风时,很多事情都可能会出错。用户可能根本没有网络摄像头,可能有网络摄像头但没有麦克风,可能有一个无法。
|
|