[英]Tokbox/Opentok: How to not display published video
I'm trying to achieve a video conference between 2 users. 我正在尝试实现2位用户之间的视频会议。 Below code displays published video and subscribed video.
下面的代码显示发布的视频和订阅的视频。 I want to publish but not display the published video to the user and only display subscribed video.
我想发布但不向用户显示已发布的视频,而只显示订阅的视频。 How to achieve that?
如何实现呢? Thanks in advance!
提前致谢!
var session = OT.initSession(apiKey, sessionId)
.connect(token, function(error) {
var publisher = OT.initPublisher('divPublish');
session.publish(publisher);
console.log("Publishing to session1");
});
var session2 = OT.initSession(apiKey, sessionId2);
session2.connect(token2, function(error) {
if (error) {
console.log("Error connecting: ", error.name, error.message);
} else {
console.log("Connected to the session2.");
}
});
session2.on("streamCreated", function(event) {
//var options = { width: 400, height: 300, insertMode: 'append' }
session2.subscribe(event.stream, 'divSubscribe');
console.log("Subscribing to session2");
});
You can initialise a publisher that doesn't appear on the page by providing a detached DOM element as the first argument: 您可以通过提供一个分离的DOM元素作为第一个参数来初始化不在页面上显示的发布者:
const container = document.createElement('div');
const publisher = OT.initPublisher(container);
It's up to you if you want to attach that container
to the page or not. 是否要将该
container
附加到页面取决于您。
See targetElement
argument of OT.initPublisher
: https://tokbox.com/developer/sdks/js/reference/OT.html#initPublisher 请参阅
targetElement
参数: https : OT.initPublisher
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.