Audio and video
Introduction
Audio and video is a medium that combines sound with moving images. You can use this component to display this type of digital content.

Configuration items
Category |
Configuration |
Example |
Description |
Content |
URL |
|
The URL of the video file. |
Poster |
|
The image displayed before the video loads or plays. |
|
Interaction |
Hide |
Hides the component. For more information, see Common properties. |
|
Autoplay |
Specifies whether to automatically play the video after it loads. Because of browser restrictions, autoplayed videos are muted by default. |
||
Loop playback |
Specifies whether to loop the video. |
||
Volume settings |
Sets the volume for the audio and video. |
||
Style |
Margin |
The outer margin. For more information, see Common properties. |
|
Height |
The height. For more information, see Common properties. |
||
Content fit |
Configurable when the height is not set to auto. The properties are `cover`, `contain`, and `fill`. |
||
Control panel |
The control panel for the audio and video. |
||
CSS style |
Blur |
The blur effect. The unit is px. A larger number creates more blur. The default value is 0 px. |
|
Grayscale |
The value ranges from 0 to 1. The default value is 0. |
||
Brightness |
The value usually ranges from 0 to 100. The default value is 1. |
||
Contrast |
The value usually ranges from 0 to 100. The default value is 1. |
||
Saturation |
The value usually ranges from 0 to 100. The default value is 1. |
Properties and methods
Name |
Type |
Example |
Description |
src |
string |
|
The URL of the video file. |
poster |
string |
|
The image displayed before the video loads or plays. |
objectFit |
string |
|
The content fit mode for the audio and video. |
muted |
boolean |
|
The mute status of the audio and video. |
play |
func |
|
Plays the audio and video. |
pause |
func |
|
Pauses the audio and video. |
getProgress |
func |
|
Gets the progress data of the audio and video. This API returns an object of the type { currentTime: number; duration: number; }. |
setSrc |
func |
|
Sets the URL of the video file. |
setPoster |
func |
|
Sets the image to display before the video loads or plays. |
setObjectFit |
func |
|
Sets the content fit mode for the audio and video. |
setMuted |
func |
|
Sets the mute status of the audio and video. If you unmute the video (false) when the volume is 0, the volume is automatically set to 0.2. |
clearSrc |
func |
|
Clears the source URL data of the audio and video. |
clearPoster |
func |
|
Clears the poster data of the audio and video. |
clearObjectFit |
func |
|
Clears the content fit mode data of the audio and video. |
clearMuted |
func |
|
Clears the mute status data of the audio and video. |
Event callbacks
Configuration |
Description |
The event triggered after the audio and video starts playing. |
|
The event triggered after the audio and video is paused. |
|
The event triggered after the audio and video finishes playing. |
|
The event triggered after a playback error occurs. |
|
The callback event for playback progress. |
Scenario example
Display playback progress while a video is playing
As shown in the figure, configure an event handler to listen for the playback progress event. Use the progress API to retrieve the playback progress data. After processing the data, use the `setText` method to assign it to the text component.
This configuration displays the playback progress while the video is playing.


