测试海康对讲

测试海康对讲
This commit is contained in:
TimSpan 2024-09-02 15:08:28 +08:00
parent 13c1e97405
commit bac75ee325
4 changed files with 1717 additions and 3136 deletions

File diff suppressed because one or more lines are too long

4485
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,194 +1,194 @@
<template> <template>
<div class="hkcont"> <div class="hkcont">
<div id="player"> <div id="player"></div>
<div class="items">
</div> <div>
<div class="items"> <button type="button" @click="startTalk">开始对讲</button>
<div> <button type="button" @click="stopTalk">停止对讲</button>
<button type="button" @click="startTalk">开始对讲</button> 设置声音<input type="range" min="0" max="100" step="1" value="50" v-model="inputValue" @change="TalkSetVolume" />
<button type="button" @click="stopTalk">停止对讲</button> </div>
<!-- <button type="button" onClick="SetVolume()">设置声音</button> --> </div>
设置声音<input </div>
type="range"
min="0"
max="100"
step="1"
value="50"
v-model="inputValue"
@change="TalkSetVolume"
/>
</div>
</div>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import api from '@/axios' import api from '@/axios'
import { Ref, ref, watch, onMounted, onBeforeMount, onBeforeUnmount, reactive, getCurrentInstance } from 'vue' import {ref, onMounted, onBeforeUnmount} from 'vue'
import { useRouter } from 'vue-router' import {useRouter} from 'vue-router'
import { JsonResult } from '@/axios' import {JsonResult} from '@/axios'
const router = useRouter() const router = useRouter()
const infoData = ref() const inputValue = ref(50)
const inputValue = ref(50) var curIndex = 0 //
var curIndex = 0 // let myPlugin: any
let myPlugin : any //
// let date = {
let date = { pointId: router.currentRoute.value.query.pointId,
pointId: router.currentRoute.value.query.pointId, useTLS: 0
useTLS: 0 }
} if (process.env.NODE_ENV === 'production') {
if (process.env.NODE_ENV === 'production') { date.useTLS = 1
date.useTLS = 1 }
} const startTalk = () => {
const startTalk = () => { console.log('开启对讲')
console.log('开启对讲') api.post<any>('/multialarm/talk/channel', {...date}).then((ress) => {
api.post('/multialarm/talk/channel', { ...date }).then((ress) => { console.log('对讲地址', ress.data.videoUrl)
console.log('对讲地址', ress.data.videoUrl); myPlugin.JS_SetConnectTimeOut(0, 3000)
myPlugin.JS_SetConnectTimeOut(0, 3000); myPlugin.JS_StartTalk(ress.data.videoUrl).then(
myPlugin.JS_StartTalk(ress.data.videoUrl).then( () => {
() => { console.log('talkStart success')
console.log("talkStart success"); },
}, (e: any) => {
(e) => { console.error(e, '对讲失败')
console.error(e, "对讲失败"); }
} )
); })
}) }
}
//
const stopTalk = ()=>{
myPlugin.JS_StopTalk().then(function () {
console.log("关闭对讲 success");
}, function () {
console.log("关闭对讲 failed");
});
};
//
const TalkSetVolume = () =>{
myPlugin.JS_TalkSetVolume(parseFloat(inputValue.value)).then(
() => {
console.log("JS_TalkSetVolume success", inputValue.value);
},
(err) => {
console.error("JS_TalkSetVolume failed", err);
}
);
}
onMounted(() => {
if (typeof window.JSPlugin === 'undefined') {
return
} else {
}
api.post('/multialarm/video/preview', { ...date }).then((res : JsonResult<any>) => {
// console.log('router222', res)
console.log('播放地址', res.data.videoUrl)
var code = res['code']
if (code == 0) {
var playURL = res.data.videoUrl
// var playURL = 'wss://w.hnjinglian.cn:2563/haikang play/openUrl/w64vRni'
var IS_MOVE_DEVICE = document.body.clientWidth < 992 //
var MSE_IS_SUPPORT = !!window.MediaSource // mse
myPlugin = new window.JSPlugin({
// div#play_windowiWidthiHeight
// iWidth: 600,
// iHeight: 400,
szId: 'player', //
szBasePath: '/haikang', // ,h5player.min.js
iMaxSplit: 1, // 4*4
iCurrentSplit: IS_MOVE_DEVICE ? 1 : 2,
openDebug: true,
oStyle: {
borderSelect: IS_MOVE_DEVICE ? '#000' : '#FFCC00'
},
bSupporDoubleClickFull: true //true
})
var controlIndex = 2 const GetVolume = () => {
myPlugin.JS_GetVolume(curIndex).then(
(volumn: any) => {
//50
console.info('JS_GetVolume success', volumn)
// do you want...
},
(err: any) => {
console.info('JS_GetVolume failed')
// do you want...
}
)
}
const OpenSound = () => {
myPlugin.JS_OpenSound(curIndex).then(
() => {
console.info('JS_OpenSound success')
// do you want...
},
(err: any) => {
console.info('JS_OpenSound failed')
// do you want...
}
)
}
//
const stopTalk = () => {
myPlugin.JS_StopTalk().then(
function () {
console.log('关闭对讲 success')
},
function () {
console.log('关闭对讲 failed')
}
)
}
//
const TalkSetVolume = () => {
myPlugin.JS_TalkSetVolume(parseFloat(inputValue.value)).then(
() => {
console.log('JS_TalkSetVolume success', inputValue.value)
},
(err: any) => {
console.error('JS_TalkSetVolume failed', err)
}
)
}
onMounted(() => {
if (typeof window.JSPlugin === 'undefined') {
return
} else {
}
// api.post('/multialarm/video/preview', {...date}).then((res: JsonResult<any>) => {
// function startTalk() { // console.log('router222', res)
// console.log('') console.log('播放地址', res.data.videoUrl)
// api.post('/multialarm/talk/channel', { ...date }).then((ress) => { var code = res['code']
// console.log('', ress.data.videoUrl); if (code == 0) {
// // myPlugin.JS_SetConnectTimeOut(0, 3000); var playURL = res.data.videoUrl
// myPlugin.JS_StartTalk(ress.data.videoUrl).then( // var playURL = 'wss://w.hnjinglian.cn:2563/haikang play/openUrl/w64vRni'
// () => { var IS_MOVE_DEVICE = document.body.clientWidth < 992 //
// console.log("talkStart success"); var MSE_IS_SUPPORT = !!window.MediaSource // mse
// }, myPlugin = new window.JSPlugin({
// (e) => { // div#play_windowiWidthiHeight
// console.error(e, ""); // iWidth: 600,
// } // iHeight: 400,
// ); szId: 'player', //
// }) szBasePath: '/haikang', // ,h5player.min.js
iMaxSplit: 1, // 4*4
iCurrentSplit: IS_MOVE_DEVICE ? 1 : 2,
openDebug: true,
oStyle: {
borderSelect: IS_MOVE_DEVICE ? '#000' : '#FFCC00'
},
bSupporDoubleClickFull: true //true
})
// } var controlIndex = 2
function playVideo() { function playVideo() {
myPlugin myPlugin
.JS_Play( .JS_Play(
playURL, playURL,
{ {
playURL: playURL, // playURL: playURL, //
mode: 1 // 0=; 1= 0 mode: 1 // 0=; 1= 0
}, },
curIndex // curIndex //
) )
.then( .then(
() => { }, () => {
(e : any) => { console.info('JS_Play success')
// console.log('')
controlIndex--
if (controlIndex <= 0) {
return
}
// console.info('JS_Play failed:', e)
playVideo()
}
)
}
playVideo()
} else {
alert('播放失败')
}
})
})
// ws OpenSound()
onBeforeUnmount(() => { GetVolume()
myPlugin.JS_Stop(curIndex).then( // do you want...
() => { },
console.info('JS_Stop success') (e: any) => {
// do you want... // console.log('')
}, controlIndex--
(err : any) => { if (controlIndex <= 0) {
console.info('JS_Stop failed:', err) return
// do you want... }
} // console.info('JS_Play failed:', e)
) playVideo()
}) }
)
}
playVideo()
} else {
alert('播放失败')
}
})
})
// ws
onBeforeUnmount(() => {
myPlugin.JS_Stop(curIndex).then(
() => {
console.info('JS_Stop success')
// do you want...
},
(err: any) => {
console.info('JS_Stop failed:', err)
// do you want...
}
)
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.hkcont{ .hkcont {
height: 100%; height: 100%;
width: 100%; width: 100%;
position: relative; position: relative;
#player { #player {
height:100%; height: 100%;
width: 100%; width: 100%;
background: #000; background: #000;
} }
.items { .items {
border: 1px solid #444444;position:absolute;bottom:0px; border: 1px solid #444444;
} position: absolute;
} bottom: 0px;
}
}
</style> </style>

View File

@ -856,8 +856,8 @@ const initMapdt = (data: any, podat: any, name: any) => {
} }
if (name !== '湖南省') { if (name !== '湖南省') {
// option.series = option.series.filter((series) => series.type !== 'lines') // option.series = option.series.filter((series) => series.type !== 'lines')
// option.series[1].data = [] option.series[1].data = []
// option.series[2].data = [] option.series[2].data = []
myChart.setOption(option) myChart.setOption(option)
} else { } else {
myChart.setOption(option) myChart.setOption(option)