Set Video Player
Updated: 2022-09-02 18:08:07
Interface Description
1、通过视频id和播放器id,设置视频的播放器
2、接口支持https协议
Interface URL
http://api.polyv.net/v2/play/set-video-player
Request Method
POST
Interface Constraints
- The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls have frequency limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| userid | true | String | POLYV VOD account ID. Refer to Get Secret Key for acquisition. Path: Official Website -> Login -> VOD (API Interface) |
| ptime | true | Long | Current time in milliseconds, valid within 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 never be saved 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 and obtain response data. See Signature Generation Rules |
| vid | true | String | Video ID, e.g., 1b448be3235552e5fafb16489eb01839_1. Path: POLYV VOD Admin -> Video List |
| playerId | true | String | Player ID. Path: POLYV VOD Admin -> Player Settings. Can also be obtained from Query Player List. When the playerId value is invalid, the video's player ID will be set to the default player ID |
Example
http://api.polyv.net/v2/play/set-video-player
Form Parameters:
vid=1b448be323d467dcf6a0f9cdde4e9ca0_1&sign=0DFE0E65139ABAEFE0DFEF776649F8BEC0F9DE7F&userid=1b448be323&ptime=1620283115760&playerId=d4b8dDzXsT
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 auxiliary error reason |
| data | Array | Returns player list information on success [See data field description](/vod/api/player/set_player.md?id=data字段说明]. Returns empty on failure |
data Field Description
| Field | Type | Description |
|---|---|---|
| userid | String | POLYV VOD account ID, e.g., 1b448be323 |
| vid | String | Video ID, e.g., 1b448be323d467dcf6a0f9cdde4e9ca0_1 |
| playerId | String | Player ID, e.g., 1b448be323 |
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. HttpUtil.java and VodSignUtil.java in the test cases are included in the download file.
It is strongly recommended to use the VOD Java SDK for API functionality integration. The VOD Java SDK provides unified packaging and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(VodVideoPlayerTest.class);
/**
* 设置视频的播放器
*/
@Test
public void testSetPlayer() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/play/set-video-player";
String vId = "1b448be323d467dcf6a0f9cdde4e9ca0_1";
String playerId = "d4b8dDzXsT";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("userid", userId);
requestMap.put("ptime", ptime);
requestMap.put("vid", vId);
requestMap.put("playerId", playerId);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.postFormBody(url, requestMap);
log.debug("测试设置视频的播放器,{}", response);
//do somethings
}
Response Example
For system global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "success",
"data": ["userid: 1b448be323", "vid: 1b448be323d467dcf6a0f9cdde4e9ca0_1", "playerId: d4b8dDzXsT"]
}
Error Example
Incorrect Signature
{
"code":400,
"status":"error",
"message":"the sign is not right",
"data":""
}
Timestamp Expired
{
"code":400,
"status":"error",
"message":"ptime is too old.",
"data":""
}
