|
@ -1,8 +1,6 @@ |
|
|
<template> |
|
|
<template> |
|
|
|
|
|
|
|
|
<div id="videoWrapper"> |
|
|
<div id="videoWrapper"> |
|
|
<canvas ref="videoCanvas" id="videoCanvas" :width="canvasWidth" :height="canvasHeight"> |
|
|
|
|
|
</canvas> |
|
|
|
|
|
<!-- <video ref="videoPlayer" id="videoPlayer" disablePictureInPicture autoplay muted |
|
|
<!-- <video ref="videoPlayer" id="videoPlayer" disablePictureInPicture autoplay muted |
|
|
@loadedmetadata="changeVideoCanvasSize" @mouseover="mouseOverVideo" @mouseout="mouseOutVideo" |
|
|
@loadedmetadata="changeVideoCanvasSize" @mouseover="mouseOverVideo" @mouseout="mouseOutVideo" |
|
|
@mousedown="mouseDownVideo"> |
|
|
@mousedown="mouseDownVideo"> |
|
@ -82,10 +80,10 @@ import VideoControlSimple from './VideoControl/VideoControlSimple.vue'; |
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
|
|
let piniaStore = useStore(); |
|
|
let piniaStore = useStore(); |
|
|
let player = <HTMLVideoElement>document.querySelector('#videoPlayer') |
|
|
let player = <HTMLVideoElement>document.querySelector('#videoPlayer') |
|
|
let canvas = <HTMLCanvasElement>document.querySelector('#videoCanvas') |
|
|
|
|
|
let canvasWidth = ref(0) |
|
|
let canvasWidth = ref(0) |
|
|
let canvasHeight = ref(0) |
|
|
let canvasHeight = ref(0) |
|
|
let curSelectKey = storeToRefs(piniaStore).curSelectKey |
|
|
let curSelectKey = storeToRefs(piniaStore).curSelectKey |
|
|
|
|
|
let closeVideoKey = storeToRefs(piniaStore).closeVideoKey |
|
|
let cameraMap = storeToRefs(piniaStore).cameraMap |
|
|
let cameraMap = storeToRefs(piniaStore).cameraMap |
|
|
let isActiveChoose = ref(false) |
|
|
let isActiveChoose = ref(false) |
|
|
let labelList = ref<any[]>([]) |
|
|
let labelList = ref<any[]>([]) |
|
@ -97,7 +95,6 @@ const curVideoKey=ref() |
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
{ |
|
|
{ |
|
|
player = <HTMLVideoElement>document.querySelector('#videoPlayer'); |
|
|
player = <HTMLVideoElement>document.querySelector('#videoPlayer'); |
|
|
canvas = <HTMLCanvasElement>document.querySelector('#videoCanvas'); |
|
|
|
|
|
loadVideoPlayer(); |
|
|
loadVideoPlayer(); |
|
|
loadVideoCanvas(); |
|
|
loadVideoCanvas(); |
|
|
changeVideoCanvasSize(); |
|
|
changeVideoCanvasSize(); |
|
@ -110,6 +107,14 @@ onMounted(() => { |
|
|
watch(curSelectKey, (newVal, oldVal) => { |
|
|
watch(curSelectKey, (newVal, oldVal) => { |
|
|
switchCamera(newVal) |
|
|
switchCamera(newVal) |
|
|
}) |
|
|
}) |
|
|
|
|
|
watch(closeVideoKey, (newVal, oldVal) => { |
|
|
|
|
|
if (curVideoKey.value == newVal) { |
|
|
|
|
|
destroyVideo() |
|
|
|
|
|
piniaStore.updateCloseVideoKey("") |
|
|
|
|
|
piniaStore.updateCurSelectKey("") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
watch(addLabel, (newVal, oldVal) => { |
|
|
watch(addLabel, (newVal, oldVal) => { |
|
|
if (newVal.isAddLabel) { |
|
|
if (newVal.isAddLabel) { |
|
|
isActiveChoose.value = true |
|
|
isActiveChoose.value = true |
|
@ -120,6 +125,11 @@ watch(addLabel, (newVal, oldVal) => { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
function destroyVideo() { |
|
|
|
|
|
jessibuca.value.destroy(); |
|
|
|
|
|
create() |
|
|
|
|
|
labelList.value = [] |
|
|
|
|
|
} |
|
|
//创建流媒体 |
|
|
//创建流媒体 |
|
|
function create() { |
|
|
function create() { |
|
|
var showOperateBtns = false; // 是否显示按钮 |
|
|
var showOperateBtns = false; // 是否显示按钮 |
|
@ -226,18 +236,7 @@ function changeVideoCanvasSize() { |
|
|
canvasWidth.value = player.clientWidth; |
|
|
canvasWidth.value = player.clientWidth; |
|
|
canvasHeight.value = player.clientHeight; |
|
|
canvasHeight.value = player.clientHeight; |
|
|
} |
|
|
} |
|
|
function mouseOverVideo() { |
|
|
|
|
|
// console.log("移入"); |
|
|
|
|
|
|
|
|
|
|
|
if (!isActiveChoose.value) return; |
|
|
|
|
|
player.classList.add('activeChoose'); |
|
|
|
|
|
} |
|
|
|
|
|
function mouseOutVideo() { |
|
|
|
|
|
// console.log("移除"); |
|
|
|
|
|
|
|
|
|
|
|
if (!isActiveChoose) return; |
|
|
|
|
|
player.classList.remove('activeChoose'); |
|
|
|
|
|
} |
|
|
|
|
|
function mouseDownVideo(e: MouseEvent) { |
|
|
function mouseDownVideo(e: MouseEvent) { |
|
|
|
|
|
|
|
|
if (!isActiveChoose.value) return; |
|
|
if (!isActiveChoose.value) return; |
|
@ -316,11 +315,9 @@ function switchCamera(cameraId: string) { |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
jessibuca.value.destroy(); |
|
|
destroyVideo() |
|
|
create() |
|
|
|
|
|
labelList.value = [] |
|
|
|
|
|
console.log('connect webrtc-steamer.'); |
|
|
console.log('connect webrtc-steamer.'); |
|
|
jessibuca.value.play("ws://192.168.1.119:8080/jessica/live/test.flv") |
|
|
jessibuca.value.play("ws://192.168.1.117:8080/jessica/live/test.flv") |
|
|
curVideoKey.value = cameraId |
|
|
curVideoKey.value = cameraId |
|
|
// step4, active camera searcher. |
|
|
// step4, active camera searcher. |
|
|
markSearchApi.IsExistsSearcher({ |
|
|
markSearchApi.IsExistsSearcher({ |
|
@ -350,11 +347,6 @@ function switchCamera(cameraId: string) { |
|
|
|
|
|
|
|
|
// step5, load camera labels. |
|
|
// step5, load camera labels. |
|
|
} |
|
|
} |
|
|
function getRtspUrl(cameraObj: any): string { |
|
|
|
|
|
// 模拟 onvif |
|
|
|
|
|
// return `rtsp://admin:hk123456@192.168.1.65:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1`; |
|
|
|
|
|
return `rtsp://${cameraObj.userName}:${cameraObj.password}@${cameraObj.ip}:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1`; |
|
|
|
|
|
} |
|
|
|
|
|
function getLabel(cbCameraId: string | number) { |
|
|
function getLabel(cbCameraId: string | number) { |
|
|
let str = JSON.stringify({ cbCameraId }) |
|
|
let str = JSON.stringify({ cbCameraId }) |
|
|
markLabelApi.GetList({ queryJson: str }).then((res: any) => { |
|
|
markLabelApi.GetList({ queryJson: str }).then((res: any) => { |
|
@ -404,27 +396,8 @@ function loadMarkLabels(cameraObj: any) { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
drawMarkLabels(list); |
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
function drawMarkLabels(markLabels: Array<any>) { |
|
|
|
|
|
let ctx = canvas.getContext('2d'); |
|
|
|
|
|
if (!ctx) return; |
|
|
|
|
|
ctx.clearRect(0, 0, canvasWidth.value, canvasHeight.value); |
|
|
|
|
|
for (let markLabel of markLabels) { |
|
|
|
|
|
if (!markLabel.inFlag) continue; |
|
|
|
|
|
let x = Math.round(canvasWidth.value * markLabel.canvasLeftRatio); |
|
|
|
|
|
let y = Math.round(canvasHeight.value * markLabel.canvasTopRatio); |
|
|
|
|
|
x = canvasWidth.value * markLabel.canvasLeftRatio; |
|
|
|
|
|
y = canvasHeight.value * markLabel.canvasTopRatio; |
|
|
|
|
|
// console.log(markLabel); |
|
|
|
|
|
ctx.beginPath(); |
|
|
|
|
|
ctx.arc(x, y, 5, 0, 2 * Math.PI); |
|
|
|
|
|
ctx.fillStyle = "red"; |
|
|
|
|
|
ctx.fill(); |
|
|
|
|
|
ctx.closePath(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//刷新页面 |
|
|
//刷新页面 |
|
|
window.onbeforeunload = () => { |
|
|
window.onbeforeunload = () => { |
|
|
jessibuca.value.destroy() |
|
|
jessibuca.value.destroy() |
|
@ -442,9 +415,6 @@ onUnmounted(() => { |
|
|
position: relative; |
|
|
position: relative; |
|
|
overflow: hidden; |
|
|
overflow: hidden; |
|
|
|
|
|
|
|
|
#videoCanvas { |
|
|
|
|
|
position: absolute; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#videoPlayer { |
|
|
#videoPlayer { |
|
|
height: 100%; |
|
|
height: 100%; |
|
|