---
name: "createIpcPlayerContext"
mode: "api"
versionRequirements:
  - { name: "基础库", version: "2.21.8" }
title: "ty.createIpcPlayerContext - 创建 IPC 播放器上下文"
---

## createIpcPlayerContext

> [VERSION] 基础库 >= 2.21.8

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

### 描述

创建 IPC 播放器上下文 IpcContext 对象

### 参数

`Params`

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `deviceId` | `string` | 是 | IPC 设备的 ID |

### 返回值

类型: `IpcContext`

IpcContext 实例

### 示例代码

#### 创建 IPC 上下文

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