1.引用
<!-- 海康 -->
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<version>1.1.3</version>
</dependency>
2.工具类(海康)
/**
* 分页获取监控点资源
* @param pageNo
* @param pageSize
* @param treeCode
* @return
*/
public static JSONArray getCameras(Integer pageNo, Integer pageSize, String treeCode) {
System.out.println("getCameras=");
/**
* STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
*/
ArtemisConfig.host = "host"; // 平台的ip端口
ArtemisConfig.appKey = "appKey"; // 密钥appkey
ArtemisConfig.appSecret = "appSecret";// 密钥appSecret
/**
* STEP2:设置OpenAPI接口的上下文
*/
final String ARTEMIS_PATH = "/artemis";
/**
* STEP3:设置接口的URI地址
*/
final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
Map<String, String> path = new HashMap<String, String>(2) {
{
put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
}
};
/**
* STEP4:设置参数提交方式
*/
String contentType = "application/json";
/**
* STEP5:组装请求参数
*/
JSONObject jsonBody = new JSONObject();
jsonBody.put("pageNo", pageNo);
jsonBody.put("pageSize",pageSize);
jsonBody.put("treeCode", treeCode);
String body = jsonBody.toJSONString();
/**
* STEP6:调用接口
*/
String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null);// post请求application/json类型参数
System.out.println("result="+result);
if (null != result && !"".equals(result)) {
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject.getJSONObject("data") != null) {
return jsonObject.getJSONObject("data").getJSONArray("list");
} else {
return null;
}
} else {
return null;
}
}
3.前端
(1)直接把官网下载即可,联调的时候只能在内网进行
(2)把demo复制到服务器,直接跑,装个插件即可
(3)将demo里面的html,改成自己需要的文件,比如 vue
4.具体文档
下载插件
下载地址:https://open.hikvision.com/download/5c67f20bb254d61550c2f63e?type=10
安装视频播放插件:
运行demo,以视频预览为例:
修改demo中的ip、ak、sk
用谷歌浏览器打开网页: