实现开始任务功能后,您可以调用StopMPUTask实现停止任务。

前提条件

在进行开始任务之前,请确保您已经完成以下操作:

接口说明

调用StopMPUTask实现停止任务,具体接口信息请参见StopMPUTask

方法示例

您需要在pom.xml文件中添加依赖。
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-rtc</artifactId>
    <version>1.0.4</version>
</dependency>
说明 不同语言的版本号,请参见阿里云SDK中心
import com.aliyuncs.*;
import com.aliyuncs.profile.*;
import com.aliyuncs.http.*;
import com.aliyuncs.rtc.model.v20180111.*;
import com.aliyuncs.exceptions.*;
public class StopTask {
private String regionID = "yourRegionId"; //例如:cn-hangzhou
private String endpoint = "rtc.aliyuncs.com";
private String accessKeyID = "yourAccessSecret";
private String accessKeySecret = "yourAccessSecret";
private String stopTask(String appID, String channelID, String taskID) throws ClientException {
           try {
            DefaultProfile profile = DefaultProfile.getProfile(regionID, accessKeyID, accessKeySecret);
            DefaultAcsClient client = new DefaultAcsClient(profile);
            StopMPUTaskRequest request = new StopMPUTaskRequest();
            request.setAppId(appID);
            request.setTaskId(taskID); // 任务ID
            DefaultProfile.addEndpoint(regionID, regionID, request.getProduct(), endpoint);            
            request.setProtocol(ProtocolType.HTTP);
            StopMPUTaskResponse response = client.getAcsResponse(request);
            String requestId = response.getRequestId();
            return requestId;
            } catch (ClientException ex) {
            ex.printStackTrace();
            return "";
        }
    }
}