---
name: "IpcPlayerContext"
mode: "api"
versionRequirements:
  - { name: "基础库", version: "2.21.8" }
title: "IpcContext"
---

## IpcPlayerContext

> [VERSION] 基础库 >= 2.21.8

> 💡 IpcContext 通过设备 ID 跟一个 ipc-player 组件绑定，操作对应的 IPC 摄像头设备。
> 支持预览、对讲、录像、截图等操作。

### 描述

IpcContext 实例，可通过 ty.createIpcPlayerContext 获取

### 参数

无


### 返回值

类型: `IpcPlayerContext`

IpcPlayerContext 实例

#### 方法

| 方法名 | 说明 |
| --- | --- |
| `connect` | 连接 IPC 设备 |
| `disconnect` | 断开 IPC 设备连接 |
| `startPreview` | 开始预览 |
| `stopPreview` | 停止预览 |
| `snapshot` | 截图 |
| `setMuted` | 设置静音状态 |
| `setSoundMode` | 设置声音模式 |
| `setClarity` | 设置清晰度 |
| `startTalk` | 开始对讲 |
| `stopTalk` | 停止对讲 |
| `isTalkBacking` | 查询是否正在对讲 |
| `startRecord` | 开始录像 |
| `stopRecord` | 停止录像 |
| `isRecording` | 查询是否正在录像 |
| `setAvailableRockerDirections` | 设置可用的摇杆方向 |
| `setTrackingStatus` | 设置移动追踪状态 |
| `getVideoInfo` | 获取视频信息 |
| `isMuted` | 查询是否静音 |
| `setMessageVideoPlaySpeed` | 倍数播放视频消息 |

### 示例代码

#### 基本使用

```ts
Page({
  onReady() {
    const ipcCtx = ty.createIpcPlayerContext('deviceId');
    ipcCtx.connect({
      success() {
        ipcCtx.startPreview();
      },
    });
  },
});
```
