简介
本文档提供关于提交智能封面任务相关的 API 概览以及 SDK 示例代码。
API | 操作描述 |
提交智能封面任务 |
SDK API 参考
提交智能封面任务
功能说明
提交智能封面任务。
注意
COS Android SDK 版本需要大于等于 v5.9.14。
示例代码
// 存储桶名称,格式为 BucketName-APPIDString bucket = "examplebucket-1250000000";// 对象键,是对象在 COS 上的完整路径,如果带目录的话,格式为 "dir1/object1"String object = "dir1/exampleobject.mp4";// 输出路径文件夹String outputResultPath = "media/job_result/";SubmitSmartCoverJobRequest request = new SubmitSmartCoverJobRequest(bucket);SubmitSmartCoverJob submitSmartCoverJob = new SubmitSmartCoverJob();SubmitSmartCoverJob.SubmitSmartCoverJobInput input = new SubmitSmartCoverJob.SubmitSmartCoverJobInput();// 文件路径input.object = object;submitSmartCoverJob.input = input;SubmitSmartCoverJob.SubmitSmartCoverJobOutput output = new SubmitSmartCoverJob.SubmitSmartCoverJobOutput();// 输出存储桶地域output.region = "ap-guangzhou";// 输出存储桶output.bucket = bucket;// 输出结果的文件名。当有多个输出文件时必须包含 ${number} 通配符。;是否必传:是;output.object = outputResultPath+"smartcover-${number}.png";// 操作配置SubmitSmartCoverJob.SubmitSmartCoverJobOperation operation = new SubmitSmartCoverJob.SubmitSmartCoverJobOperation();operation.output = output;TemplateSmartCover.TemplateSmartCoverSmartCover smartCover = new TemplateSmartCover.TemplateSmartCoverSmartCover();// 图片格式;是否必传:否;默认值:jpg;限制:jpg、png、webp;smartCover.format = "png";operation.smartCover = smartCover;// 任务优先级,级别限制:0 、1 、2 。级别越大任务优先级越高,默认为0;是否必传:否;operation.jobLevel = "0";submitSmartCoverJob.operation = operation;// 任务回调格式,JSON 或 XML,默认 XML,优先级高于队列的回调格式;是否必传:否;submitSmartCoverJob.callBackFormat = "XML";// 任务回调类型,Url 或 TDMQ,默认 Url,优先级高于队列的回调类型;是否必传:否;submitSmartCoverJob.callBackType = "Url";// 任务回调地址,优先级高于队列的回调地址。设置为 no 时,表示队列的回调地址不产生回调;是否必传:否;submitSmartCoverJob.callBack = "http://callback.demo.com";request.setSubmitSmartCoverJob(submitSmartCoverJob);// 更多配置请查看api文档或者SDK源码ciService.submitSmartCoverJobAsync(request, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult cosResult) {// result 提交智能封面任务的结果// 详细字段请查看api文档或者SDK源码SubmitSmartCoverJobResult result = (SubmitSmartCoverJobResult) cosResult;}@Overridepublic void onFail(CosXmlRequest request, CosXmlClientException clientException, CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
说明