本示例介绍如何使用Alibaba Cloud SDK for Java调用QueryMediaList接口查询转码作业。

前提条件

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-mts</artifactId>
    <version>2.7.2</version>
</dependency>

示例代码

说明 在执行前,您需要获取媒体ID(MediaIds)。
package com.ygx.program;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.mts.model.v20140618.QueryJobListRequest;
import com.aliyuncs.mts.model.v20140618.QueryJobListResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;

public class TestQueryJobList {

    public static void main(String[] args) {
        // 创建QueryJobList实例并初始化
        DefaultProfile profile = DefaultProfile.getProfile(
                "<your-region-id>",            // 地域ID
                "<your-access-key-id>",        // 您的AccessKey ID
                "<your-access-key-secret>" );    // 您的AccessKey Secret
        IAcsClient client = new DefaultAcsClient(profile);
        QueryJobListRequest request = new QueryJobListRequest();
        // 转码作业ID列表,逗号分隔,一次最多10个
        request.setJobIds("<your-ids>");
        try {
            QueryJobListResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());
        }
    }
}
说明 更多QueryMediaList接口内容,请参见 新版API参考