2015-04-12 163 views
0

我正在尝试学习如何使用webrtc来允许用户通过网络摄像头和音频进行双向通信。使用webrtc进行双向通信?

我也碰到过这样的:LINK

,我认为是完美的,我开始学习,因为它似乎很简单,整齐,不像是我在谷歌找到其他的东西的地步。

但是,我真的不能在自己的演示和我自己的服务器上做这项工作!

我只能在一个小窗口中看到我自己的摄像头视图,我找不到任何链接与其他人分享!

我以为:<a id="link" target="_blank">Video Link</a>将是与其他人分享聊天会话的链接,但是当我点击该链接时绝对没有任何事情发生。

我选择使用上面链接中显示的代码的主要原因是因为它似乎没有使用任何其他插件。

我有这个问题是我错过了什么使这项工作?

还是我需要plugin才能让webrtc适用于视频/音频P2P聊天?

任何意见,将不胜感激。

+0

看看这个:https://github.com/mgiuliani/webrtc-video-chat和demo:http://mg-webrtc.azurewebsites.net/ – Alexan

+0

@Alex,写什么编程语言? –

+0

这是C#使用SignalR进行连接:http://www.skylinetechnologies.com/Blog/Article/48/Peer-to-Peer-Media-Streaming-with-WebRTC-and-SignalR.aspx 对不起,我没有'不明白你想使用html5而不需要服务器端。 – Alexan

回答

0

的WebRTC是由它的性质用于P2P通信,我会建议使用一些简单的像http://simplewebrtc.com/

见下面的代码,你可以用它来创建简单的WebRTC应用,刚从是testing123改变房间名称到别的东西。

<!DOCTYPE html> 
<html> 
    <head> 
     <script src="http://simplewebrtc.com/latest.js"></script> 
     <style> 
      #remoteVideos video { 
       height: 320px; 
      } 
      #localVideo { 
       height: 240px; 
      } 
     </style> 
<script> 
var webrtc = new SimpleWebRTC({ 
    // the id/element dom element that will hold "our" video 
    localVideoEl: 'localVideo', 
    // the id/element dom element that will hold remote videos 
    remoteVideosEl: 'remoteVideos', 
    // immediately ask for camera access 
    autoRequestMedia: true, 
// url: 'atlas' 
}); 

// we have to wait until it's ready 
webrtc.on('readyToCall', function() { 
    // you can name it anything 
    webrtc.joinRoom('testing123'); 
}); 

</script> 
    </head> 
    <body> 
     <video id="localVideo"></video> 
     <div id="remoteVideos"></div> 
    </body> 
</html> 
0

你不需要插件。您需要能够在浏览器中编写javascript以使用WebRTC API(听起来您不想编写自己的本机应用程序?),并且您需要某种信号服务器来启用两个对等端(浏览器客户端)互相发送消息。根据您的需求,您不一定需要数据库。