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

## createNativeVideoContext

> [VERSION] Base Library >= 2.21.8

> 💡 Used when the video component uses layered rendering in native environments; in non-native environments it falls back to web video.

### Description

Create a native video context (NativeVideoContext) object

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | ID of the native-video component |

### Return Value

Type: `NativeVideoContext`

NativeVideoContext instance

### Examples

#### Create native video context

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