首页 行业资讯 宠物日常 宠物养护 宠物健康 宠物故事

基于webrtc以及nodejs的P2P实时视频demo

发布网友

我来回答

1个回答

热心网友

吐槽, 你的分类错了, 导致不能贴代码。
github:

priologic/easyrtc
webRTC/webRTC.io

自己开发推荐使用priologic/easyrtc

只是玩玩 对于webRTC.io使用简单

npm install webrtc.io

Client
<video id="local" autoplay="autoplay"></video>
<video id="remote" autoplay="autoplay"></video>

<script src="/webrtc.io.js"></script>
<script>

// note: make sure hostname available to all connecting clients
// (ie. probably not `localhost`)
rtc.connect('ws://yourserveraddress:8001');

rtc.createStream({"video": true, "audio":false}, function(stream){
// get local stream for manipulation
rtc.attachStream(stream, 'local');
});

rtc.on('add remote stream', function(stream){
// show the remote video
rtc.attachStream(stream, 'remote');
});

// more rtc callbacks are available
</script>

Server

var webRTC = require('webrtc.io').listen(8001);
//then a bunch of callbacks are available

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com