安卓视频监控
parent
c401d817d5
commit
13ed350850
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name" : "海驰24",
|
||||
"appid" : "__UNI__F1AF57E",
|
||||
"appid" : "__UNI__7302921",
|
||||
"description" : "111",
|
||||
"versionName" : "1.2.0",
|
||||
"versionCode" : "100",
|
||||
"versionName" : "1.2.1",
|
||||
"versionCode" : 102,
|
||||
"transformPx" : false,
|
||||
"app-plus" : {
|
||||
"usingComponents" : true,
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
},
|
||||
"distribute" : {
|
||||
"android" : {
|
||||
"minSdkVersion" : 21,
|
||||
"permissions" : [
|
||||
"<!-- 扫码核心必要权限 -->",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||
|
|
@ -35,7 +36,7 @@
|
|||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>"
|
||||
],
|
||||
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ]
|
||||
"abiFilters" : [ "armeabi-v7a" ]
|
||||
},
|
||||
"ios" : {
|
||||
"dSYMs" : false,
|
||||
|
|
@ -45,6 +46,22 @@
|
|||
}
|
||||
},
|
||||
"sdkConfigs" : {}
|
||||
},
|
||||
"nativePlugins" : {
|
||||
"ry-ipc-video" : {
|
||||
"__plugin_info__" : {
|
||||
"name" : "ry-ipc-video",
|
||||
"description" : "IPC 监控视频组件插件",
|
||||
"platforms" : "Android",
|
||||
"url" : "",
|
||||
"android_package_name" : "",
|
||||
"ios_bundle_id" : "",
|
||||
"isCloud" : false,
|
||||
"bought" : -1,
|
||||
"pid" : "",
|
||||
"parameters" : {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"quickapp" : {},
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "ry-ipc-video",
|
||||
"id": "ry-ipc-video",
|
||||
"version": "1.0.0",
|
||||
"description": "IPC 监控视频组件插件",
|
||||
"_dp_type": "nativeplugin",
|
||||
"_dp_nativeplugin": {
|
||||
"android": {
|
||||
"plugins": [
|
||||
{
|
||||
"type": "component",
|
||||
"name": "ry-ipc-video",
|
||||
"class": "com.ry.ipcplugin.IpcVideoComponent"
|
||||
}
|
||||
],
|
||||
"integrateType": "aar",
|
||||
"minSdkVersion": "21",
|
||||
"permissions": [
|
||||
"android.permission.CHANGE_WIFI_MULTICAST_STATE"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
<template>
|
||||
<view class="monitor-container">
|
||||
<text class="header">实时监控</text>
|
||||
|
||||
<!-- 这里使用我们封装好的原生插件组件 ry-ipc-video -->
|
||||
<view class="video-wrapper">
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<ry-ipc-video
|
||||
ref="ipcVideo"
|
||||
class="ipc-video"
|
||||
:uid="deviceUid"
|
||||
@onStatus="onVideoStatusChange">
|
||||
</ry-ipc-video>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 非App端提示 -->
|
||||
<!-- #ifndef APP-PLUS -->
|
||||
<view class="not-support-tips">
|
||||
<text class="not-support-tips-text">当前环境不支持查看监控,请使用App</text>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
|
||||
<view class="status-text-wrap" v-if="statusMsg">
|
||||
<text class="status-text">状态:{{ statusMsg }}</text>
|
||||
</view>
|
||||
|
||||
<view class="controls">
|
||||
<button class="btn btn-primary" @click="startPlay"><text class="btn-text">播放</text></button>
|
||||
<button class="btn btn-warn" @click="stopPlay"><text class="btn-text">停止</text></button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
deviceUid: 'HLTY020667DHKCD', // 默认使用你 Demo 里的测试 UID
|
||||
isPlaying: false,
|
||||
statusMsg: '等待操作'
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options && options.uid) {
|
||||
this.deviceUid = options.uid;
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
// 页面卸载时停止播放,释放资源
|
||||
this.stopPlay();
|
||||
},
|
||||
methods: {
|
||||
startPlay() {
|
||||
// #ifdef APP-PLUS
|
||||
if (this.$refs.ipcVideo) {
|
||||
this.statusMsg = '正在发起播放请求...';
|
||||
console.log('组件对象:', this.$refs.ipcVideo);
|
||||
|
||||
// 在 nvue 中调用组件的方法,有时可能需要通过 evalJS,但绝大多数情况可以直接调
|
||||
if (typeof this.$refs.ipcVideo.start === 'function') {
|
||||
this.$refs.ipcVideo.start();
|
||||
} else {
|
||||
console.error('start 方法不存在,可能插件注册失败或版本未生效');
|
||||
uni.showToast({ title: '插件方法未找到', icon: 'none' });
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: '插件未加载成功', icon: 'none' });
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef APP-PLUS
|
||||
uni.showToast({ title: '仅App端支持', icon: 'none' });
|
||||
// #endif
|
||||
},
|
||||
stopPlay() {
|
||||
// #ifdef APP-PLUS
|
||||
if (this.$refs.ipcVideo) {
|
||||
if (typeof this.$refs.ipcVideo.stop === 'function') {
|
||||
this.$refs.ipcVideo.stop();
|
||||
}
|
||||
this.statusMsg = '已发送停止指令';
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
onVideoStatusChange(e) {
|
||||
console.log("视频状态改变:", e.detail);
|
||||
// 根据我们在 Java 封装里写的 fireEventStatus 传回的 msg 显示
|
||||
if (e.detail) {
|
||||
// 提取参数
|
||||
const status = e.detail.status;
|
||||
const msg = e.detail.msg;
|
||||
const msgParam = e.detail.msgParam;
|
||||
|
||||
// 更新页面显示的文字状态
|
||||
if (msg) {
|
||||
this.statusMsg = msg;
|
||||
}
|
||||
|
||||
// 处理特定的连接错误状态
|
||||
if (status === 'error' || msgParam === 7 || msgParam === 14) {
|
||||
uni.showToast({
|
||||
title: '摄像机离线,请检查设备网络',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
// 可以在这里做一些重置操作
|
||||
this.isPlaying = false;
|
||||
} else if (status === 'playing') {
|
||||
this.isPlaying = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* nvue 样式必须是纯 CSS/flex,不支持 scss 嵌套和某些普通 css 属性 */
|
||||
.monitor-container {
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.header {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
padding: 20rpx;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.video-wrapper {
|
||||
width: 750rpx;
|
||||
height: 450rpx;
|
||||
background-color: #000000;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.ipc-video {
|
||||
width: 750rpx;
|
||||
height: 450rpx;
|
||||
}
|
||||
.not-support-tips {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.not-support-tips-text {
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.status-text-wrap {
|
||||
align-items: center;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.status-text {
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #666666;
|
||||
}
|
||||
.controls {
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
padding-top: 40rpx;
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
.btn {
|
||||
width: 300rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 10rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.btn-primary {
|
||||
background-color: #007aff;
|
||||
}
|
||||
.btn-warn {
|
||||
background-color: #e64340;
|
||||
}
|
||||
.btn-text {
|
||||
color: #ffffff;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
</style>
|
||||
13
pages.json
13
pages.json
|
|
@ -56,7 +56,18 @@
|
|||
{ "path": "mine/about/index", "style": { "navigationBarTitleText": "关于我们" } },
|
||||
{ "path": "mine/pwd/index", "style": { "navigationBarTitleText": "修改密码" } },
|
||||
{ "path": "common/webview/index", "style": { "navigationBarTitleText": "浏览网页" } },
|
||||
{ "path": "common/textview/index", "style": { "navigationBarTitleText": "浏览文本" } }
|
||||
{
|
||||
"path": "common/textview/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "浏览文本"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "monitor/monitor",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@
|
|||
</view>
|
||||
|
||||
<view class="grid-item" @click="navigateTo('实时监控')">
|
||||
<view class="item-icone">
|
||||
<view class="item-icone" @click="goToMonitor">
|
||||
|
||||
</view>
|
||||
<text class="item-text">实时监控</text>
|
||||
|
|
@ -356,6 +356,20 @@ export default {
|
|||
url: '/package_a/product/product'
|
||||
})
|
||||
},
|
||||
goToMonitor(){
|
||||
// #ifdef MP
|
||||
uni.showToast({
|
||||
title: '小程序暂不支持查看监控请使用app',
|
||||
icon: 'none'
|
||||
})
|
||||
// #endif
|
||||
|
||||
// #ifndef MP
|
||||
uni.navigateTo({
|
||||
url: '/package_a/monitor/monitor'
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
goToAsset() {
|
||||
uni.navigateTo({
|
||||
url: '/package_a/asset/asset'
|
||||
|
|
|
|||
Loading…
Reference in New Issue