You can query details about one or more transcoding tasks by task ID, task status, page number, start time, and end time.
In the query results, if the page number and maximum number of displayed records are not specified, but the number of records is greater than 10, 10 records are displayed by default on each page.
For details about the search criteria and search result parameters, see the API for querying transcoding tasks.
Querying a Transcoding Task
|
|
String taskId="593";
// Set the task ID.
queryTranscodingRequest.setTaskId(taskId);
// Send a query request.
QueryTranscodingResponse queryTranscodingResponse=mpcClient.queryTranscodingTask(queryTranscodingRequest);
System.out.println(new Gson().toJson(queryTranscodingResponse));
|
Querying Transcoding Tasks
|
|
// A maximum of 10 transcoding task IDs can be queried at a time.
String[] taskIds={"593", "595", "594","597"};
// Set task IDs.
queryTranscodingRequest.setTaskIdArray(taskIds);
// Send a query request.
QueryTranscodingResponse queryTranscodingResponse=mpcClient.queryTranscodingTask(queryTranscodingRequest);
System.out.println(new Gson().toJson(queryTranscodingResponse));
|
Query by Task Status
|
|
String status="CANCELED";
// Set the task status.
queryTranscodingRequest.setStatus(status);
// Send a query request.
QueryTranscodingResponse queryTranscodingResponse=mpcClient.queryTranscodingTask(queryTranscodingRequest);
System.out.println(new Gson().toJson(queryTranscodingResponse));
|
Query by Start Time and End Time
|
|
// Query based on the start time and end time of a transcoding task.
// Set the start time.
queryTranscodingRequest.setStartTime("20180116125625");
// Set the end time.
queryTranscodingRequest.setEndTime("20180118132810");
// Send a query request.
QueryTranscodingResponse queryTranscodingResponse=mpcClient.queryTranscodingTask(queryTranscodingRequest);
System.out.println(new Gson().toJson(queryTranscodingResponse));
|
Query by Page Number
|
|
// Query based on the page number and number of records on each page.
// Set the page number.
queryTranscodingRequest.setPage(0);
// Set the number of records on each page.
queryTranscodingRequest.setSize(4);
// Send a query request.
QueryTranscodingResponse queryTranscodingResponse=mpcClient.queryTranscodingTask(queryTranscodingRequest);
System.out.println(new Gson().toJson(queryTranscodingResponse));
|
Full Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Service process:
* 1. Import the SDK package MPCSDK.jar.
* 2. Set configuration items, including the endpoint, AK, SK, and project ID, for accessing MPC.
* 3. Set request parameters.
* 4. Send a request for querying a transcoding task.
* 5. Return the results.
*/
import com.google.gson.Gson;
import com.huawei.mpc.client.ClientConfig;
import com.huawei.mpc.client.MpcClient;
import com.huawei.mpc.client.MpcConfig;
import com.huawei.mpc.model.transcoding.QueryTrancodingResponse;
import com.huawei.mpc.model.transcoding.QueryTranscodingRequest;
// Set the method for constructing MPC configuration items.
MpcConfig mpcconfig = new MpcConfig();
// Mandatory. Set the endpoint of MPC. For details, see section "Obtaining Key Parameters."
mpcConfig.setEndPoint(endPoint);
// Mandatory. Set the user's project ID. For details, see section "Obtaining Key Parameters."
mpcConfig.setProjectId(projectId);
// Mandatory. Set the SK. For details, see section "Obtaining Key Parameters."
mpcConfig.setSk(sk);
// Mandatory. Set the AK. For details, see section "Obtaining Key Parameters."
mpcConfig.setAk(ak);
/*if you need proxy*/
// Optional. Set the proxy if necessary.
/*
ClientConfig clientConfig = new ClientConfig();
// Set the IP address of the proxy server.
clientConfig.setProxyHost(proxyHost);
// Set the port number of the proxy server.
clientConfig.setProxyPort(Integer.parseInt(proxyPort));
// Set the username for accessing the proxy server.
clientConfig.setProxyUserName(proxyUserName);
// Set the password for accessing the proxy server.
clientConfig.setProxyPassword(proxyPassword);
*/
// MPC construction method
MpcClient mpcClient = new MpcClient(mpcconfig);
/*
* proxy provided
// MPC construction method. If a proxy needs to be configured, use this construction method.
* MpcClient mpcClient=new MpcClient(mpcconfig, clientConfig);
*/
// Set task parameters.
QueryTranscodingRequest queryTranscodingRequest=new QueryTranscodingRequest();
/**
* Single task query
*/
// Query a single transcoding task by task ID.
/*String taskId="";
// Set the task ID.
queryTranscodingRequest.setTaskId(taskId);*/
/**
* Multitasking query
*/
// A maximum of 10 transcoding task IDs can be queried at a time.
String[] taskIds={"593", "595", "594","597"};
// Set task IDs.
queryTranscodingRequest.setTaskIdArray(taskIds);
/**
* According to the status query
*/
/*String status="CANCELED";
// Set the task status.
queryTranscodingRequest.setStatus(status);*/
/**
* According to the page&size query,If you do not provide default display 10 data
*/
// Query based on the page number and number of records on each page.
// Set the page number.
/*queryTranscodingRequest.setPage(0);
// Set the number of records on each page.
queryTranscodingRequest.setSize(4);*/
/**
* According to the startTime&endTime query
*/
// Query by start time and end time
// Set the start time.
/*queryTranscodingRequest.setStartTime("20180116125625");
// Set the end time.
queryTranscodingRequest.setEndTime("20180118132810");*/
// Send a query request.
QueryTranscodingResponse queryTranscodingResponse=mpcClient.queryTranscodingTask(queryTranscodingRequest);
/*response*/
// Return the query results.
System.out.println(new Gson().toJson(queryTranscodingResponse));
|
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.