Browse Source

完善视频录制功能

master
chendingwei 2 years ago
parent
commit
c23d5a04dc
  1. 88
      src/views/page/cameraCenter.vue

88
src/views/page/cameraCenter.vue

@ -6,13 +6,10 @@
@mousedown="mouseDownVideo"> @mousedown="mouseDownVideo">
</video> --> </video> -->
<div id="videoPlayer" @mousedown="mouseDownVideo"></div> <div id="videoPlayer" @mousedown="mouseDownVideo"></div>
<div v-for="item in labelList" <div v-for="item in labelList" :class="`labels ${item.groupName == '视频标签' ? 'lavels-video' : 'lavels-build'}`"
:class="`labels ${item.groupName == '视频标签' ? 'lavels-video' : 'lavels-build'}`" :key="item.id" :id="item.id"
:key="item.id"
:id="item.id"
:style="`top:${canvasHeight * item.canvasTopRatio}px;left:${canvasWidth * item.canvasLeftRatio}px`" :style="`top:${canvasHeight * item.canvasTopRatio}px;left:${canvasWidth * item.canvasLeftRatio}px`"
@click="itemClick(item)" @click="itemClick(item)">
>
<a-dropdown :trigger="['contextmenu']"> <a-dropdown :trigger="['contextmenu']">
<div class="labels-item" v-if="item.groupName == '视频标签'"> <div class="labels-item" v-if="item.groupName == '视频标签'">
<!-- <div class="labels-item" v-if="item.inFlag"> --> <!-- <div class="labels-item" v-if="item.inFlag"> -->
@ -66,15 +63,15 @@
<script setup lang='ts'> <script setup lang='ts'>
////@ts-nocheck ////@ts-nocheck
import {ExclamationCircleOutlined} from '@ant-design/icons-vue'; import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import {Modal} from 'ant-design-vue'; import { Modal } from 'ant-design-vue';
import {ref, h, onMounted, getCurrentInstance, ComponentInternalInstance, onUnmounted, watch, createVNode} from "vue"; import { ref, h, onMounted, getCurrentInstance, ComponentInternalInstance, onUnmounted, watch, createVNode } from "vue";
import * as markLabelApi from '@/axios/cameraMark/markLabelApi'; import * as markLabelApi from '@/axios/cameraMark/markLabelApi';
import * as markSearchApi from '@/axios/core/markSearchApi'; import * as markSearchApi from '@/axios/core/markSearchApi';
import * as zlmApi from '@/axios/core/zlmApi'; import * as zlmApi from '@/axios/core/zlmApi';
import {useStore} from '@/store/index'; import { useStore } from '@/store/index';
import {apiUrl} from "@/axios"; import { apiUrl } from "@/axios";
import {storeToRefs} from 'pinia'; import { storeToRefs } from 'pinia';
import Msg from "@/utils/message"; import Msg from "@/utils/message";
import CameraLeftMenu from '@/views/page/Aside/cameraLeftMenu.vue' import CameraLeftMenu from '@/views/page/Aside/cameraLeftMenu.vue'
import CameraRightMenu from '@/views/page/Aside/cameraRightMenu.vue' import CameraRightMenu from '@/views/page/Aside/cameraRightMenu.vue'
@ -83,7 +80,7 @@ import cameraWindow from '@/views/page/cameraWindow.vue'
import popup from "@/utils/popup"; import popup from "@/utils/popup";
import VideoControlSimple from './VideoControl/VideoControlSimple.vue'; 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 canvasWidth = ref(0) let canvasWidth = ref(0)
@ -95,6 +92,7 @@ let isActiveChoose = ref(false)
let labelList = ref<any[]>([]) let labelList = ref<any[]>([])
let addLabel = storeToRefs(piniaStore).addLabel let addLabel = storeToRefs(piniaStore).addLabel
let screenshot = storeToRefs(piniaStore).screenshot let screenshot = storeToRefs(piniaStore).screenshot
let record = storeToRefs(piniaStore).record
let addLabelLeft = ref(0); let addLabelLeft = ref(0);
let addLabelTop = ref(0); let addLabelTop = ref(0);
var jessibuca = ref(); var jessibuca = ref();
@ -106,21 +104,7 @@ onMounted(() => {
loadVideoCanvas(); loadVideoCanvas();
} }
}) })
watch(screenshot, (newVal, oldVal) => {
if (newVal) {
console.log(123);
//jessibuca.value.isPlaying()
if (!jessibuca.value.isPlaying()) {
Msg.info("请先选择监控画面")
piniaStore.updateScreenshot(false)
return
}
jessibuca.value.screenshot("", "png", 1)
piniaStore.updateScreenshot(false)
}
})
watch(curSelectKey, (newVal, oldVal) => { watch(curSelectKey, (newVal, oldVal) => {
switchCamera(newVal) switchCamera(newVal)
}) })
@ -141,7 +125,33 @@ watch(addLabel, (newVal, oldVal) => {
} }
} }
}) })
watch(screenshot, (newVal, oldVal) => {
if (newVal) {
//jessibuca.value.isPlaying()
if (!jessibuca.value.isPlaying()) {
Msg.info("请先选择监控画面")
piniaStore.updateScreenshot(false)
return
}
jessibuca.value.screenshot("", "png", 1)
piniaStore.updateScreenshot(false)
}
})
watch(record, (newVal, oldVal) => {
if (!jessibuca.value.isPlaying()) {
Msg.info("请先选择监控画面")
piniaStore.updateRecord(false)
return
}
if (newVal) {
jessibuca.value.startRecord()
Msg.info("开始录制")
} else {
jessibuca.value.stopRecordAndSave()
Msg.info("录制完毕")
}
})
function closeVideo() { function closeVideo() {
jessibuca.value.close(); jessibuca.value.close();
labelList.value = [] labelList.value = []
@ -149,7 +159,7 @@ function closeVideo() {
// //
function deleteLabel(id: number) { function deleteLabel(id: number) {
markLabelApi.Delete({id}).then((res: any) => { markLabelApi.Delete({ id }).then((res: any) => {
if (judgeResponse(res)) return; if (judgeResponse(res)) return;
let flag = res.data.data; let flag = res.data.data;
let msg = flag === true ? "删除成功" : "删除失败"; let msg = flag === true ? "删除成功" : "删除失败";
@ -167,7 +177,7 @@ function deleteLabel(id: number) {
// //
function itemClick(item: any) { function itemClick(item: any) {
// console.log("",item); // console.log("",item);
popup("监控画面", [h(cameraWindow, {windowData: item})], "cameraWindow"); popup("监控画面", [h(cameraWindow, { windowData: item })], "cameraWindow");
} }
function loadVideoPlayer() { function loadVideoPlayer() {
@ -202,6 +212,11 @@ function loadVideoPlayer() {
jessibuca.value.onPlay = () => console.log('onPlay'); jessibuca.value.onPlay = () => console.log('onPlay');
jessibuca.value.onFullscreen = (msg: any) => console.log('onFullscreen', msg); jessibuca.value.onFullscreen = (msg: any) => console.log('onFullscreen', msg);
jessibuca.value.onMute = (msg: any) => console.log('onMute', msg); jessibuca.value.onMute = (msg: any) => console.log('onMute', msg);
//
// jessibuca.value.on("recordEnd", function () {
// console.log("record end")
// piniaStore.updateRecord(false)
// })
} }
function loadVideoCanvas() { function loadVideoCanvas() {
@ -215,7 +230,7 @@ const onContextMenuClick = (item: any, menuKey: string,) => {
// console.log(`labelId: ${item.id}, menuKey: ${menuKey}`); // console.log(`labelId: ${item.id}, menuKey: ${menuKey}`);
//key //key
if (menuKey == "edit") { if (menuKey == "edit") {
popup("编辑标签", [h(LabelEditModel, {modelData: item})], "editLabel"); popup("编辑标签", [h(LabelEditModel, { modelData: item })], "editLabel");
} else if (menuKey == "delete") { } else if (menuKey == "delete") {
Modal.confirm({ Modal.confirm({
zIndex: 10000, zIndex: 10000,
@ -224,7 +239,7 @@ const onContextMenuClick = (item: any, menuKey: string,) => {
content: () => content: () =>
h( h(
"span", "span",
{style: {color: "black"}}, { style: { color: "black" } },
"是否确认删除该标签?" "是否确认删除该标签?"
), ),
okText: okText:
@ -307,14 +322,14 @@ function mouseDownVideo(e: MouseEvent) {
} }
labelList.value.push(obj) labelList.value.push(obj)
isActiveChoose.value = false isActiveChoose.value = false
piniaStore.updateIsAddLabel({cmMarkGroupId: 0, labelType: "", isAddLabel: false}) piniaStore.updateIsAddLabel({ cmMarkGroupId: 0, labelType: "", isAddLabel: false })
} }
}); });
}) })
} else { } else {
// //
isActiveChoose.value = false isActiveChoose.value = false
piniaStore.updateIsAddLabel({cmMarkGroupId: 0, labelType: "", isAddLabel: false}) piniaStore.updateIsAddLabel({ cmMarkGroupId: 0, labelType: "", isAddLabel: false })
} }
} }
@ -381,8 +396,8 @@ function switchCamera(cameraId: string) {
} }
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) => {
if (judgeResponse(res)) return; if (judgeResponse(res)) return;
labelList.value = res.data.data labelList.value = res.data.data
labelList.value = labelList.value.map((item: any) => { labelList.value = labelList.value.map((item: any) => {
@ -479,7 +494,7 @@ onUnmounted(() => {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
> div { >div {
position: relative; position: relative;
} }
@ -488,6 +503,7 @@ onUnmounted(() => {
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -55%); transform: translate(-50%, -55%);
color: white;
} }
img { img {

Loading…
Cancel
Save