getPlaybackUrl static method
获取回放地址url
cameraIndexCode:摄像头标识
beginTime:开始时间(ISO8601格式:yyyy-MM-dd’T’HH:mm:ss.SSSXXX,例如北京时间:2017-06-14T00:00:00.000+08:00)
endTime:结束时间(ISO8601格式:yyyy-MM-dd’T’HH:mm:ss.SSSXXX,例如北京时间:2017-06-15T00:00:00.000+08:00)
recordLocation: 存储类型 0,中心存储 1,设备存储
version:1是海康SDK1.3版本,默认是2海康SDK1.4版本
isHttps是否为https请求
Implementation
static Future<dynamic> getPlaybackUrl({
String? cameraIndexCode,
String? beginTime,
String? endTime,
int recordLocation = 0,
int version = 2,
bool isHttps = false,
}) async {
if (cameraIndexCode == null || cameraIndexCode.isEmpty) {
return;
}
///根据版本切换地址,isc1.4之后用v2版本
var playbackURLs = playbackURLsV2;
if (version == 1) {
playbackURLs = playbackURLsV1;
}
var headers = ArtemisConfig.createHeaders(playbackURLs);
///根据实际服务器情况选用http或https
String url = 'http://${ArtemisConfig.host}$playbackURLs';
if (isHttps) {
url = 'https://${ArtemisConfig.host}$playbackURLs';
}
Map body = Map();
body['cameraIndexCode'] = cameraIndexCode;
body['beginTime'] = beginTime;
body['endTime'] = endTime;
body['recordLocation'] = recordLocation;
Dio dio = Dio();
dio.interceptors.add(LogInterceptor(requestBody: true));
// 忽略SSL认证
// (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
// (client) {
// client.badCertificateCallback =
// (X509Certificate cert, String host, int port) {
// return true;
// };
// };
(dio.httpClientAdapter as IOHttpClientAdapter).createHttpClient = (){
var client = HttpClient();
client.badCertificateCallback = (X509Certificate cert, String host, int port) {
return true;
};
return client;
};
dio.options.headers.addAll(headers);
Response response = await dio.post(url, data: body);
return response.data;
}