Warm tip: This article is reproduced from serverfault.com, please click

javascript-如何在没有 Object 标签的 JS 中管理 Activex 事件

(javascript - How to manage Activex events in JS without Object tag)

发布于 2021-02-18 18:38:00

嗨,我正在开发 Activex 控件来管理 IE 中的网络摄像头,一切正常,但我需要在捕获新帧时刷新图像,到目前为止我单击时显示图像,但我想在 JS 中收听“捕获的帧事件”以刷新我的 html 视图。

我看过很多示例,但所有这些都在 html 中使用 Object 标记

<object id="Control" classid="CLSID:id"/>
    <script for="Control" event="myEvent()">
        alert("hello");
    </script>

有没有办法使用纯 JS 来监听 activex 事件?使用 :

Ob = new ActivexObject('PROG.ID');
Questioner
luis juarez
Viewed
11
luis juarez 2021-02-25 03:26:05

我最终使用了计时器,当我单击视图中的启用按钮时,我调用了方法 startRecord,在此方法中,我每 70 毫秒读取一次 Activex 值,我宁愿不使用计时器,但它可以工作。

private async startRecord() {
    while (this.banCapturing) {
      await new Promise(res => setTimeout(res, 70)); //14 ~ 15 fps
      this.foto = this.Ob.imageBase64; //Read Activex Value, DLL is updating imageBase64 on camera event.
    }
  }