---
name: "createNativeVideoContext"
mode: "api"
versionRequirements:
  - { name: "基础库", version: "2.21.8" }
title: "ty.createNativeVideoContext - 创建原生视频上下文"
---

## createNativeVideoContext

> [VERSION] 基础库 >= 2.21.8

> 💡 在原生环境使用异层渲染的 video 组件时使用，非原生环境下降级为 web video。

### 描述

创建原生 video 上下文 NativeVideoContext 对象

### 参数

`Params`

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `id` | `string` | 是 | native-video 组件的 id |

### 返回值

类型: `NativeVideoContext`

NativeVideoContext 实例

### 示例代码

#### 创建原生视频上下文

```ts
Page({
  onReady() {
    const videoCtx = ty.createNativeVideoContext('myNativeVideo');
    videoCtx.play();
  },
});
```
