首页 > 解决方案 > 如何制作 OpenTok 视频聊天的截图?

问题描述

我正在尝试 OpenTok(来自 GitHub Basic-Video-Chat 的示例)并想保存屏幕截图。有人可以推荐我怎么做吗?也许,我应该以某种方式从订阅者视图中获取位图?

标签: opentok

解决方案


这是我在 react js 中的表现

  if (
  otCore.internalState &&
  otCore.internalState.subscribers &&
  otCore.internalState.subscribers.camera
) {
  let streams = otCore.internalState.subscribers.camera;
  let key = Object.keys(streams)[0];
  let object = streams[key];
  if (object) {
    let imgData = object.getImgData();

    let div = document.createElement("div");
    div.style =
      "display: flex;justify-content: center;flex-direction: column;justify-items: center;align-items: center; min-height: -webkit-fill-available;";

    let img = document.createElement("img");
    img.setAttribute("src", "data:image/png;base64," + imgData);
    img.setAttribute("height", "60%");
    img.setAttribute("width", "70%");

    var imgWin = window.open("", "", "postwindow");
    imgWin.document.write("<title>DstTok:Annotation</title>");
    imgWin.document.write("<body style='background:#666666'></body>");
    div.appendChild(img);
    imgWin.document.body.appendChild(div);
  }
}

}


推荐阅读