From 144fa7b4230aa3e8555ffebb8c69d521927facda Mon Sep 17 00:00:00 2001 From: 86156 <823267011@qq.com> Date: Wed, 1 Oct 2025 22:38:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/video/device/component/cusPlayer.vue | 18 ++++++++++++++++++ .../src/views/video/device/component/flv.vue | 2 ++ ruoyi-admin/src/main/resources/application.yml | 6 +++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/rtsp-vue/src/views/video/device/component/cusPlayer.vue b/rtsp-vue/src/views/video/device/component/cusPlayer.vue index 7add9a7..f7d7e27 100644 --- a/rtsp-vue/src/views/video/device/component/cusPlayer.vue +++ b/rtsp-vue/src/views/video/device/component/cusPlayer.vue @@ -35,14 +35,17 @@ export default { methods: { createPlayer(url, hasCloseBtn, index) { if (!url) { + console.error('播放地址为空'); return; } if (this.player) { + console.log('播放器已存在,切换视频源'); this.changeVideo(url); return; } + console.log('创建播放器,URL:', url, 'Element ID:', this.elId); this.isPlay = true; this.player = new FlvJsPlayer({ id: this.elId, @@ -71,6 +74,21 @@ export default { autoCleanupMinBackwardDuration: 30 * 60 } //flv.js可选配置项 [flv.js配置](https://github.com/bilibili/flv.js/blob/master/docs/api.md#config) }); + + // 监听播放器错误 + this.player.on('error', (error) => { + console.error('播放器错误:', error); + }); + + // 监听播放器就绪 + this.player.on('ready', () => { + console.log('播放器就绪'); + }); + + // 监听播放开始 + this.player.on('play', () => { + console.log('开始播放'); + }); // 自定义播放器按钮 // let divStr = diff --git a/rtsp-vue/src/views/video/device/component/flv.vue b/rtsp-vue/src/views/video/device/component/flv.vue index 6e6e57c..2fee0c3 100644 --- a/rtsp-vue/src/views/video/device/component/flv.vue +++ b/rtsp-vue/src/views/video/device/component/flv.vue @@ -69,8 +69,10 @@ const getDetails = async (deviceId) => { const res = await getDevice(deviceId); tableData.value = res.data; // 使用当前访问的域名和端口,通过Nginx代理访问视频流 + // 注意:RTSP URL需要原样传递,不要编码,&&&作为特殊分隔符 // 添加ffmpeg=true参数,强制使用FFmpeg转换为FLV格式 playUrl.value = `${window.location.origin}/live?url=${tableData.value.url}&&&ffmpeg=true`; + console.log('播放地址:', playUrl.value); handlePlay(); } diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 9441e9a..d9e0b81 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -148,9 +148,9 @@ xss: # 流媒体服务端口 mediasServer: - port: ${MEDIA_SERVER_PORT:8866} - # 监听地址,支持环境变量配置 - address: ${MEDIA_SERVER_ADDRESS:0.0.0.0} + port: ${MEDIA_SERVER_PORT:10083} + # 监听地址,支持环境变量配置(默认127.0.0.1,只监听本地,通过Nginx代理) + address: ${MEDIA_SERVER_ADDRESS:127.0.0.1} # 网络超时,15秒 netTimeout: 15000000 # 读写超时,15秒