opentok如何隐藏发布者视频显示

opentok how to hide the publisher video display

我正在使用 OpenTok,我正在尝试切换视频显示 on/off。 所以我使用以下 pubOptions

  var pubOptions;
  if (show_video) 
  {
   pubOptions= null;   
  }
  else
  {
   pubOptions= { videoSource: null,  style: {buttonDisplayModeo: 'off'}};
  }
  //Replace the first parameter with the replacement element ID:
  session.on("streamCreated", function(event) 
  {
   session.subscribe(event.stream);
  });
  session.connect(token, function(error) 
  {
   publisher = OT.initPublisher("publisher_text",pubOptions);
   session.publish(publisher);
  });

但是视频 window 在两种情况下都会显示。

https://tokbox.com/opentok/libraries/client/js/reference/OT.html#initPublisher

我相信你想要pubOptions = {publishVideo: false, style:{buttonDisplayMode: 'off'}};

查看以下文档:https://tokbox.com/opentok/tutorials/audio-video/js/#publish_audio_video_only

如果您想在发布后停用视频,您需要:

publisher.publishVideo(false);

我不确定你要找的是不是这个,但你可以试试...

session.unpublish(); //取消发布你的stream/video

session.forceUnpublish(); //取消发布你的 strea/video 并强制其他流也取消发布