我使用 opentok 创建了在线教育视频门户。学生人数应该看到老师的视频。老师也会看到所有连接学生的视频。使用以下代码,我可以防止自己订阅:-
function subscribeToStreams(streams) {
for (var i = 0; i < streams.length; i++) {
// Make sure we don't subscribe to ourself
if (streams[i].connection.connectionId == session.connection.connectionId) {
return;
}
//if (streams[i].connection.connectionId != session.connection.connectionId) {
// Create the div to put the subscriber element in to
var container = document.getElementById('videoContainer');
var div = document.createElement('div');
var id = 'stream' + streams[i].streamId;
div.setAttribute('id', id);
container.appendChild(div);
// Subscribe to the stream
session.subscribe(streams[i], div.id);
div.style.width = '20%';
div.style.height = '20%';
div.style.left = '80%';
//}
}
}
我想阻止学生看到其他学生视频。学生应该只能看到老师的视频。
帮助将不胜感激。谢谢