Query Video Preview Duration
Updated: 2025-01-14 15:48:58
API Description
1、通过视频id查询视频的播放预览时长
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/video/{userid}/get-preview-duration
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended to ensure security. API calls have frequency limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds, valid for 3 minutes |
| sign | true | String | Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules |
| vid | true | String | Video ID |
Example
http://api.polyv.net/v2/video/1b448be323/get-preview-duration?vid=1b448be3239c2ef0cb3ab9fd105f7fb2_1&sign=D7506BD5E514909E2C18E15DA485E2076E714B2F&ptime=1617157510888
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code. 200 indicates success, non-200 indicates failure. See global error description |
| status | String | Response status text |
| message | String | Response description. When code is 400 or 500, provides additional error details |
| data | String | On success, returns the preview duration in seconds; on failure, returns an error description |
Java Request Example
For quick integration of basic code, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and VodSignUtil.java in the downloaded file.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
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("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试查询视频预览时长,{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code":200,
"status":"success",
"message":"success",
"data":180
}
Error Example
{
code: 400,
status: "success",
message: "success",
data: "查询的视频不存在."
}
{
code: 400,
status: "success",
message: "success",
data: "查询的视频没有设置预览时长."
}
