通过阅读本文,您可以了解通过服务端SDK调用OpenAPI管理智能媒体服务云剪辑工程的示例代码。
注意事项
创建云剪辑工程时,Title为必选参数;如果要调用 SubmitMediaProducingJob提交剪辑合成作业,参数Timeline必须设置。
示例代码
您可以通过阿里云OpenAPI开发者门户在线调试。
package com.aliyun.ice.sample;
import com.aliyun.ice20201109.Client;
import com.aliyun.ice20201109.models.*;
import com.aliyun.teaopenapi.models.Config;
public class EditingProjectSample {
public static void main (String args[]) throws Exception {
// 阿里云账号AccessKey拥有所有API的访问权限,建议您使用RAM用户进行API访问或日常运维。
// 本示例以将AccessKey ID和 AccessKey Secret保存在环境变量为例说明。配置方法请参见:https://help.aliyun.com/document_detail/378657.html
com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
Config config = new Config();
config.setCredential(credentialClient);
// 如需硬编码AccessKey ID和AccessKey Secret,代码如下,但强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。
// config.accessKeyId = <yourAccessKeyId>;
// config.accessKeySecret = <yourAccessKeySecret>;
config.endpoint = "ice.cn-shanghai.aliyuncs.com";
Client client = new Client(config);
// 搜索云剪辑工程
SearchEditingProjectRequest searchEditingProjectRequest = new SearchEditingProjectRequest();
SearchEditingProjectResponse searchEditingProjectResponse = client.searchEditingProject(searchEditingProjectRequest);
System.out.println("totle count : " + searchEditingProjectResponse.getBody().getTotalCount());
System.out.println("next token : " + searchEditingProjectResponse.getBody().getNextToken());
System.out.println("size : " + searchEditingProjectResponse.getBody().getProjectList().size());
if (searchEditingProjectResponse.getBody().getProjectList().size() > 0) {
System.out.println("projectid : " + searchEditingProjectResponse.getBody().getProjectList().get(0).getProjectId());
System.out.println("title : " + searchEditingProjectResponse.getBody().getProjectList().get(0).getTitle());
System.out.println("maxresult : " + searchEditingProjectResponse.getBody().getMaxResults());
}
// 创建云剪辑工程
CreateEditingProjectRequest createEditingProjectRequest = new CreateEditingProjectRequest();
createEditingProjectRequest.setTitle("测试工程名字");
createEditingProjectRequest.setDescription("测试工程描述");
createEditingProjectRequest.setTimeline("{\"VideoTracks\":[{\"VideoTrackClips\":[{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"}]}]}");
createEditingProjectRequest.setCoverURL("http://xxxx/coverUrl.jpg");
CreateEditingProjectResponse createEditingProjectResponse = client.createEditingProject(createEditingProjectRequest);
String projectId = createEditingProjectResponse.getBody().getProject().getProjectId();
System.out.println("project id : " + projectId);
// 获取单个云剪辑工程
GetEditingProjectRequest getEditingProjectRequest = new GetEditingProjectRequest();
getEditingProjectRequest.setProjectId(projectId);
GetEditingProjectResponse getEditingProjectResponse = client.getEditingProject(getEditingProjectRequest);
GetEditingProjectResponseBody.GetEditingProjectResponseBodyProject project = getEditingProjectResponse.getBody().getProject();
System.out.println("project id : " + project.getProjectId());
// 修改云剪辑工程
UpdateEditingProjectRequest updateEditingProjectRequest = new UpdateEditingProjectRequest();
updateEditingProjectRequest.setProjectId("11119b4d7cf14dc7b83b0e801cbe1ce6");
updateEditingProjectRequest.setTimeline("{\"VideoTracks\":[{\"VideoTrackClips\":[{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"}]}]}");
UpdateEditingProjectResponse updateEditingProjectResponse = client.updateEditingProject(updateEditingProjectRequest);
System.out.println("request id : " + updateEditingProjectResponse.getBody().getRequestId());
// 删除云剪辑工程
DeleteEditingProjectsRequest deleteEditingProjectsRequest = new DeleteEditingProjectsRequest();
deleteEditingProjectsRequest.setProjectIds("****9b4d7cf14dc7b83b0e801cbe****,****9b4d7cf14dc7b83b0e801cbe****");
DeleteEditingProjectsResponse deleteEditingProjectsResponse = client.deleteEditingProjects(deleteEditingProjectsRequest);
System.out.println("request id : " + deleteEditingProjectsResponse.getBody().getRequestId());
}
}
相关接口
文档内容是否对您有帮助?