README
看护家智能摄像机Android SDK
文档地址:https://topcode280.github.io/MonitorGitBook/
原始SDK地址:https://github.com/TopCode280/MonitorGitBook
Installing the plugin
cordova plugin add cordova-plugin-khjcamera
Using the plugin
//0,必须init输入password连接摄像头后才能使用其他方法
//初始化,连接摄像头
KhjCameraPlugin.prototype.init = function(uid,password,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "init", [{"uid":uid,"pass":password}]);
};
//在进行二维码配网时需要Android设备连接一个非5G并可连通外网的WIFI
KhjCameraPlugin.prototype.startqr = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "startqr", [{}]);
};
//开始播放视频
KhjCameraPlugin.prototype.begin = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "begin", [{}]);
};
//停止播放视频
KhjCameraPlugin.prototype.stop = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "stop", [{}]);
};
//修改设备密码 oldPass newPass
KhjCameraPlugin.prototype.changePassword = function(oldPass,newPass,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "changePassword", [{"oldPass":oldPass,"newPass":newPass}]);
};
//接收音频
KhjCameraPlugin.prototype.receiveAudio = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "receiveAudio", [{}]);
};
//停止接收音频
KhjCameraPlugin.prototype.stopRecvAudio = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "stopRecvAudio", [{}]);
};
//发送音频给摄像头
KhjCameraPlugin.prototype.sendAudio = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "sendAudio", [{}]);
};
//停止发送音频
KhjCameraPlugin.prototype.stopSendAudio = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "stopSendAudio", [{}]);
};
//设置视频质量 1高清 HD,3标清 SD,5流畅 LD video quality 1>3>5
KhjCameraPlugin.prototype.setQuality = function(quality,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setQuality", [{"quality":quality}]);
};
//云台转动 direction方向,speed一次转动多少步 0:向右,1向左,2向上,3向下
KhjCameraPlugin.prototype.setPtz = function(direction,speed,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setPtz", [{"direction":direction,"speed":speed}]);
};
//画面翻转
KhjCameraPlugin.prototype.flipping = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "flipping", [{}]);
};
//设置SD卡录像模式
// 0关闭录像 record off
// 1连续录像 record continuous
// 2定时计划 schedule record
// 3报警录像 record when alarm
KhjCameraPlugin.prototype.setVideoRecordType = function(type,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setVideoRecordType", [{"type":type}]);
};
//声音设置 设备音量大小0-100
KhjCameraPlugin.prototype.setDeviceVolume = function(volume,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setDeviceVolume", [{"volume":volume}]);
};
//移动侦测报警 true/false
KhjCameraPlugin.prototype.setAlarmSwitch = function(isAlarm,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setAlarmSwitch", [{"isAlarm":isAlarm}]);
};
//设置布防撤防 true布防,false撤防
KhjCameraPlugin.prototype.setDefence = function(onoff,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setDefence", [{"onoff":onoff}]);
};
//移动侦测灵敏度,等级1-5 5灵敏度最高
KhjCameraPlugin.prototype.setMotionDetect = function(motion,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setMotionDetect", [{"motion":motion}]);
};
//开关声音侦测报警 true/false
KhjCameraPlugin.prototype.setSoundAlarm = function(onoff,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setSoundAlarm", [{"onoff":onoff}]);
};
//设置报警时设备是否发出报警声音 true/false
KhjCameraPlugin.prototype.setAlarmVolume = function(onoff,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setAlarmVolume", [{"onoff":onoff}]);
};
KhjCameraPlugin.prototype.formatSdcard = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "formatSdcard", [{}]);
};
/**
* 参数设置为服务器地址,设备推送消息的实际地址是服务器地址+/pushMsg
* 设置“www.hao123.com”,设备会向www.hao123.com/pushMsg发送报警消息
*/
KhjCameraPlugin.prototype.setPhpServer = function(url,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setPhpServer", [{"url":url}]);
};
//设备报警上传到上述setPhpServer接口的json数据包含图片的名称,可以连接设备后使用mCamera.downLoadFile()下载图片,
//但是,连接设备再从设备端下载图片可能由于网络等各种原因造成下载图片失败,为了确保下载图片成功,用户可以调用mCamera.setPictureUrl,
//设置一个服务器图片上传的接口,设置改接口后,设备会向该接口上传图片,设备在推送到setPhpServer接口的json数据中包含一个imgUrl字段,就是上传图片的地址,用户可以使用
//该url地址从服务器下载报警图片,服务器下载的url地址必须是"服务器上传报警图片接口/图片的名称"
KhjCameraPlugin.prototype.setPictureUrl = function(url,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "setPictureUrl", [{"url":url}]);
};
//查询设备SD卡上的图片,传入格式"yyyy-MM-dd"的日期值和是否第一张的begin(true/false),返回JSON,code为0表示还可以继续调用返回下一张图片,1为后面没有图片了,每次返回文件为files参数
KhjCameraPlugin.prototype.listJpegfile = function(date,begin,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "listJpegfile", [{"date":date,"begin":begin}]);
};
//查询设备SD卡上的视频,传入格式"yyyy-MM-dd"的日期值和是否第一张的begin(true/false),返回JSON,code为0表示还可以继续调用返回下一张图片,1为后面没有视频了,每次返回文件为files参数
KhjCameraPlugin.prototype.listvideoFile = function(date,begin,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "listvideoFile", [{"date":date,"begin":begin}]);
};
//下载listJpegfile或者listvideoFile读取到的文件,传入读取到的文件名
KhjCameraPlugin.prototype.downLoadFile = function(filename,success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "downLoadFile", [{"filename":filename}]);
};
KhjCameraPlugin.prototype.playBackVideoStart = function(filename,success, fail) { //回放视频,该接口不能和begin同时使用,必须先暂停播放,才能回放,停止回放后才能继续播放
return cordova.exec(success, fail, "KhjCameraPlugin", "playBackVideoStart", [{"filename":filename}]);
};
KhjCameraPlugin.prototype.stopPlayBack = function(success, fail) { //停止回放
return cordova.exec(success, fail, "KhjCameraPlugin", "stopPlayBack", [{}]);
};
//type message 没有type就是视频数据 说明
//connect true:连接成功 false:连接失败 连接摄像头是否成功
//qrnet true:二维码配网成功
//changePass true:成功 false:失败 修改密码是否成功
//jpegFiles json:{code:0,files:['filename1','filename2']} 通过listJpegfile读取到的文件名
//videoFiles json:{code:0,files:['filename1','filename2']} 通过listvideoFile读取到的文件名
//download string:localpath 通过downLoadFile下载到本机的本地文件路径
KhjCameraPlugin.prototype.registerNotify = function(success, fail) {
return cordova.exec(success, fail, "KhjCameraPlugin", "registerNotify", [{}]);
};