更新记录

1.2.0(2022-08-03)

本次主要更新: 1.ios 修复 停止回放 方法报错问题

1.1.0(2022-08-02)

本次主要更新: 1.andorid 修复回放播放不了 2.增加回放相关的方法

1.0.0(2022-07-24)

新版首发

查看更多

平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 12.0 armeabi-v7a:支持,arm64-v8a:支持,x86:未测试 适用版本区间:11 - 16

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


KJ-HCNet

海康设备网络SDK

使用

<template>
    <view class="content">
        <KJ-HCNet class="HCNet" ref="HCNet" :style="{width:'100%',height:palyerHeight}">
            <view class="video-view" :style="{width:'100%',height:palyerHeight}">
                <view class=" top-title" :style="{width:'100%'}">
                    <view></view>
                    <text :style="{color:'#fff'}">标题</text>
                    <view></view>
                </view>
                <view class="bottom-title" :style="{width:'100%'}">
                    <button type="primary" @click="full">全屏</button>
                    <button type="primary" @click="selectCamera">选择摄像头</button>
                </view>
            </view>
        </KJ-HCNet>
        <view class="btns">
            <button type="primary" @click="NET_DVR_Init">初始化SDk</button>
            <button type="primary" @click="NET_DVR_Login_V40">登录</button>
            <button type="primary" @click="NET_DVR_RealPlay_V40">预览</button>
            <button type="primary" @click="NET_DVR_StopRealPlay">停止预览</button>
            <button type="primary" @click="NET_DVR_OpenSound">打开声音</button>
            <button type="primary" @click="NET_DVR_CloseSound">关闭声音</button>
            <button type="primary" @click="NET_DVR_CapturePictureBlock">抓图</button>
            <button type="primary" @click="NET_DVR_PTZControl_Other">云台控制</button>
            <button type="primary" @click="NET_DVR_StartVoiceCom_V30">开始对讲</button>
            <button type="primary" @click="NET_DVR_StopVoiceCom">停止对讲</button>
            <button type="primary" @click="NET_DVR_PlayBackByTime">设置回放参数</button>
            <button type="primary" @click="NET_DVR_PlayBackControl_V40">开始回放</button>
            <button type="primary" @click="NET_DVR_StopPlayBack">停止回放</button>
            <button type="primary" @click="OpenSound">打开回放声音</button>
            <button type="primary" @click="CloseSound">关闭回放声音</button>

        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                title: 'Hello',
                palyerHeight: "500rpx",
                lUserID: 0,
                lChannel: 0,
                lRealHandle: 0,
                lVoiceComHandle: 0,
                lPlayHandle: 0,
                isFull: false,
                selectTexts: [],
                selectValues: []
            }
        },
        onLoad() {
            if (plus.os.name == 'Android') {
                plus.android.requestPermissions(
                    ['android.permission.RECORD_AUDIO', //对讲需要
                    ],
                    function(resultObj) {
                        var result = 0;
                        for (var i = 0; i < resultObj.granted.length; i++) {
                            var grantedPermission = resultObj.granted[i];
                            console.log('已获取的权限:' + grantedPermission);
                            result = 1
                        }
                        for (var i = 0; i < resultObj.deniedPresent.length; i++) {
                            var deniedPresentPermission = resultObj.deniedPresent[i];
                            console.log('拒绝本次申请的权限:' + deniedPresentPermission);
                            result = 0
                        }
                        for (var i = 0; i < resultObj.deniedAlways.length; i++) {
                            var deniedAlwaysPermission = resultObj.deniedAlways[i];
                            console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);
                            result = -1
                        }
                    },
                    function(error) {
                        console.log('申请权限错误:' + error.code + " = " + error.message);
                    }
                );
            }
        },
        onReady() {
            this.NET_DVR_Init();
            this.NET_DVR_Login_V40();
        },
        (res) {
            console.log(JSON.stringify(res))
            if (res.deviceOrientation == "portrait") {
                this.isFull = false;
                plus.navigator.showSystemNavigation();
                this.palyerHeight = '500rpx';
                this.$refs.HCNet.exitFullScreen()
            } else if (res.deviceOrientation == "landscape") {
                this.isFull = true;
                plus.navigator.hideSystemNavigation();
                this.palyerHeight = '750rpx'
                this.$refs.HCNet.requestFullScreen()
            }
        },
        methods: {
            full() {
                console.log("full:" + this.isFull)
                if (!this.isFull) {
                    plus.screen.lockOrientation("landscape-primary");
                    //this.$refs.HCNet.requestFullScreen()
                } else {
                    plus.screen.lockOrientation("portrait-primary");
                    //this.$refs.HCNet.exitFullScreen()
                }
                //plus.screen.unlockOrientation();
                this.isFull = !this.isFull;
            },
            NET_DVR_Init() {
                this.$refs.HCNet.NET_DVR_Init((res) => {
                    console.log("NET_DVR_Init:" + JSON.stringify(res))
                })
            },
            NET_DVR_Login_V40() {
                this.selectTexts = [];
                this.selectValues = [];
                //rtsp://admin:admin123456@192.168.1.64:554 

                // var dic = {
                //  "iP": "222.244.145.1", //ip地址
                //  "port": "20222", //端口
                //  "userName": "admin", //用户名
                //  "password": "hdyt123@" //密码
                // }
                var dic = {
                    "iP": "222.244.145.1", //ip地址
                    "port": "24180", //端口
                    "userName": "admin", //用户名
                    "password": "hdyt123@" //密码
                }
                this.$refs.HCNet.NET_DVR_Login_V40(dic, (res) => {
                    console.log("NET_DVR_Login_V40:" + JSON.stringify(res))
                    this.lUserID = res.lUserID;
                    var byStartChan = res.byStartChan;
                    var byChanNum = res.byChanNum;
                    var byStartDChan = res.byStartDChan;
                    var byIPChanNum = res.byIPChanNum;
                    if (byStartChan > 0) {
                        this.lChannel = byStartChan;
                    }
                    if (byStartDChan > 0) {
                        this.lChannel = byStartDChan;
                    }
                    console.log("lChannel:" + this.lChannel);
                    var iAnalogStartChan = byStartChan;
                    var iDigitalStartChan = byStartDChan;
                    for (var i = 0; i < byChanNum; i++) {
                        this.selectTexts.push({
                            "title": "ACamera_" + iAnalogStartChan
                        });
                        this.selectValues.push(iAnalogStartChan);
                        iAnalogStartChan++;
                    }
                    for (var i = 0; i < byIPChanNum; i++) {
                        this.selectTexts.push({
                            "title": "DCamera_" + iDigitalStartChan
                        });
                        this.selectValues.push(iDigitalStartChan);
                        iDigitalStartChan++;
                    }
                    console.log(JSON.stringify(this.selectValues));

                })
            },
            selectCamera() {
                plus.nativeUI.actionSheet({
                    title: "选择摄像头",
                    cancel: "取消",
                    buttons: this.selectTexts
                }, (res) => {
                    this.lChannel = this.selectValues[res.index - 1];
                    console.log("lChannel:" + this.lChannel);
                });
            },
            NET_DVR_RealPlay_V40() {
                var dic = {
                    "lUserID": this.lUserID,
                    "lChannel": this.lChannel
                }
                console.log(JSON.stringify(dic))
                this.$refs.HCNet.NET_DVR_RealPlay_V40(dic, (res) => {
                    console.log("NET_DVR_RealPlay_V40:" + JSON.stringify(res))
                    this.lRealHandle = res.lRealHandle;
                })
            },
            NET_DVR_StopRealPlay() {
                var dic = {
                    "lRealHandle": this.lRealHandle
                }
                this.$refs.HCNet.NET_DVR_StopRealPlay(dic, (res) => {
                    console.log("NET_DVR_StopRealPlay:" + JSON.stringify(res))
                })
            },
            NET_DVR_OpenSound() {
                var dic = {
                    "lRealHandle": this.lRealHandle
                }
                this.$refs.HCNet.NET_DVR_OpenSound(dic, (res) => {
                    console.log("NET_DVR_OpenSound:" + JSON.stringify(res))
                })
            },
            NET_DVR_CloseSound() {
                this.$refs.HCNet.NET_DVR_CloseSound((res) => {
                    console.log("NET_DVR_CloseSound:" + JSON.stringify(res))
                })
            },
            NET_DVR_CapturePictureBlock() {
                var imagePath = plus.io.convertLocalFileSystemURL("_doc/" + new Date()
                    .getTime() +
                    ".png")
                var dic = {
                    "lRealHandle": this.lRealHandle,
                    "imagePath": imagePath
                }
                this.$refs.HCNet.NET_DVR_CapturePictureBlock(dic, (res) => {
                    console.log("NET_DVR_CapturePictureBlock:" + JSON.stringify(res))
                    uni.saveImageToPhotosAlbum({
                        filePath: imagePath
                    })
                })
            },
            NET_DVR_PTZControl_Other() {
                // #define ZOOM_IN            11    // Zoom in
                // #define ZOOM_OUT        12    // Zoom out 
                // #define FOCUS_NEAR      13  // Focus in 
                // #define FOCUS_FAR       14  // Focus out
                // #define IRIS_OPEN       15  // Iris open 
                // #define IRIS_CLOSE      16  // Iris close 
                // #define TILT_UP            21    // PTZ tilt up 
                // #define TILT_DOWN        22    // PTZ tilt down
                // #define PAN_LEFT        23    // PTZ pan left 
                // #define PAN_RIGHT        24    // PTZ pan right
                // #define UP_LEFT            25    // PTZ turn up and left 
                // #define UP_RIGHT        26    // PTZ turn up and right 
                // #define DOWN_LEFT        27    // PTZ turn down and left 
                // #define DOWN_RIGHT        28    // PTZ turn down and right 
                // #define PAN_AUTO        29    // PTZ auto pan 

                var dic = {
                    "lUserID": this.lUserID,
                    "lChannel": this.lChannel,
                    "dwPTZCommand": 23,
                    "dwStop": 0 //0-开始 1-停止
                }
                console.log(JSON.stringify(dic))
                this.$refs.HCNet.NET_DVR_PTZControl_Other(dic, (res) => {
                    console.log("NET_DVR_PTZControl_Other:" + JSON.stringify(res))
                })
            },
            NET_DVR_StartVoiceCom_V30() {
                var dic = {
                    "lUserID": this.lUserID,
                    "dwVoiceChan": 1,
                    "bNeedCBNoEncData": false
                }
                this.$refs.HCNet.NET_DVR_StartVoiceCom_V30(dic, (res) => {
                    console.log("NET_DVR_StartVoiceCom_V30:" + JSON.stringify(res))
                    this.lVoiceComHandle = res.lVoiceComHandle;
                })
            },
            NET_DVR_StopVoiceCom() {
                var dic = {
                    "lVoiceComHandle": this.lVoiceComHandle
                }
                this.$refs.HCNet.NET_DVR_StopVoiceCom(dic, (res) => {
                    console.log("NET_DVR_StopVoiceCom:" + JSON.stringify(res))
                })
            },
            NET_DVR_PlayBackByTime() {
                var dic = {
                    "lUserID": this.lUserID,
                    "lChannel": this.lChannel,
                    "startTime": {
                        "dwYear": 2022,
                        "dwMonth": 8,
                        "dwDay": 1,
                        "dwHour": 0,
                        "dwMinute": 0,
                        "dwSecond": 0,
                    },
                    "endTime": {
                        "dwYear": 2022,
                        "dwMonth": 8,
                        "dwDay": 1,
                        "dwHour": 16,
                        "dwMinute": 55,
                        "dwSecond": 0,
                    }
                }
                this.$refs.HCNet.NET_DVR_PlayBackByTime(dic, (res) => {
                    console.log("NET_DVR_PlayBackByTime:" + JSON.stringify(res))
                    this.lPlayHandle = res.lPlayHandle
                })
            },
            NET_DVR_PlayBackControl_V40() {
                // #define NET_DVR_PLAYSTART        1//Start play
                // #define NET_DVR_PLAYSTOP        2//Stop play
                // #define NET_DVR_PLAYPAUSE        3//Pause
                // #define NET_DVR_PLAYRESTART        4//Restore
                // #define NET_DVR_PLAYFAST        5//Play Faster
                // #define NET_DVR_PLAYSLOW        6//Play Slower
                // #define NET_DVR_PLAYNORMAL        7//Normal Speed
                // #define NET_DVR_PLAYSTARTAUDIO    9//Open Audio
                // #define NET_DVR_PLAYSTOPAUDIO    10//Close Audio
                // #define NET_DVR_PLAYSETPOS        12//Change playing progress
                // #define NET_DVR_RESETBUFFER      37  //reset matrix decode buffer(remote playback file)

                // public static final int NET_DVR_PLAYSTART = 1;
                //    public static final int NET_DVR_PLAYPAUSE = 3;
                //    public static final int NET_DVR_PLAYRESTART = 4;
                //    public static final int NET_DVR_PLAYFAST = 5;
                //    public static final int NET_DVR_PLAYSLOW = 6;
                //    public static final int NET_DVR_PLAYSTARTAUDIO = 9;
                //    public static final int NET_DVR_PLAYSTOPAUDIO = 10;
                //    public static final int NET_DVR_PLAYAUDIOVOLUME = 11;
                //    public static final int NET_DVR_PLAYSETTIME_V50 = 28;
                //    public static final int NET_DVR_SET_TRANS_TYPE = 32;
                //    public static final int NET_DVR_PLAY_CONVERT = 33;
                var dic = {
                    "lPlayHandle": this.lPlayHandle,
                    "dwControlCode": 1
                }
                this.$refs.HCNet.NET_DVR_PlayBackControl_V40(dic, (res) => {
                    console.log("NET_DVR_PlayBackControl_V40:" + JSON.stringify(res))
                })
            },
            NET_DVR_StopPlayBack() {
                var dic = {
                    "lPlayHandle": this.lPlayHandle
                }
                this.$refs.HCNet.NET_DVR_StopPlayBack(dic, (res) => {
                    console.log("NET_DVR_StopPlayBack:" + JSON.stringify(res))
                    this.NET_DVR_PlayBackByTime();
                })
            },
            OpenSound() {
                var dic = {
                    "lPlayHandle": this.lPlayHandle,
                    "dwControlCode": 9
                }
                this.$refs.HCNet.NET_DVR_PlayBackControl_V40(dic, (res) => {
                    console.log("NET_DVR_PlayBackControl_V40:" + JSON.stringify(res))
                })
            },
            CloseSound() {
                var dic = {
                    "lPlayHandle": this.lPlayHandle,
                    "dwControlCode": 10
                }
                this.$refs.HCNet.NET_DVR_PlayBackControl_V40(dic, (res) => {
                    console.log("NET_DVR_PlayBackControl_V40:" + JSON.stringify(res))
                })
            }
        }
    }
</script>

<style>
    .text {
        color: #fff;
        font-size: 10px;
    }

    .HCNet {
        justify-content: center;
        align-items: center;
        background-color: black;
    }

    .video-view {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
    }

    .tip {
        position: absolute;
        left: 0;
        right: 0;
        top: 250rpx;
        text-align: center;
        color: #fff
    }

    .top-title,
    .bottom-title {
        position: absolute;
        left: 0;
        right: 0;
        height: 70px;
        background-color: rgba(0, 0, 0, 0.1);
        display: flex;
        justify-content: space-between;
        flex-direction: row;
        align-items: center;
        color: #fff;
        padding: 16px;
    }

    .top-title {
        top: 0;
        width: 750rpx;
    }

    .bottom-title {
        bottom: 0;
        width: 750rpx;
    }

    .fullControls-center {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        height: 40px;
    }

    .btns {
        margin-top: 40px;
        display: flex;
        flex-wrap: wrap;
        flex-direction: row;
        align-items: center;
        justify-content: center;
    }
</style>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

语音对讲需要麦克风权限,android.permission.RECORD_AUDIO

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件使用的 海康 SDK 会采集数据,详情可参考:https://open.hikvision.com/

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问