阿里云音视频服务云端录制typescript版本; 编译后可以使用 node index.js运行
package.json 版本
json
// npm install --save @alicloud/rtc20180111@2.3.0
"@alicloud/rtc20180111": "^2.3.0",
引入
typescript
import Client, { StartCloudRecordRequest, StopCloudRecordRequest, DescribeAppRecordingFilesRequest} from "@alicloud/rtc20180111";
import * as Util from "@alicloud/tea-util";
创建客户端
typescript
// @ts-ignore:
const client = new Client({
endpoint: "rtc.aliyuncs.com",
accessKeyId: "",
accessKeySecret: "",
type: "access_key",
regionId: "cn-hangzhou"
});
旁路推流开始
typescript
const startStreamingOutRequest = new rtc20180111_1.StartStreamingOutRequest({
appId: "",
// 频道 ID
channelId: '',
// 直播推流地址,仅支持传单个地址
url: '',
})
// 03D06E77-5916-53B3-A2F6-48DA78E262D7
client.startStreamingOut(startStreamingOutRequest).then((res) => {
console.log('旁路推流开始_任务成功', res);
}).catch((error) => {
console.log('旁路推流开始_任务失败', error);
});
旁路推流结束
typescript
const stopStreamingOutRequest = new rtc20180111_1.StopStreamingOutRequest({
appId: "",
// 频道 ID
channelId: '',
// 任务id
taskId: '',
});
client.stopStreamingOut(stopStreamingOutRequest).then((res) => {
console.log('旁路推流结束_任务成功', res);
}).catch((error) => {
console.log('旁路推流结束_任务失败', error);
});