| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="video_app"> |
| | | <div class="player_bg" ref="videoRef" style="width: 100%;height: 100%;" id="playWnd"> </div> |
| | | </div> |
| | | <!-- <img style="width: 34px;margin-bottom: 16px;" src="../../assets/images/SecurityControl/ic_unable@2x.png" > --> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted, onUnmounted, watch } from 'vue' |
| | | const props = defineProps({ |
| | | indexCode: String, |
| | | href: String, |
| | | }) |
| | | const templateA = ` |
| | | <div style="width:100%;height: 100%;display: flex;justify-content: center;align-items: center;flex-direction: column;"> |
| | | <div style="font-weight: 500;font-size: 15px;color: #CCCCCC;margin-bottom: 4px;">æ æ³ææ¾çæ§ç»é¢ï¼</div> |
| | | <div style="font-weight: 500;font-size: 15px;color: #CCCCCC;margin-bottom: 20px;">ç¹å»ä¸è½½å¹¶å®è£
è§å±ææ¾æä»¶</div> |
| | | <a href="${props.href}" target="_blank" style="font-weight: 500;font-size: 15px;color: #01D9FE;">ç¹å»ä¸è½½</a> |
| | | </div> |
| | | ` |
| | | |
| | | |
| | | const width = ref(0) |
| | | const height = ref(0) |
| | | const videoRef = ref(null) |
| | | |
| | | onMounted(() => { |
| | | const rect = videoRef.value.getBoundingClientRect() |
| | | width.value = rect.width |
| | | height.value = rect.height |
| | | |
| | | initPlugin() |
| | | window.addEventListener('resize', function () { // æ§è¡ |
| | | if (oWebControl.value) { |
| | | const rect = videoRef.value.getBoundingClientRect() |
| | | width.value = rect.width |
| | | height.value = rect.height |
| | | oWebControl.value.JS_Resize($('#playWnd').width(), $('#playWnd').height()) |
| | | } |
| | | }) |
| | | }) |
| | | onUnmounted(() => { |
| | | destroyed() |
| | | }) |
| | | const oWebControl = ref(null) |
| | | const initCount = ref() |
| | | const pubKey = ref('') |
| | | |
| | | watch( |
| | | () => props.indexCode, |
| | | (newValue, oldValue) => { |
| | | console.log('ç¶ç»ä»¶ä¼ å¼ååï¼', newValue) |
| | | videoPlay() |
| | | } |
| | | ) |
| | | |
| | | const initPlugin = () => { |
| | | oWebControl.value = new WebControl({ |
| | | szPluginContainer: "playWnd", // æå®å®¹å¨id |
| | | iServicePortStart: 15900, // æå®èµ·æ¢ç«¯å£å·ï¼å»ºè®®ä½¿ç¨è¯¥å¼ |
| | | iServicePortEnd: 15900, |
| | | szClassId: "23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // ç¨äºIE10使ç¨ActiveXçclsid |
| | | cbConnectSuccess: function () { |
| | | // å建WebControlå®ä¾æå |
| | | console.log('1--å建WebControlå®ä¾æå') |
| | | |
| | | oWebControl.value.JS_StartService("window", { // WebControlå®ä¾å建æååéè¦å¯å¨æå¡ |
| | | dllPath: "./VideoPluginConnect.dll" // å¼"./VideoPluginConnect.dll"åæ» |
| | | }).then(function () { |
| | | oWebControl.value.JS_SetWindowControlCallback({ // è®¾ç½®æ¶æ¯åè° |
| | | cbIntegrationCallBack: cbIntegrationCallBack |
| | | })// å¯å¨æä»¶æå¡æå |
| | | oWebControl.value.JS_CreateWnd("playWnd", width.value, height.value).then(function () { //JS_CreateWndå建è§é¢ææ¾çªå£ï¼å®½é«å¯è®¾å®ï¼boxWidth, boxHeightå®¹å¨ |
| | | // oWebControl.value.JS_CreateWnd("playWnd").then(function () { //JS_CreateWndå建è§é¢ææ¾çªå£ï¼å®½é«å¯è®¾å®ï¼boxWidth, boxHeightå®¹å¨ |
| | | init() // åå»ºææ¾å®ä¾æåååå§å |
| | | }) |
| | | }, function () { // å¯å¨æä»¶æå¡å¤±è´¥ |
| | | }) |
| | | }, |
| | | cbConnectError: function () { // å建WebControlå®ä¾å¤±è´¥ |
| | | console.log('å建WebControlå®ä¾å¤±è´¥') |
| | | oWebControl.value = null |
| | | $("#playWnd").html("æä»¶æªå¯å¨ï¼æ£å¨å°è¯å¯å¨ï¼è¯·ç¨å...") |
| | | WebControl.JS_WakeUp("VideoWebPlugin://") // ç¨åºæªå¯å¨æ¶æ§è¡error彿°ï¼éç¨wakeupæ¥å¯å¨ç¨åº |
| | | initCount.value++ |
| | | if (initCount.value < 3) { |
| | | setTimeout(function () { |
| | | initPlugin() |
| | | }, 3000) |
| | | } else { |
| | | $("#playWnd").html(templateA) |
| | | } |
| | | }, |
| | | cbConnectClose: function (bNormalClose) { |
| | | // å¼å¸¸æå¼ï¼bNormalClose = false |
| | | // JS_Disconnectæ£å¸¸æå¼ï¼bNormalClose = true |
| | | console.log('å¼å¸¸æå¼ï¼bNormalClose') |
| | | oWebControl.value = null |
| | | $("#playWnd").html("æä»¶æªå¯å¨ï¼æ£å¨å°è¯å¯å¨ï¼è¯·ç¨å...") |
| | | WebControl.JS_WakeUp("VideoWebPlugin://") |
| | | initCount.value++ |
| | | if (initCount.value < 3) { |
| | | setTimeout(function () { |
| | | initPlugin() |
| | | }, 3000) |
| | | } else { |
| | | $("#playWnd").html(templateA) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | // åå§å |
| | | const init = () => { |
| | | getPubKey(function () { |
| | | ////////////////////////////////// 请èªè¡ä¿®æ¹ä»¥ä¸åéå¼ //////////////////////////////////// |
| | | let appkey = "23154099" //综åå®é²ç®¡ç平尿ä¾çappkeyï¼å¿
å¡« |
| | | // let secret = '88wFsg3xfn7o8QMsWEO2' //综åå®é²ç®¡ç平尿ä¾çsecretï¼å¿
å¡« |
| | | let secret = setEncrypt("88wFsg3xfn7o8QMsWEO2") //综åå®é²ç®¡ç平尿ä¾çsecretï¼å¿
å¡« |
| | | let ip = "10.50.250.253" //综åå®é²ç®¡çå¹³å°IPå°åï¼å¿
å¡« |
| | | let playMode = 0 //åå§ææ¾æ¨¡å¼ï¼0-é¢è§(宿¶æµ)ï¼1-åæ¾(è§é¢) |
| | | let port = 443 //综åå®é²ç®¡çå¹³å°ç«¯å£ï¼è¥å¯ç¨HTTPSåè®®ï¼é»è®¤443 |
| | | let snapDir = "D:\\SnapDir" //æå¾åå¨è·¯å¾ |
| | | let videoDir = "D:\\VideoDir" //ç´§æ¥å½åæå½ååªè¾åå¨è·¯å¾ |
| | | let layout = "1x1" //playModeæå®æ¨¡å¼çå¸å± |
| | | let enableHTTPS = 1 //æ¯å¦å¯ç¨HTTPSåè®®ä¸ç»¼åå®é²ç®¡çå¹³å°äº¤äºï¼è¿éæ»æ¯å¡«1 |
| | | let encryptedFields = 'secret' //å å¯å段ï¼é»è®¤å å¯é¢å为secret |
| | | let showToolbar = 1 //æ¯å¦æ¾ç¤ºå·¥å
·æ ï¼0-䏿¾ç¤ºï¼é0-æ¾ç¤º |
| | | let showSmart = 1 //æ¯å¦æ¾ç¤ºæºè½ä¿¡æ¯ï¼å¦é
置移å¨ä¾¦æµåç»é¢ä¸ç线æ¡ï¼ï¼0-䏿¾ç¤ºï¼é0-æ¾ç¤º |
| | | let buttonIDs = "0,16,256,257,258,259,260,513,514,515,516,517,768" //èªå®ä¹å·¥å
·æ¡æé® |
| | | oWebControl.value.JS_RequestInterface({ |
| | | funcName: "init", |
| | | argument: JSON.stringify({ |
| | | appkey: appkey, //APIç½å
³æä¾çappkey |
| | | secret: secret, //APIç½å
³æä¾çsecret |
| | | ip: ip, //APIç½å
³IPå°å |
| | | playMode: playMode, //ææ¾æ¨¡å¼ï¼å³å®æ¾ç¤ºé¢è§è¿æ¯åæ¾çé¢ï¼ |
| | | port: port, //ç«¯å£ |
| | | snapDir: snapDir, //æå¾åå¨è·¯å¾ |
| | | videoDir: videoDir, //ç´§æ¥å½åæå½ååªè¾åå¨è·¯å¾ |
| | | layout: layout, //å¸å± |
| | | enableHTTPS: enableHTTPS, //æ¯å¦å¯ç¨HTTPSåè®® |
| | | encryptedFields: encryptedFields, //å å¯å段 |
| | | showToolbar: showToolbar, //æ¯å¦æ¾ç¤ºå·¥å
·æ |
| | | showSmart: showSmart, //æ¯å¦æ¾ç¤ºæºè½ä¿¡æ¯ |
| | | buttonIDs: buttonIDs //èªå®ä¹å·¥å
·æ¡æé® |
| | | }) |
| | | }).then(function (oData) { |
| | | console.log('åå§åæå') |
| | | videoPlay() |
| | | // oWebControl.value.JS_Resize(that.boxWidth, that.boxHeight) // åå§ååresize䏿¬¡ï¼è§é¿firefoxä¸é¦æ¬¡æ¾ç¤ºçªå£åæä»¶çªå£æªä¸DIVçªå£éåé®é¢ |
| | | }) |
| | | }) |
| | | } |
| | | const videoPlay = () => { |
| | | console.log('å¼å§ææ¾') |
| | | |
| | | oWebControl.value.JS_RequestInterface({ |
| | | funcName: "startPreview", |
| | | argument: JSON.stringify({ |
| | | cameraIndexCode: props.indexCode, //çæ§ç¹ç¼å· |
| | | streamMode: 0, //主åç æµæ è¯ï¼0-ä¸»ç æµï¼1-åç æµ |
| | | transMode: 1, //ä¼ è¾åè®®ï¼0-UDPï¼1-TCP |
| | | gpuMode: 0, //æ¯å¦å¯ç¨GPU硬解ï¼0-ä¸å¯ç¨ï¼1-å¯ç¨ |
| | | wndId: -1 //ææ¾çªå£åºå·ï¼å¨2x2以ä¸å¸å±ä¸å¯æå®ææ¾çªå£ï¼ |
| | | }) |
| | | }).then((oData) => { |
| | | if (oData.responseMsg.code === 1) { |
| | | console.log('ææ¾æå', oData) |
| | | } |
| | | }, err => { |
| | | console.log('err', err) |
| | | |
| | | }) |
| | | } |
| | | // 鿝 |
| | | const destroyed = () => { |
| | | if (oWebControl.value) { |
| | | oWebControl.value.JS_HideWnd() // å
让çªå£éèï¼è§é¿æä»¶çªå£æ»åäºæµè§å¨æ¶å¤±é®é¢ |
| | | oWebControl.value.JS_Disconnect().then(function () { }, function () { }) |
| | | } |
| | | } |
| | | |
| | | function fileDown() { |
| | | window.open('./videoUrl/VideoWebPlugin.exe') |
| | | } |
| | | // æ¶æ¯åè° |
| | | const cbIntegrationCallBack = (oData) => { |
| | | let response = oData.responseMsg |
| | | // response.type=1 éä¸çªå£æ¶æ¯ type=2 ææ¾æ¶æ¯ |
| | | } |
| | | // çæ§ |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // è·åå
¬é¥ |
| | | function getPubKey(callback) { |
| | | oWebControl.value.JS_RequestInterface({ |
| | | funcName: 'getRSAPubKey', |
| | | argument: JSON.stringify({ |
| | | keyLength: 1024, |
| | | }), |
| | | }).then((oData) => { |
| | | if (oData.responseMsg.data) { |
| | | pubKey.value = oData.responseMsg.data |
| | | callback() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // RSAå å¯ |
| | | function setEncrypt(value) { |
| | | let that = this |
| | | let encrypt = new JSEncrypt() |
| | | encrypt.setPublicKey(pubKey.value) |
| | | return encrypt.encrypt(value) |
| | | } |
| | | |
| | | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .video_app { |
| | | width: 100%; |
| | | height: 100%; |
| | | |
| | | } |
| | | </style> |