Video
Requires:
@ray-js/ray≥1.4.24
Description
Video component supporting playback controls, bullet comments, and full screen.
Props
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
src | string | Yes | - | Source URL of the video to play; network URLs are supported |
duration | number | No | 0 | Specify the video duration |
controls | boolean | No | true | Whether to show the default controls (play/pause button, progress, time) |
| No | - | Bullet comment list | ||
danmuBtn | boolean | No | false | Whether to show the bullet comment button; only effective at initialization and cannot be changed dynamically |
enableDanmu | boolean | No | false | Whether to display bullet comments; only effective at initialization and cannot be changed dynamically |
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 | - | URL of the video poster image |
showMuteBtn | boolean | No | false | Whether to show the mute button |
autoPause | boolean | No | true | Whether to auto-pause when out of the viewport |
| No | - | Triggers when playback starts or resumes | ||
| No | - | Triggers when playback is paused | ||
| No | - | Triggers when playback reaches the end | ||
| 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 | - | Triggered when the browser can play the video | ||
| No | - | Triggered when the browser can play without stalling for buffering | ||
| No | - | Triggered when the video is ready after being paused or stopped due to buffering | ||
| No | - | Triggered when the playback speed changes | ||
| No | - | Triggered when the volume changes | ||
| No | - | Triggers when seek completes |
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 | - |
Examples
Basic usage
Playback configuration
Danmaku and events
Related Links
Related API: createVideoContext
Scan with SmartLife App to Try
Download Sample CodeFAQ
Default width, height, and supported formats of Video
videodefault width is 300px and height is 225px. You can set the width and height via tyss.videosupports three video formats: MP4, WebM, and Ogg.- MP4 = MPEG-4 files using H.264 video codec and AAC audio codec
- WebM = WebM files using VP8 video codec and Vorbis audio codec
- Ogg = Ogg files using Theora video codec and Vorbis audio codec
How do I get the video playback progress?
You can use onTimeupdate to get the playback duration of the video.