coursewareService
1. Asynchronous Courseware Upload
Description
通过视频id上传课件,支持ppt、pptx及pdf文件
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/uploadPPT/asyn
Call Constraints
API calls are rate-limited. Click here for details. For common call exceptions, click here.
The API only returns the upload result. The courseware conversion result must be obtained via event callback. See: Callback Notification Description.
Unit Test
@Test
public void testUploadCourseware() throws IOException, NoSuchAlgorithmException {
VodUploadCoursewareRequest vodUploadCoursewareRequest = new VodUploadCoursewareRequest();
Boolean vodUploadCoursewareResponse = null;
try {
String coursewareFile = getClass().getResource("/courseware/Courseware.ppt").getPath();
vodUploadCoursewareRequest.setVideoId("1b448be32345b255cabc3fe8d65a4d00_1")
.setCourseware(new File(coursewareFile));
vodUploadCoursewareResponse = new VodCoursewareServiceImpl().uploadCourseware(vodUploadCoursewareRequest);
Assert.assertTrue(vodUploadCoursewareResponse);
if (vodUploadCoursewareResponse) {
log.debug("测试异步上传课件成功");
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.
If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ]
If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation] |
| courseware | true | File | Upload courseware |
Return Object Description
true indicates successful courseware upload, false indicates failure.
2. Synchronous Courseware Upload
Description
通过视频id与ppt控制文件上传ppt课件
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/uploadPPT
Call Constraints
API calls are rate-limited. Click here for details. For common call exceptions, click here.
The format of the PPT control file is as follows: each line is "seconds" + ":" + "title" (Note: The PPT control file must be in UTF-8 encoding, otherwise the chapter titles of the courseware will display as garbled characters).
Unit Test
@Test
public void testUploadPPT() throws IOException, NoSuchAlgorithmException {
VodUploadPPTRequest vodUploadPPTRequest = new VodUploadPPTRequest();
Boolean vodUploadPPTResponse = null;
try {
String pptFile = getClass().getResource("/file/PPT.pptx").getPath();
String controlFile = getClass().getResource("/file/controlFile.txt").getPath();
vodUploadPPTRequest.setVideoId(super.getTestVideoId())
.setPpt(new File(pptFile))
.setControlFile(new File(controlFile));
vodUploadPPTResponse = new VodUploadServiceImpl().uploadPPT(vodUploadPPTRequest);
Assert.assertTrue(vodUploadPPTResponse);
if (vodUploadPPTResponse) {
log.debug("测试同步上传课件成功");
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.
If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ]
If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation] |
| ppt | true | File | PPT file |
| controlFile | true | File | PPT control file, file extension is txt, text format as per constraints |
Return Object Description
true indicates successful upload, false indicates failure.
3. Query Courseware
Description
通过视频id查询课件
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/getPPTPage
Call Constraints
- API calls are rate-limited. Click here for details. For common call exceptions, click here.
Unit Test
@Test
public void testQueryCourseware() throws IOException, NoSuchAlgorithmException {
VodQueryCoursewareRequest vodQueryCoursewareRequest = new VodQueryCoursewareRequest();
List<VodQueryCoursewareResponse> vodQueryCoursewareResponseList = null;
try {
vodQueryCoursewareRequest.setVideoId("1b448be32345b255cabc3fe8d65a4d00_1");
vodQueryCoursewareResponseList = new VodCoursewareServiceImpl().queryCourseware(vodQueryCoursewareRequest);
Assert.assertNotNull(vodQueryCoursewareResponseList);
if (vodQueryCoursewareResponseList != null) {
log.debug("测试查询课件成功,{}", JSON.toJSONString(vodQueryCoursewareResponseList));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a successful request, a VodQueryCoursewareResponse object is returned. The B-end processes business logic based on this object.
If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ]
If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation] |
Return Object Description
The return object is a List<VodQueryCoursewareResponse>. The specific elements of VodQueryCoursewareResponse are as follows:
| Parameter | Type | Description |
|---|---|---|
| pageNo | Integer | Courseware page number |
| pageTitle | String | Page title |
| pageImage | String | URL of the transcoded image |
| pageThumbnail | String | Thumbnail URL |
| showTime | Integer | The second in the video playback when this PPT page is displayed, unit: seconds |
4. Delete Courseware
Description
通过视频id删除课件
接口地址(仅做说明使用):https://api.polyv.net/v2/video/%s/deletePPT
Call Constraints
- API calls are rate-limited. Click here for details. For common call exceptions, click here.
Unit Test
@Test
public void testDeleteCourseware() throws IOException, NoSuchAlgorithmException {
VodDeleteCoursewareRequest vodDeleteCoursewareRequest = new VodDeleteCoursewareRequest();
Boolean vodDeleteCoursewareResponse = null;
try {
//准备测试数据
uploadCoursewareOther();
vodDeleteCoursewareRequest.setVideoId("1b448be32345b255cabc3fe8d65a4d00_1");
vodDeleteCoursewareResponse = new VodCoursewareServiceImpl().deleteCourseware(vodDeleteCoursewareRequest);
Assert.assertTrue(vodDeleteCoursewareResponse);
if (vodDeleteCoursewareResponse) {
log.debug("测试删除课件成功");
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Test Description
On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.
If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ]
If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID [corresponds to the vid field in the API documentation] |
Return Object Description
true indicates successful deletion, false indicates failure.
