Forráskód Böngészése

1. 视频添加播放倍数设置

hongrunxia 1 hónapja
szülő
commit
78c48f2802

+ 16 - 7
src/hooks/system/useCamera.ts

@@ -17,7 +17,7 @@ export function useCamera() {
   let webRtcServer = <any[]>[];
   const playerList = <any[]>[];
   const playerDoms = <(HTMLVideoElement | undefined | null)[]>[];
-  const videoParentDomList: (HTMLElement | [string, { name: string; addr: string }])[] = [];
+  const videoParentDomList: (HTMLElement | [string, { name: string; addr: string; cameraRate: number }])[] = [];
 
   async function getCamera(deviceid, parentPlayerDom?, devKind?) {
     removeCamera();
@@ -51,7 +51,7 @@ export function useCamera() {
     //   // },
     // ];
     const cameraAddrs: any[] = [],
-      cameraNames: string[] = [];
+      cameraNames: any[] = [];
     if (cameras.length > 0) {
       for (let i = 0; i < cameras.length; i++) {
         const item = cameras[i];
@@ -60,7 +60,7 @@ export function useCamera() {
           try {
             const data = await cameraAddr({ cameraCode: item['addr'] });
             if (data && data['url']) {
-              cameraAddrs.push({ name: item['name'], addr: data['url'] });
+              cameraAddrs.push({ name: item['name'], addr: data['url'], cameraRate: item['cameraRate'] });
             }
             // // 从海康平台接口获取视频流测试
             // cameraAddrs.push({
@@ -69,15 +69,17 @@ export function useCamera() {
             // });
           } catch (error) {}
         } else if (item['devicekind'] == 'toHKR') {
-          cameraNames.push(item['name']);
+          cameraNames.push({ name: item['name'], cameraRate: item['cameraRate'] });
         } else {
-          cameraAddrs.push({ name: item['name'], addr: item['addr'] });
+          cameraAddrs.push({ name: item['name'], addr: item['addr'], cameraRate: item['cameraRate'] });
         }
       }
     }
     if (cameraNames.length > 0) {
       // 请求接口从装备院拿数据
-      const addrs: string[] = await cameraAddrList({ cameraNameList: cameraNames });
+      const cameraNameList = cameraNames.map((item) => item.name);
+
+      const addrs: string[] = await cameraAddrList({ cameraNameList: cameraNameList });
       for (let i = 0; i < addrs.length; i++) {
         cameraAddrs.push({ name: '摄像头' + i, addr: addrs[i] });
       }
@@ -103,7 +105,8 @@ export function useCamera() {
       const playCamrea = () => {
         if (cameraAddrs.length > 0) {
           const promiseList: Promise<any>[] = [];
-          cameraAddrs.forEach(async (cameraUrl: { name: string; addr: string }, index) => {
+
+          cameraAddrs.forEach(async (cameraUrl: { name: string; addr: string; cameraRate: number }, index) => {
             const promise = new Promise(async (childResolve) => {
               let cameraNameDom: null | HTMLElement = null;
               console.log('摄像头地址--------->', cameraUrl, cameraUrl.addr.startsWith('rtsp://'), livePlayerDiv);
@@ -218,6 +221,8 @@ export function useCamera() {
                 customConfig: {
                   isClickPlayBack: false,
                 },
+                controls: false,
+                defaultPlaybackRate: videoParent[1].cameraRate || 1,
                 flv: {
                   retryCount: 3, // 重试 3 次,默认值
                   retryDelay: 1000, // 每次重试间隔 1 秒,默认值
@@ -249,6 +254,8 @@ export function useCamera() {
                   autoplayMuted: true,
                   cors: true,
                   poster: '/src/assets/images/vent/noSinge.png',
+                  defaultPlaybackRate: videoParent[1].cameraRate || 1,
+                  controls: false,
                   hls: {
                     retryCount: 10, // 重试 3 次,默认值
                     retryDelay: 30000, // 每次重试间隔 1 秒,默认值
@@ -276,6 +283,8 @@ export function useCamera() {
                   autoplayMuted: true,
                   plugins: [HlsPlugin], // 第二步
                   poster: '/src/assets/images/vent/noSinge.png',
+                  defaultPlaybackRate: videoParent[1].cameraRate || 1,
+                  controls: false,
                   hls: {
                     retryCount: 10, // 重试 3 次,默认值
                     retryDelay: 30000, // 每次重试间隔 1 秒,默认值

+ 26 - 0
src/views/vent/deviceManager/comment/cameraTabel/camera.data.ts

@@ -47,6 +47,32 @@ export const columns: BasicColumn[] = [
     width: 100,
     editRow: true,
   },
+  {
+    title: '视频播放倍速',
+    dataIndex: 'cameraRate',
+    width: 100,
+    editRow: true,
+    editComponentProps: {
+      options: [
+        {
+          label: '0.5',
+          value: 0.5,
+        },
+        {
+          label: '1 ',
+          value: 1,
+        },
+        {
+          label: '1.5',
+          value: 1.5,
+        },
+        {
+          label: '2',
+          value: 2,
+        },
+      ],
+    },
+  },
   // {
   //   title: '端口号',
   //   width: 100,

+ 15 - 9
src/views/vent/monitorManager/camera/index.vue

@@ -74,7 +74,7 @@ const current = ref(1)
 const total = ref(0)
 const playerList = ref([])
 const webRtcServerList = <any[]>[]
-let addrList = ref<{ name: string, addr: string }[]>([])
+let addrList = ref<{ name: string, addr: string, cameraRate: number }[]>([])
 
 async function getCameraDevKindList() {
   let res = await getCameraDevKind()
@@ -196,7 +196,7 @@ async function getVideoAddrs() {
   let res = await list({ devKind: paramKind, strType: searchParam.strType, pageSize: pageSize.value, pageNo: current.value })
   total.value = res['total'] || 0
   if (res.records.length != 0) {
-    const cameraList = <{ name: string, addr: string }[]>[]
+    const cameraList = <{ name: string, addr: string, cameraRate: number }[]>[]
     const cameras = res.records
     for (let i = 0; i < cameras.length; i++) {
       const item = cameras[i];
@@ -206,7 +206,7 @@ async function getVideoAddrs() {
         try {
           const data = await cameraAddr({ cameraCode: item['addr'] });
           if (data) {
-            cameraList.push({ name: item['name'], addr: data['url'] });
+            cameraList.push({ name: item['name'], addr: data['url'], cameraRate: item['cameraRate'] });
           }
           // cameraList.push({
           //   name: item['name'],
@@ -221,7 +221,7 @@ async function getVideoAddrs() {
         if (item['addr'].includes('0.0.0.0')) {
           item['addr'] = item['addr'].replace('0.0.0.0', window.location.hostname)
         }
-        cameraList.push({ name: item['name'], addr: item['addr'] });
+        cameraList.push({ name: item['name'], addr: item['addr'], cameraRate: item['cameraRate'] });
       }
     }
     addrList.value = cameraList
@@ -233,7 +233,7 @@ async function getVideoAddrsSon(Id) {
   playerList.value = []
   let res = await getVentanalyCamera({ deviceid: Id })
   if (res.records.length != 0) {
-    const cameraList = <{ name: string, addr: string }[]>[]
+    const cameraList = <{ name: string, addr: string, cameraRate: number }[]>[]
     const cameras = res.records
     for (let i = 0; i < cameras.length; i++) {
       const item = cameras[i];
@@ -243,7 +243,7 @@ async function getVideoAddrsSon(Id) {
         try {
           const data = await cameraAddr({ cameraCode: item['addr'] });
           if (data && data['url']) {
-            cameraList.push({ name: item['name'], addr: data['url'] });
+            cameraList.push({ name: item['name'], addr: data['url'], cameraRate: item['cameraRate'] });
           }
           // cameraList.push({
           //   name: item['name'],
@@ -258,7 +258,7 @@ async function getVideoAddrsSon(Id) {
         if (item['addr'].includes('0.0.0.0')) {
           item['addr'] = item['addr'].replace('0.0.0.0', window.location.hostname)
         }
-        cameraList.push({ name: item['name'], addr: item['addr'] });
+        cameraList.push({ name: item['name'], addr: item['addr'], cameraRate: item['cameraRate']  });
       }
     }
     addrList.value = cameraList
@@ -284,12 +284,12 @@ function getVideo() {
       webRtcServerList.push(webRtcServer)
       webRtcServer.connect(item.addr)
     } else {
-      setNoRtspVideo('player' + i, item.addr)
+      setNoRtspVideo('player' + i, item.addr, item.cameraRate,)
     }
   }
 }
 
-function setNoRtspVideo(id, videoAddr) {
+function setNoRtspVideo(id, videoAddr, cameraRate) {
   const fileExtension = videoAddr.split('.').pop();
   if (fileExtension === 'flv') {
     const player = new Player({
@@ -311,6 +311,8 @@ function setNoRtspVideo(id, videoAddr) {
       customConfig: {
         isClickPlayBack: false
       },
+      defaultPlaybackRate: cameraRate || 1,
+      controls: false,
       flv: {
         retryCount: 3, // 重试 3 次,默认值
         retryDelay: 1000, // 每次重试间隔 1 秒,默认值
@@ -342,6 +344,8 @@ function setNoRtspVideo(id, videoAddr) {
         autoplayMuted: true,
         cors: true,
         poster: '/src/assets/images/vent/noSinge.png',
+        defaultPlaybackRate: cameraRate || 1,
+        controls: false,
         hls: {
           retryCount: 3, // 重试 3 次,默认值
           retryDelay: 1000, // 每次重试间隔 1 秒,默认值
@@ -369,6 +373,8 @@ function setNoRtspVideo(id, videoAddr) {
         autoplayMuted: true,
         plugins: [HlsPlugin], // 第二步
         poster: '/src/assets/images/vent/noSinge.png',
+        defaultPlaybackRate: cameraRate || 1,
+        controls: false,
         hls: {
           retryCount: 3, // 重试 3 次,默认值
           retryDelay: 1000, // 每次重试间隔 1 秒,默认值