javascript 在 HTML5 应用程序中添加音频/视频通话
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16918013/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding audio/video calls in HTML5 app
提问by Eugeny89
I'm working on HTML5 app that lets several users to work on one document. I need to add a possibility for users (editing the same document) to talk to each other. And I just don't know how to start with that. Here are my questions
我正在开发允许多个用户处理一个文档的 HTML5 应用程序。我需要为用户(编辑同一个文档)增加相互交谈的可能性。我只是不知道如何开始。这是我的问题
- Is there an HTML5 lib allowing to transfer sound from microphone between clients?
- What about streaming video from camera?
- What is an easiest server-side solution for that?
- 是否有 HTML5 库允许在客户端之间从麦克风传输声音?
- 从相机流式传输视频怎么样?
- 什么是最简单的服务器端解决方案?
Any thoughts are strongly appreciated! So don't be shy! :)
任何想法都非常感谢!所以不要害羞!:)
UPD:please note that I need an abbility for more then two users to talk.
UPD:请注意,我需要一个能够让两个以上的用户交谈的能力。
采纳答案by Eugeny89
For this you can use WebRTC.
为此,您可以使用WebRTC。
However, this is a very young and unfinished technology that as already stated is currently available only in Chrome stable and Firefox beta. This means there will probably come changes to the current spec, something to be aware of in case of early implementation. But it allow you to use video and audio communication directly in the browser.
然而,这是一项非常年轻且未完成的技术,如前所述,目前仅在 Chrome 稳定版和 Firefox 测试版中可用。这意味着当前规范可能会发生变化,在早期实施的情况下需要注意一些事项。但它允许您直接在浏览器中使用视频和音频通信。
Quick-start here:
http://www.html5rocks.com/en/tutorials/webrtc/basics/
快速入门:http:
//www.html5rocks.com/en/tutorials/webrtc/basics/
Other options are Flash based plugins such as flash-videoio. This is an open source plugin but will naturally require Adobe Flash installed. This may or may not be a problem depending on the company's security policy.
其他选项是基于 Flash 的插件,例如flash-videoio。这是一个开源插件,但自然需要安装 Adobe Flash。这可能是也可能不是问题,具体取决于公司的安全策略。
For technical details on implementation please see examples on the provided links.
有关实施的技术细节,请参阅提供的链接上的示例。
For many-to-many you can use either:
对于多对多,您可以使用:
- "Mesh" - everybody connects to everybody. This however is costly on CPU and mobiles are often left out.
- "Star" - everybody goes through the most capable device. However, with many connections this will soon run slow for the device handling all connections.
- MCU. Specialized server to handle all connections. If mixes audio and video and handles drop-outs as well without affecting the other callers.
- “Mesh” - 每个人都与每个人相连。然而,这对 CPU 来说是昂贵的,而且移动设备通常被排除在外。
- “明星” - 每个人都经过最强大的设备。但是,对于许多连接,这对于处理所有连接的设备来说很快就会运行缓慢。
- 微控制器。处理所有连接的专用服务器。If 混合音频和视频并在不影响其他呼叫者的情况下处理掉线问题。
Examples of MCU's:
http://sourceforge.net/projects/mcumediaserver/(open source)
http://www.medooze.com/products/mcu.aspx(commercial)
MCU 示例:
http: //sourceforge.net/projects/mcumediaserver/(开源)
http://www.medooze.com/products/mcu.aspx(商业)
回答by cocco
you are searching for navigator.getUserMedia()
您正在搜索 navigator.getUserMedia()
that allows the various users to share video audio and data.
允许各种用户共享视频音频和数据。
the support is very low... only chrome and the latest verions of opera and firefox support it.
支持率很低……只有chrome和最新版本的opera和firefox支持。
and totally no support on mobile devices... maybe in the next android chrome... dunno
并且完全不支持移动设备......也许在下一个android chrome中......不知道
as there is much to talk about and i have no clue on how u wanna setup everything i suggest u read a little more about that on the urls...
因为有很多要谈的,我不知道你想如何设置一切我建议你在网址上阅读更多关于它的内容......
http://www.html5rocks.com/en/tutorials/getusermedia/intro/
http://www.html5rocks.com/en/tutorials/getusermedia/intro/
http://dev.w3.org/2011/webrtc/editor/getusermedia.html
http://dev.w3.org/2011/webrtc/editor/getusermedia.html
https://developer.mozilla.org/en-US/docs/WebRTC/navigator.getUserMedia
https://developer.mozilla.org/en-US/docs/WebRTC/navigator.getUserMedia
http://my.opera.com/core/blog/2011/03/23/webcam-orientation-preview
http://my.opera.com/core/blog/2011/03/23/webcam-orientation-preview
http://simpl.info/getusermedia/
http://simpl.info/getusermedia/
and SERVERSIDE solution nahh... thats not a good solution
和 SERVERSIDE 解决方案不,那不是一个好的解决方案
clientside is the way to go.
客户端是要走的路。
回答by edgarjs
Not sure if you're required to do it yourself from scratch or are able to use third party libraries/tools.
不确定您是否需要从头开始或能够使用第三方库/工具。
In which case I would recommend using Tokboxwhich has support for WebRTC and SDK for iOS.
在这种情况下,我建议使用Tokbox,它支持 iOS 的 WebRTC 和 SDK。
Their API is simple and easy to use.
他们的 API 简单易用。