测试海康对讲

测试海康对讲
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>
<div class="hkcont">
<div id="player">
</div>
<div class="items">
<div>
<button type="button" @click="startTalk">开始对讲</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"
/>
</div>
</div>
</div>
<div class="hkcont">
<div id="player"></div>
<div class="items">
<div>
<button type="button" @click="startTalk">开始对讲</button>
<button type="button" @click="stopTalk">停止对讲</button>
设置声音<input type="range" min="0" max="100" step="1" value="50" v-model="inputValue" @change="TalkSetVolume" />
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import api from '@/axios'
import { Ref, ref, watch, onMounted, onBeforeMount, onBeforeUnmount, reactive, getCurrentInstance } from 'vue'
import { useRouter } from 'vue-router'
import { JsonResult } from '@/axios'
const router = useRouter()
const infoData = ref()
const inputValue = ref(50)
var curIndex = 0 //
let myPlugin : any
//
let date = {
pointId: router.currentRoute.value.query.pointId,
useTLS: 0
}
if (process.env.NODE_ENV === 'production') {
date.useTLS = 1
}
const 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, "对讲失败");
}
);
})
}
//
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
})
import api from '@/axios'
import {ref, onMounted, onBeforeUnmount} from 'vue'
import {useRouter} from 'vue-router'
import {JsonResult} from '@/axios'
const router = useRouter()
const inputValue = ref(50)
var curIndex = 0 //
let myPlugin: any
//
let date = {
pointId: router.currentRoute.value.query.pointId,
useTLS: 0
}
if (process.env.NODE_ENV === 'production') {
date.useTLS = 1
}
const startTalk = () => {
console.log('开启对讲')
api.post<any>('/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: any) => {
console.error(e, '对讲失败')
}
)
})
}
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 {
}
//
// 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, "");
// }
// );
// })
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
function playVideo() {
myPlugin
.JS_Play(
playURL,
{
playURL: playURL, //
mode: 1 // 0=; 1= 0
},
curIndex //
)
.then(
() => { },
(e : any) => {
// console.log('')
controlIndex--
if (controlIndex <= 0) {
return
}
// console.info('JS_Play failed:', e)
playVideo()
}
)
}
playVideo()
} else {
alert('播放失败')
}
})
})
function playVideo() {
myPlugin
.JS_Play(
playURL,
{
playURL: playURL, //
mode: 1 // 0=; 1= 0
},
curIndex //
)
.then(
() => {
console.info('JS_Play success')
// 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...
}
)
})
OpenSound()
GetVolume()
// do you want...
},
(e: any) => {
// console.log('')
controlIndex--
if (controlIndex <= 0) {
return
}
// 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>
<style scoped lang="scss">
.hkcont{
height: 100%;
width: 100%;
position: relative;
#player {
height:100%;
width: 100%;
background: #000;
}
.items {
border: 1px solid #444444;position:absolute;bottom:0px;
}
}
</style>
.hkcont {
height: 100%;
width: 100%;
position: relative;
#player {
height: 100%;
width: 100%;
background: #000;
}
.items {
border: 1px solid #444444;
position: absolute;
bottom: 0px;
}
}
</style>

View File

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