NativeVideo
Requires:
@ray-js/ray≥0.6.9
Description
Native video playback component.
Props
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
src | string | Yes | - | URL of the video to play; network URLs are supported. In partitioned deployments, ensure the video is accessible |
duration | number | No | - | Specify the video duration, in seconds |
controls | boolean | No | true | Whether to show the default controls (play/pause button, progress, time) |
autoplay | boolean | No | false | Whether to autoplay |
loop | boolean | No | false | Whether to loop |
muted | boolean | No | false | Whether to mute |
initialTime | number | No | 0 | Initial playback position |
showFullscreenBtn | boolean | No | true | Whether to show the fullscreen button |
showPlayBtn | boolean | No | true | Whether to show the play button in the bottom control bar |
showCenterPlayBtn | boolean | No | true | Whether to show the center play button |
objectFit | "contain" | "fill" | "cover" | "none" | No | contain | How the video is fitted when its size differs from the video container |
poster | string | No | - | Poster image URL |
showMuteBtn | boolean | No | false | Whether to show the mute button |
borderWidth | number | No | 0 | Border width, in px |
borderStyle | "solid" | "dashed" | No | solid | Border style; valid values: solid, dashed |
borderColor | string | No | #ffffff | Border color, must be hex format |
borderRadius | number | No | 0 | Border radius, in px |
borderRadiusTopLeft | number | No | - | Top-left border radius, in px |
borderRadiusTopRight | number | No | - | Top-right border radius, in px |
borderRadiusBottomLeft | number | No | - | Bottom-left border radius, in px |
borderRadiusBottomRight | number | No | - | Bottom-right border radius, in px |
backgroundColor | string | No | #ffffff | Background color, must be hex format |
| No | - | Triggers when playback starts or resumes | ||
| No | - | Triggers when playback is paused | ||
| No | - | Triggers when playback reaches the end | ||
| No | - | Triggers when the playback position changes | ||
| No | - | Triggers when entering or exiting fullscreen | ||
| No | - | Triggers when buffering occurs | ||
| No | - | Triggers on playback error | ||
| No | - | Triggers when load progress changes; only a single segment is supported | ||
| No | - | Triggers when video metadata has loaded | ||
| No | - | Triggers when controls visibility toggles | ||
| No | - | Triggers when seek completes | ||
updateLayout | unknown | No | - | Used for cross-layer components to notify the container layer to update styles |
Valid Values
objectFit
| Value | Description | Since |
|---|---|---|
contain | Preserve the aspect ratio and display the entire video; the container may have empty space | - |
fill | Stretch the video to fill the container without preserving the aspect ratio | - |
cover | Preserve the aspect ratio and fill the container, cropping any overflow | - |
none | Keep the video's original size without scaling | - |
borderStyle
| Value | Description | Since |
|---|---|---|
solid | Solid border | - |
dashed | Dashed border | - |
NativeVideoFullscreenChangeDetail.direction
| Value | Description | Since |
|---|---|---|
vertical | Portrait orientation | - |
horizontal | Landscape orientation | - |
Examples
Basic usage
Playback configuration and cover
Custom border and events
Related Links
Related API: createNativeVideoContext. This is a native component based on off-screen rendering. Please note the native component usage restrictions.
Scan with SmartLife App to Try
Download Sample CodeFAQ
native-videodefault width is 300px and height is 225px. You can set the width and height via tyss.- For related principles, refer to Native components based on off-screen rendering.
- Please note the native component usage restrictions.
- Supported video format for
native-video: MP4 (MPEG-4 files using H.264 video codec and AAC audio codec).