我想在應用程序中設置一個會議模塊。所以我找到並創建了兩個用戶之間的流。Peerjs多個查看器
的問題是,別人不能加入。
我一直試圖在他們的文檔閱讀了,但是我似乎無法找出如何實現它。
這裏是我的代碼:
// Compatibility shim
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
navigator.getUserMedia({audio: true, video: true}, function (stream) {
// Set your video displays
$('#my-video').prop('src', URL.createObjectURL(stream));
window.localStream = stream;
}, function() {
$('#step1-error').show();
});
peerFactory.on('error', function (err) {
alert(err.message);
});
peerFactory.on('connection', function (id) {
alert('new logon' + id);
});
// Receiving a call
peerFactory.on('call', function (call) {
// Answer the call automatically (instead of prompting user) for demo purposes
var r = confirm('Ny kald fra ');
if (r) {
call.answer(window.localStream);
$scope.currentCall = true;
$scope.$apply();
streamCall(call);
}
else
{
call.close();
window.existingCall.close();
}
});
$scope.makeCall = function (callId) {
var call = peerFactory.call(callId, window.localStream);
$scope.currentCall = true;
streamCall(call);
};
$scope.hangUp = function()
{
$scope.currentCall = false;
window.existingCall.close();
};
function streamCall(call) {
// Hang up on an existing call if present
if (window.existingCall) {
window.existingCall.close();
}
// Wait for stream on the call, then set peerFactory video display
call.on('stream', function (stream) {
$('#their-video').prop('src', URL.createObjectURL(stream));
});
// UI stuff
window.existingCall = call;
$('#their-id').text(call.peerFactory);
call.on('error', function() {
var i = 0;
});
}
誰能給我在正確的方向推?