From d2102ac20a468761e7d3973829600234a8fea4f9 Mon Sep 17 00:00:00 2001 From: lxj <15683799673@163.com> Date: Thu, 28 Aug 2025 09:10:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=B5=81=E9=80=82=E9=85=8D?= =?UTF-8?q?=E5=86=85=E5=A4=96=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/sis/stream/model.d.ts | 2 ++ apps/web-antd/src/views/sis/video/index.vue | 29 ++++++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apps/web-antd/src/api/sis/stream/model.d.ts b/apps/web-antd/src/api/sis/stream/model.d.ts index 8993f651..dde8e896 100644 --- a/apps/web-antd/src/api/sis/stream/model.d.ts +++ b/apps/web-antd/src/api/sis/stream/model.d.ts @@ -1,5 +1,7 @@ export interface AddStreamProxyResult { key:string; + app:string; + streamId:string; rtsp:string; rtmp:string; flv:string; diff --git a/apps/web-antd/src/views/sis/video/index.vue b/apps/web-antd/src/views/sis/video/index.vue index 1d570d1d..fa537334 100644 --- a/apps/web-antd/src/views/sis/video/index.vue +++ b/apps/web-antd/src/views/sis/video/index.vue @@ -2,11 +2,8 @@
-
- +
+
@@ -52,7 +49,7 @@ import { Page } from '@vben/common-ui'; import ChannelTree from './channel-tree.vue'; import mpegts from 'mpegts.js'; import { message } from 'ant-design-vue'; -import { addFFmpegStreamProxy, addStreamProxy } from '#/api/sis/stream'; +import { addStreamProxy } from '#/api/sis/stream'; import { Svg16FrameIcon, Svg1FrameIcon, @@ -296,8 +293,8 @@ function streamProxy(nodeData: any, cb: Function) { if (isSupportH265) { addStreamProxy(params).then((res) => cb(res)); } else { - addFFmpegStreamProxy(params).then((res) => cb(res)); - // addStreamProxy(params).then((res) => cb(res)); + // addFFmpegStreamProxy(params).then((res) => cb(res)); + addStreamProxy(params).then((res) => cb(res)); } } @@ -310,7 +307,8 @@ function doPlayer(nodeData: any, index: number = 0) { console.log('index=', index); if (mpegts.isSupported()) { streamProxy(nodeData, (res: AddStreamProxyResult) => { - const url = res.wsFlv; + const host = window.location.host; + const url = `http://${host}/${res.app}/${res.streamId}.live.flv`; // 将url 绑定到 nodeData nodeData.url = url; closePlayer(index); @@ -337,7 +335,9 @@ function doPlayer(nodeData: any, index: number = 0) { player.play(); playerList[index] = { player, + key: nodeData.id, data: nodeData, + el: videoElement, }; } else { console.log('视频播放元素获取异常'); @@ -381,10 +381,13 @@ function catchUp() { if (playerData) { const { player, el } = playerData; const end = player.buffered.end(player.buffered.length - 1); - const diff = end - el.currentTime; - if (diff > 2) { - // 如果延迟超过2秒 - el.currentTime = end - 0.5; // 跳转到接近直播点 + const { currentTime } = el; + if (end && currentTime) { + const diff = end - el.currentTime; + if (diff > 2) { + // 如果延迟超过2秒 + el.currentTime = end - 0.5; // 跳转到接近直播点 + } } } });