艺术家
2025-05-24 6564593ef44090cca74582d7b32ac979c262b908
ÏîÄ¿´úÂë/ÉìËõ¸Ë/client/src/views/tts/PickAndDrop/Manualcontrol.vue
@@ -492,7 +492,16 @@
            <span style="color: #fff; font-size: 1.25rem; font-weight: bold"
              >视频监控右侧</span
            >
            <img src="@/assets/imgs/left.png" alt="" />
            <div
              id="playWnd"
              class="playWnd"
              style="left: 109px; top: 133px"
            ></div>
            <!-- <iframe
              src="http://192.168.2.168/doc/pageview.asp"
              id="childFrame"
              style="height: 100%"
            ></iframe> -->
          </div>
        </div>
      </div>
@@ -509,7 +518,7 @@
  AutoPickAndDrop,
  Pouse,
} from "@/api/newapi/Parameters.js";
// import { WebVideoCtrl } from "@/assets/webControl/webVideoCtrl.js";
const router = useRouter();
const isMobile = ref(false);
const Position = ref({
@@ -584,7 +593,144 @@
    }
  });
};
// const WebVideoCtrl = new WebControl();
// åˆ›å»ºæ’­æ”¾å®žä¾‹
function initPlugin() {
  console.log("initPlugin",new WebControl());
  oWebControl = new WebControl({
    szPluginContainer: "playWnd", // æŒ‡å®šå®¹å™¨id
    iServicePortStart: 15900, // æŒ‡å®šèµ·æ­¢ç«¯å£å·ï¼Œå»ºè®®ä½¿ç”¨è¯¥å€¼
    iServicePortEnd: 15900,
    szClassId: "23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // ç”¨äºŽIE10使用ActiveX的clsid
    cbConnectSuccess: function () {
      // åˆ›å»ºWebControl实例成功
      oWebControl
        .JS_StartService("window", {
          // WebControl实例创建成功后需要启动服务
          dllPath: "./VideoPluginConnect.dll", // å€¼"./VideoPluginConnect.dll"写死
        })
        .then(
          function () {
            // å¯åŠ¨æ’ä»¶æœåŠ¡æˆåŠŸ
            oWebControl.JS_SetWindowControlCallback({
              // è®¾ç½®æ¶ˆæ¯å›žè°ƒ
              cbIntegrationCallBack: cbIntegrationCallBack,
            });
            oWebControl.JS_CreateWnd("playWnd", 1000, 600).then(function () {
              //JS_CreateWnd创建视频播放窗口,宽高可设定
              init(); // åˆ›å»ºæ’­æ”¾å®žä¾‹æˆåŠŸåŽåˆå§‹åŒ–
            });
          },
          function () {
            // å¯åŠ¨æ’ä»¶æœåŠ¡å¤±è´¥
          }
        );
    },
    cbConnectError: function () {
      // åˆ›å»ºWebControl实例失败
      oWebControl = null;
      $("#playWnd").html("插件未启动,正在尝试启动,请稍候...");
      WebControl.JS_WakeUp("VideoWebPlugin://"); // ç¨‹åºæœªå¯åŠ¨æ—¶æ‰§è¡Œerror函数,采用wakeup来启动程序
      initCount++;
      if (initCount < 3) {
        setTimeout(function () {
          initPlugin();
        }, 3000);
      } else {
        $("#playWnd").html("插件启动失败,请检查插件是否安装!");
      }
    },
    cbConnectClose: function (bNormalClose) {
      // å¼‚常断开:bNormalClose = false
      // JS_Disconnect正常断开:bNormalClose = true
      console.log("cbConnectClose");
      oWebControl = null;
      $("#playWnd").html("插件未启动,正在尝试启动,请稍候...");
      WebControl.JS_WakeUp("VideoWebPlugin://");
      initCount++;
      if (initCount < 3) {
        setTimeout(function () {
          initPlugin();
        }, 3000);
      } else {
        $("#playWnd").html("插件启动失败,请检查插件是否安装!");
      }
    },
  });
}
// const initWebVideoCtrl = () => {
//   if (!WebVideoCtrl) {
//     console.error("WebControl æœªæ­£ç¡®åŠ è½½ï¼Œè¯·æ£€æŸ¥ç›¸å…³è„šæœ¬ã€‚");
//     ElMessage.error("WebControl æœªæ­£ç¡®åŠ è½½ï¼Œè¯·æ£€æŸ¥ç›¸å…³è„šæœ¬ã€‚");
//     return;
//   }
//   try {
//     // åˆå§‹åŒ–插件
//     WebVideoCtrl.I_InitPlugin(800, 600, {
//       bWndFull: true, // æ˜¯å¦æ”¯æŒå•窗口全屏
//       iPackageType: 2, // 2 è¡¨ç¤º HLS åè®®
//     });
//     // æ’入插件到指定 DOM å…ƒç´ 
//     WebVideoCtrl.I_InsertOBJECTPlugin("videoDiv");
//     // è®¾å¤‡ä¿¡æ¯
//     const deviceInfo = {
//       sIP: "192.168.2.168", // è®¾å¤‡ IP åœ°å€
//       iPort: 80, // è®¾å¤‡ç«¯å£å·
//       sUsername: "admin", // ç”¨æˆ·å
//       sPassword: "123456", // å¯†ç 
//     };
//     // è°ƒç”¨ç™»å½•设备函数
//     loginDevice(deviceInfo);
//   } catch (error) {
//     console.error("初始化 WebVideoCtrl æ’件时出错:", error);
//     ElMessage.error("初始化 WebVideoCtrl æ’件时出错,请检查配置。");
//   }
// };
// ç™»å½•设备
// const loginDevice = (deviceInfo) => {
//   WebVideoCtrl.I_Login(
//     deviceInfo.sIP,
//     1,
//     deviceInfo.iPort,
//     deviceInfo.sUsername,
//     deviceInfo.sPassword,
//     {
//       success: () => {
//         console.log("登录成功");
//         ElMessage.success("设备登录成功");
//         // å¼€å§‹é¢„览
//         startRealPlay();
//       },
//       error: () => {
//         console.error("登录失败,请检查设备信息和网络连接。");
//         ElMessage.error("设备登录失败,请检查设备信息和网络连接。");
//       },
//     }
//   );
// };
// // å¼€å§‹å®žæ—¶é¢„览函数
// const startRealPlay = () => {
//   try {
//     WebVideoCtrl.I_StartRealPlay(1, {
//       iStreamType: 0, // ä¸»ç æµ
//     });
//     console.log("开始实时预览");
//   } catch (error) {
//     console.error("开始实时预览时出错:", error);
//     ElMessage.error("开始实时预览时出错,请检查设备状态。");
//   }
// };
onMounted(() => {
  initPlugin();
  // initWebVideoCtrl();
  // ç›‘听窗口大小变化
  window.addEventListener("resize", () => {
    nextTick(() => {