我正在创建音频/视频/文字聊天应用程序。我已成功完成视频会议功能。但是,如果没有用户的许可,我不知道如何访问用户的网络摄像头。
我想要做的是管理员可以访问用户的网络摄像头。我创建了在线用户列表。当管理员点击在线用户的Watch
按钮时,管理员应该能够访问用户的网络摄像头,以便管理员可以从该特定用户的网络摄像头中看到。
任何人都可以指导我这样做吗?
答案 0 :(得分:1)
超级管理员可以查看所有房间,从任何房间获取任何用户的视频。
您可以使用socket.io或其他PHP / mySQL与超级管理员共享房间。
超级管理员可以使用“加入”方法查看任何用户的视频:
var selectedUserId = database.getSelectedUserId();
connection.join(selectedUserId);
超级管理员必须设置“dontCaptureUserMedia = true”以确保他不共享自己的相机。这意味着超级管理员将无缝地查看来自任何房间的任何用户的视频。
connection.dontCaptureUserMedia = true;
var selectedUserId = database.getSelectedUserId();
connection.join(selectedUserId);
了解如何send or receive custom messages using socket.io并尝试a demo as well。
以下是超级管理员的示例代码:
connection.socketCustomEvent = 'super-admin-socket';
connection.dontCaptureUserMedia = true;
connection.connectSocket(function() {
connection.socket.on(connection.socketCustomEvent, function(message) {
if (message.newUser === true) {
connection.join(message.userid);
}
});
});
以下是所有普通用户的代码。即任何房间的任何用户:
connection.socketCustomEvent = 'super-admin-socket';
connection.openOrJoin('any-room-id', function() {
// this message is going toward super-admin
// super-admin will receive this message
// super-admin can view this user's camera seamlessly
// or show his name in a list
connection.socket.emit(connection.socketCustomEvent, {
newUser: true,
userid: connection.userid
});
});
了解如何与超级管理员共享会议室
以下代码适用于普通用户:
connection.socketCustomEvent = 'super-admin-socket';
connection.openOrJoin('any-room-id', function() {
// check if it is a room owner
if (connection.isInitiator === true) {
// room owner is sharing his room with super-adin
connection.socket.emit(connection.socketCustomEvent, {
newRoom: true,
roomid: connection.sessionid
});
}
});
以下代码适用于超级管理员:
connection.socketCustomEvent = 'super-admin-socket';
connection.dontCaptureUserMedia = true;
connection.connectSocket(function() {
connection.socket.on(connection.socketCustomEvent, function(message) {
if (message.newUser === true) {
connection.join(message.userid);
}
if (message.newRoom === true) {
// display room in a list
// or view room owner's video
connection.join(message.roomid);
}
});
});
<强>结论:强>
超级管理员必须有
userid
来自任何用户才能观看他的视频。