# Mix 插件使用说明

## 1. 导入并加载插件

```js
import { Client } from '@urtc/sdk-web';
import { plugin } from '@urtc/plugin-mix';

Client.use(plugin);
```

## 2. 录制 API 调用示例

### 开启录制

```js
client
  .$mixer
  .startRecord({
    storage: {
      bucket: 'test-record',
      region: 'cn-bj',
    },
    output: {
      layout: {
        type: 'main',
      },
    }
  })
  .then((res) => {
    console.log('开启录制成功，录制文件名：', res.FileName);
  })
  .catch((err) => {
    console.log('开启录制失败 ', err);
  });
```

### 停止录制

```js
client
  .$mixer
  .stopRecord()
  .then(() => {
    console.log('停止录制成功');
  })
  .catch((err) => {
    console.log('停止录制失败 ', err);
  });
```

### 更新录制设置

```js
client
  .$mixer
  .stopRecord()
  .then(() => {
    console.log('停止录制成功');
  })
  .catch((err) => {
    console.log('停止录制失败 ', err);
  });
```

## 3. 转推 API 调用示例

### 开启转推

```js
client
  .$mixer
  .startRelay({
    relay: {
      pushURL: [`rtmp://push.xxxxx.com/xxx/${this.roomId}`]
    },
    output: {
      layout: {
        type: 'main',
      },
    }
  })
  .then(() => {
    console.log('开启转推成功');
  })
  .catch((err) => {
    console.log('开启转推失败 ', err);
  });
```

### 停止转推

```js
client
  .$mixer
  .stopRelay()
  .then(() => {
    console.log('停止转推成功');
  })
  .catch((err) => {
    console.log('停止转推失败 ', err);
  });
```

### 更新转推设置

```js
client
  .$mixer
  .updateRelay({
    output: {
      layout: {
        type: 'main',
        mainViewUId: 'user_yyy',
        mainViewType: 'screen',
      },
    }
  })
  .then(() => {
    console.log('更新成功');
  })
  .catch((err) => {
    console.log('更新失败 ', err);
  });
```
