测试海康对讲

测试海康对讲
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

4225
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,88 +1,104 @@
<template> <template>
<div class="hkcont"> <div class="hkcont">
<div id="player"> <div id="player"></div>
</div>
<div class="items"> <div class="items">
<div> <div>
<button type="button" @click="startTalk">开始对讲</button> <button type="button" @click="startTalk">开始对讲</button>
<button type="button" @click="stopTalk">停止对讲</button> <button type="button" @click="stopTalk">停止对讲</button>
<!-- <button type="button" onClick="SetVolume()">设置声音</button> --> 设置声音<input type="range" min="0" max="100" step="1" value="50" v-model="inputValue" @change="TalkSetVolume" />
设置声音<input
type="range"
min="0"
max="100"
step="1"
value="50"
v-model="inputValue"
@change="TalkSetVolume"
/>
</div> </div>
</div> </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('/multialarm/talk/channel', { ...date }).then((ress) => { api.post<any>('/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) => { (e: any) => {
console.error(e, "对讲失败"); console.error(e, '对讲失败')
} }
); )
}) })
}
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 stopTalk = ()=>{ }
myPlugin.JS_StopTalk().then(function () {
console.log("关闭对讲 success"); const OpenSound = () => {
}, function () { myPlugin.JS_OpenSound(curIndex).then(
console.log("关闭对讲 failed"); () => {
}); console.info('JS_OpenSound success')
}; // do you want...
// },
const TalkSetVolume = () =>{ (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( myPlugin.JS_TalkSetVolume(parseFloat(inputValue.value)).then(
() => { () => {
console.log("JS_TalkSetVolume success", inputValue.value); console.log('JS_TalkSetVolume success', inputValue.value)
}, },
(err) => { (err: any) => {
console.error("JS_TalkSetVolume failed", err); console.error('JS_TalkSetVolume failed', err)
} }
); )
} }
onMounted(() => { onMounted(() => {
if (typeof window.JSPlugin === 'undefined') { if (typeof window.JSPlugin === 'undefined') {
return return
} else { } else {
} }
api.post('/multialarm/video/preview', {...date}).then((res: JsonResult<any>) => {
api.post('/multialarm/video/preview', { ...date }).then((res : JsonResult<any>) => {
// console.log('router222', res) // console.log('router222', res)
console.log('播放地址', res.data.videoUrl) console.log('播放地址', res.data.videoUrl)
var code = res['code'] var code = res['code']
@ -108,28 +124,6 @@
var controlIndex = 2 var controlIndex = 2
//
// function startTalk() {
// console.log('')
// api.post('/multialarm/talk/channel', { ...date }).then((ress) => {
// console.log('', ress.data.videoUrl);
// // myPlugin.JS_SetConnectTimeOut(0, 3000);
// myPlugin.JS_StartTalk(ress.data.videoUrl).then(
// () => {
// console.log("talkStart success");
// },
// (e) => {
// console.error(e, "");
// }
// );
// })
// }
function playVideo() { function playVideo() {
myPlugin myPlugin
.JS_Play( .JS_Play(
@ -141,8 +135,14 @@
curIndex // curIndex //
) )
.then( .then(
() => { }, () => {
(e : any) => { console.info('JS_Play success')
OpenSound()
GetVolume()
// do you want...
},
(e: any) => {
// console.log('') // console.log('')
controlIndex-- controlIndex--
if (controlIndex <= 0) { if (controlIndex <= 0) {
@ -158,37 +158,37 @@
alert('播放失败') alert('播放失败')
} }
}) })
}) })
// ws // ws
onBeforeUnmount(() => { onBeforeUnmount(() => {
myPlugin.JS_Stop(curIndex).then( myPlugin.JS_Stop(curIndex).then(
() => { () => {
console.info('JS_Stop success') console.info('JS_Stop success')
// do you want... // do you want...
}, },
(err : any) => { (err: any) => {
console.info('JS_Stop failed:', err) console.info('JS_Stop failed:', err)
// do you want... // 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)