1、通过视频id查询视频的播放预览时长
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
http://api.polyv.net/v2/video/{userid}/get-preview-duration
http://api.polyv.net/v2/video/1b448be323/get-preview-duration?vid=1b448be3239c2ef0cb3ab9fd105f7fb2_1&sign=D7506BD5E514909E2C18E15DA485E2076E714B2F&userid=1b448be323&ptime=1617157510888
强烈建议您使用点播Java SDK完成API的功能对接,点播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(VodVideoManageManagementTest.class);
/**
*查询视频预览时长
*/
@Test
public void testGetPreviewDuration() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/video/"+userId+"/get-preview-duration";
String vid="1b448be3239c2ef0cb3ab9fd105f7fb2_1";
//调用参数
Map<String, String> requestMap = new HashMap<>();
requestMap.put("userid", userId);
requestMap.put("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试查询视频预览时长,{}", response);
//do somethings
}
{
"code":200,
"status":"success",
"message":"success",
"data":180
}
{
code: 400,
status: "success",
message: "success",
data: "查询的视频不存在."
}
{
code: 400,
status: "success",
message: "success",
data: "查询的视频没有设置预览时长."
}