nowjs 可以保存由 webrtc 发送的流吗
WebRTC 是一个免费、开放的项目,它通过简单的 Javascript API 使 Web 浏览器具有实时通信 (RTC) 功能
,我可以使用此代码来捕获我的相机,这是 demo
if (navigator.webkitGetUserMedia) {
navigator.webkitGetUserMedia('video', gotStream, noStream);
var video = document.getElementById('monitor');
var canvas = document.getElementById('photo');
function gotStream(stream) {
video.src = webkitURL.createObjectURL(stream);
video.onerror = function () {
stream.stop();
streamError();
};
document.getElementById('splash').hidden = true;
document.getElementById('app').hidden = false;
}
function noStream() {
document.getElementById('errorMessage').textContent = 'No camera available.';
}
function streamError() {
document.getElementById('errorMessage').textContent = 'Camera error.';
}
function snapshot() {
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0);
}
} else {
document.getElementById('errorMessage').textContent = 'No native camera support available.';
}
现在,我想将我的相机流发送给其他人,
我已经使用 nowjs 创建了一个聊天室,
所以我想知道,nowjs 有吗握持相机的方法 上流式传输和显示
在网络浏览器
,谢谢
WebRTC is a free, open project that enables web browsers with Real-Time Communications (RTC) capabilities via simple Javascript APIs
and i can use this code to Capture my camera,this is the demo
if (navigator.webkitGetUserMedia) {
navigator.webkitGetUserMedia('video', gotStream, noStream);
var video = document.getElementById('monitor');
var canvas = document.getElementById('photo');
function gotStream(stream) {
video.src = webkitURL.createObjectURL(stream);
video.onerror = function () {
stream.stop();
streamError();
};
document.getElementById('splash').hidden = true;
document.getElementById('app').hidden = false;
}
function noStream() {
document.getElementById('errorMessage').textContent = 'No camera available.';
}
function streamError() {
document.getElementById('errorMessage').textContent = 'Camera error.';
}
function snapshot() {
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0);
}
} else {
document.getElementById('errorMessage').textContent = 'No native camera support available.';
}
and now , i want to send my camera stream to other people,
i have already create a chat room using nowjs,
so i want to know , Does the nowjs has method to hold the camera stream and show on
the web-browser,
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
视频流不需要存储在任何地方。它通过 对等连接< /strong>。您需要做的就是通过在客户端之间传输信令消息(类似于“握手”)来创建这样的连接。流式传输由 API 负责。
The video stream need not be stored anywhere. It is transmitted from one client to the other through a Peer Connection. All you need to do is create such a connection, by transmitting the Signaling Messages (something like a 'Handshake') between the clients. The streaming is taken care by the API.