-1

我正在创建音频/视频/文本聊天应用程序。我已成功完成视频会议功能。但我不知道未经用户许可访问用户的网络摄像头。

我到底想要做的是管理员可以访问用户的网络摄像头。我已经创建了在线用户列表。当管理员单击Watch在线用户的按钮时,管理员应该能够访问用户的网络摄像头,以便管理员可以从该特定用户的网络摄像头中看到。

任何人都可以指导我这样做吗?

在此处输入图像描述

4

1 回答 1

1

超级管理员可以查看所有房间,从任何房间的任何用户那里获取视频。

您可以使用 socket.io 或其他 PHP/mySQL 与超级管理员共享房间。

超级管理员可以使用“加入”方法查看任何用户的视频:

var selectedUserId = database.getSelectedUserId();
connection.join(selectedUserId);

超级管理员必须设置“dontCaptureUserMedia=true”以确保他不共享自己的相机。这意味着超级管理员可以从任何房间无缝查看任何用户的视频。

connection.dontCaptureUserMedia = true;
var selectedUserId = database.getSelectedUserId();
connection.join(selectedUserId);

了解如何使用 socket.io 发送或接收自定义消息并尝试演示

这是超级管理员的示例代码:

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从任何用户那里查看他的视频。

于 2017-09-28T08:38:33.413 回答