TokBox:有没有办法重新创建视频 window?
TokBox: is there way to recreate video window?
创建会话时,我们传递元素的 ID 以替换为视频 window。但是如果元素从 DOM 树中移除,我们可以将会话重新绑定到另一个元素吗?
无法将发布者或订阅者重新绑定到已初始化的不同元素。
相反,您应该创建一个提供给 publisher/subscriber 的容器,然后您可以根据需要将该容器附加并移动到 DOM 中的任何位置。
例如:
const pubContainer = document.createElement('div');
const publisher = OT.initPublisher(pubContainer);
session.publish(publisher);
document.getElementById('A').appendChild(pubContainer);
然后:
pubContainer.parentElement.removeChild(pubContainer);
document.getElementById('B').appendChild(pubContainer);
创建会话时,我们传递元素的 ID 以替换为视频 window。但是如果元素从 DOM 树中移除,我们可以将会话重新绑定到另一个元素吗?
无法将发布者或订阅者重新绑定到已初始化的不同元素。
相反,您应该创建一个提供给 publisher/subscriber 的容器,然后您可以根据需要将该容器附加并移动到 DOM 中的任何位置。
例如:
const pubContainer = document.createElement('div');
const publisher = OT.initPublisher(pubContainer);
session.publish(publisher);
document.getElementById('A').appendChild(pubContainer);
然后:
pubContainer.parentElement.removeChild(pubContainer);
document.getElementById('B').appendChild(pubContainer);