通過閱讀本文,您可以了解通過服務端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保存在環境變量為例說明。配置方法請參見:http://bestwisewords.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());
}
}
相關接口
文檔內容是否對您有幫助?