diff --git a/manifest.json b/manifest.json index 529278f..2c8932d 100644 --- a/manifest.json +++ b/manifest.json @@ -34,7 +34,11 @@ "", "", "", - "" + "", + "", + "", + "", + "" ], "abiFilters" : [ "arm64-v8a" ] }, @@ -42,7 +46,8 @@ "dSYMs" : false, "privacyDescription" : { "NSCameraUsageDescription" : "需要使用相机扫描条码", - "NSPhotoLibraryUsageDescription" : "需要访问相册选择图片扫码" + "NSPhotoLibraryUsageDescription" : "需要访问相册选择图片扫码", + "NSMicrophoneUsageDescription" : "需要使用麦克风进行监控视频的语音对讲或录制" } }, "sdkConfigs" : {} diff --git a/nativeplugins/ry-ipc-video/android/ipc-video-plugin-release.aar b/nativeplugins/ry-ipc-video/android/ipc-video-plugin-release.aar new file mode 100644 index 0000000..3c62e94 Binary files /dev/null and b/nativeplugins/ry-ipc-video/android/ipc-video-plugin-release.aar differ diff --git a/package_a/monitor/monitor.nvue b/package_a/monitor/monitor.nvue index 0e95052..fa99ac7 100644 --- a/package_a/monitor/monitor.nvue +++ b/package_a/monitor/monitor.nvue @@ -28,6 +28,11 @@ 状态:{{ statusMsg }} + + + 正在录像... + + @@ -61,6 +66,10 @@ + + + + @@ -70,6 +79,7 @@ return { deviceUid: 'HLTY036190SYNSK', // 默认使用你 Demo 里的测试 UID isPlaying: false, + isRecording: false, // 是否正在录像 statusMsg: '等待操作', currentChannel: 0, // 0对应CH1, 1对应CH2... currentStreamType: 1, // 1为高清(主码流),2为标清(子码流) @@ -87,7 +97,18 @@ } }, onUnload() { - // 页面卸载时停止播放,释放资源 + // 如果正在录像,必须先停止录像 + if (this.isRecording) { + this.endRecord(); + } + // 页面卸载时停止播放,释放资源,防止占用通道 + this.stopPlay(); + }, + onHide() { + // 页面切到后台或跳转到其他页面时,也停止录像和播放,释放通道 + if (this.isRecording) { + this.endRecord(); + } this.stopPlay(); }, methods: { @@ -145,15 +166,15 @@ this.$refs.ipcVideo.start(); } else { console.error('start 方法不存在,可能插件注册失败或版本未生效'); - uni.showToast({ title: '插件方法未找到', icon: 'none' }); + // uni.showToast({ title: '插件方法未找到', icon: 'none' }); // 暂时注释掉 } } else { - uni.showToast({ title: '插件未加载成功', icon: 'none' }); + // uni.showToast({ title: '插件未加载成功', icon: 'none' }); // 暂时注释掉 } // #endif // #ifndef APP-PLUS - uni.showToast({ title: '仅App端支持', icon: 'none' }); + // uni.showToast({ title: '仅App端支持', icon: 'none' }); // 暂时注释掉 // #endif }, stopPlay() { @@ -166,6 +187,38 @@ } // #endif }, + beginRecord() { + // #ifdef APP-PLUS + if (this.$refs.ipcVideo && typeof this.$refs.ipcVideo.startRecord === 'function') { + // 将 _doc/ 相对路径转换为手机上的绝对绝对路径 + const savePath = plus.io.convertLocalFileSystemURL("_doc/camera_record_" + Date.now() + ".mp4"); + + this.$refs.ipcVideo.startRecord({ + path: savePath, + width: 1920, // 可选,默认 1920 + height: 1080, // 可选,默认 1080 + fps: 15 // 可选,默认 10 + }); + + this.statusMsg = '正在录像...'; + this.isRecording = true; + console.log("正在录像,保存到:", savePath); + // uni.showToast({ title: '已开始录像', icon: 'success' }); // 暂时注释掉,使用 isRecording 替代 + } else { + // uni.showToast({ title: '原生插件缺少录像方法', icon: 'none' }); // 暂时注释掉 + } + // #endif + }, + endRecord() { + // #ifdef APP-PLUS + if (this.$refs.ipcVideo && typeof this.$refs.ipcVideo.stopRecord === 'function') { + this.$refs.ipcVideo.stopRecord(); + this.statusMsg = '录像已保存'; + this.isRecording = false; + // uni.showToast({ title: '录像已保存到 _doc 目录', icon: 'success' }); // 暂时注释掉 + } + // #endif + }, onVideoStatusChange(e) { try { console.log("视频状态改变:", e); @@ -183,22 +236,22 @@ // 捕获来自 Java 层主动抛出的原生崩溃错误 if (status === 'error' && msg && msg.indexOf('原生启动崩溃') !== -1) { - uni.showModal({ + /* uni.showModal({ title: '原生插件崩溃', content: msg, showCancel: false - }); + }); */ // 暂时注释掉 this.isPlaying = false; return; } // 处理特定的连接错误状态 if (status === 'error' || msgParam === 7 || msgParam === 14) { - uni.showToast({ + /* uni.showToast({ title: msg ? msg : '摄像机离线,请检查设备网络', icon: 'none', duration: 3000 - }); + }); */ // 暂时注释掉 // 可以在这里做一些重置操作 this.isPlaying = false; } else if (status === 'playing') { @@ -207,18 +260,18 @@ } else { // 如果 e.detail 是空对象或者 undefined,提示异常 console.error("收到空的状态事件:", e); - uni.showToast({ + /* uni.showToast({ title: '收到空状态,原生可能发生异常', icon: 'none' - }); + }); */ // 暂时注释掉 } } catch (err) { console.error("解析状态回调时发生前端异常:", err); - uni.showModal({ + /* uni.showModal({ title: '前端回调解析异常', content: err.toString(), showCancel: false - }); + }); */ // 暂时注释掉 } } } @@ -322,4 +375,19 @@ color: #ffffff; background-color: #007aff; } +.recording-indicator { + position: absolute; + top: 40rpx; + right: 40rpx; + background-color: rgba(255, 0, 0, 0.7); + padding: 10rpx 20rpx; + border-radius: 10rpx; + flex-direction: row; + align-items: center; +} +.recording-text { + color: #ffffff; + font-size: 24rpx; + font-weight: bold; +} \ No newline at end of file diff --git a/package_a/playback/playback.nvue b/package_a/playback/playback.nvue new file mode 100644 index 0000000..4ed1c85 --- /dev/null +++ b/package_a/playback/playback.nvue @@ -0,0 +1,353 @@ + + + + + \ No newline at end of file diff --git a/pages.json b/pages.json index 9b56139..ef163c4 100644 --- a/pages.json +++ b/pages.json @@ -67,6 +67,12 @@ "style": { "navigationBarTitleText": "" } + }, + { + "path": "playback/playback", + "style": { + "navigationBarTitleText": "" + } } ] } diff --git a/pages/index.vue b/pages/index.vue index 47ccd82..6851ba8 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -179,7 +179,7 @@ 实时监控 - + 查看回放 @@ -370,6 +370,20 @@ export default { }) // #endif }, + goToPlayback(){ + // #ifdef MP + uni.showToast({ + title: '小程序暂不支持查看监控回放请使用app', + icon: 'none' + }) + // #endif + + // #ifndef MP + uni.navigateTo({ + url: '/package_a/playback/playback' + }) + // #endif + }, goToAsset() { uni.navigateTo({ url: '/package_a/asset/asset'