Skip to main content

Video Playback

WedaVideo

Applicable Scenarios

Used for displaying and playing video resources.

Basic Capabilities Description

  1. By entering a playable video URL in the video resource properties, the video can be played, compatible with most mainstream video formats. Additionally, it supports independent configuration of the video cover.
  2. Provides functional control attributes such as "autoplay, loop playback, mute mode playback", and others.
  3. Some browsers block the default autoplay behavior.
  4. Video resources support Cloud File id. Using a Cloud File id to play videos stored in the cloud will consume the account's cdn resources. Once the cdn resources are exhausted, the video resources cannot be played.
  5. If data source binding is used for video resource properties, the video cannot be played in the editor editing area since mock data is utilized for the data source.

Property Introduction

External properties received by the component

Property Name
Property Identifier
Type
Description
Initial playback time (seconds)startTimenumber

Less than 0 is disabled. If the value exceeds the video duration, it will be set to the maximum duration.

0
Specify video duration (seconds)endTimenumber

Less than 0 is disabled; if the value exceeds the video duration, it will be set to the maximum duration; the progress bar display length does not change on the H5 side but will alter on the mini program side.

Example: 0

video resourcesvideoDataSourcestring

Do not include Chinese in video resource host addresses, as it may lead to compatibility issues. See the video resource configuration guide (https://cloud.tencent.com/document/product/1301/104390).

Playable video resource address, supports cloud file ID

Example: "https://qcloudimg.tencent-cloud.cn/raw/472043e1e13e1cc06e4afc46407e8c4d.mp4"

Cover imageposterImagestring
autoplayautoPlayboolean

From the user's perspective, web pages or apps automatically sending noise without warning may be annoying, inconvenient, or disliked. Therefore, browsers usually only allow autoplay under specific circumstances, such as muted playback. For details, see (https://developer.mozilla.org/zh-CN/docs/Web/Media/Autoplay_guide).

Ensure playback availability, mute can be enabled

loop playbackloopPlayboolean
mute playbackmutePlayboolean
playback controlscontrolBarStatusboolean

Control video playback, pause, mute, full-screen and other features. After disabling, it is equivalent to watch video only without interaction.

Default value: true

Play button in the middle of the videoshowCenterPlayBtnboolean

Whether to display the play button in the middle of the video

Default value: true

layout modeobjectFitstring

When the video size is inconsistent with the container size, the video form

Default value: "contain"

Events

Events exposed by the component. You can listen to component events to trigger external actions

Event Name
Event Code
Event Output Parameters event.detail
Applicable Scenarios
Description
start/continue playbackplayCompatible with all platforms

When playback starts or continues, the play event is triggered. This is supported in WeChat Mini Program Base Library 1.0.0 and above.

pause playbackpauseCompatible with all platforms

When playback is paused, the pause event is triggered. This is supported in WeChat Mini Program Base Library 1.0.0 and above.

Play to the endendedCompatible with all platforms

When playback reaches the end, the ended event is triggered. This is supported in WeChat Mini Program Base Library 1.0.0 and above.

playback progress adjustmenttimeupdateobject
  • currentTime: number当前播放时间

    当前播放时间

  • duration: number视频总时长

    视频总时长

Compatible with all platforms

Trigger on playback progress change, event.detail = {currentTime, duration}. Trigger frequency is 250ms once, supported by WeChat Mini Program Base Library 1.0.0+

full screen switchfullscreenchangeobject
  • fullScreen: boolean是否全屏

    是否全屏

  • direction: string全屏方向

    全屏方向

    Optional values:vertical(垂直) horizontal(水平)
Compatible with all platforms

Trigger when entering or exiting full screen mode. event.detail = {fullScreen, direction}. Valid values for direction: vertical or horizontal. Supported by WeChat Mini Program Base Library 1.4.0 and above.

video bufferwaitingCompatible with all platforms

When buffering occurs during video playback, the event is triggered. This is supported in WeChat Mini Program Base Library 1.7.0 and above.

Video playback errorerrorobject
  • message: string错误详情

    错误详情

Compatible with all platforms

Trigger on video playback error, supported by WeChat Mini Program Base Library 1.7.0+

loading progress transitionprogressobject
  • buffered: number缓冲进度百分比

    缓冲进度百分比

Compatible with all platforms

Trigger when loading progress changes. Supports only segment loading. event.detail = {buffered}, percentage. Supported by WeChat Mini Program Base Library 2.4.0 and above.

Video metadata loading completedloadedmetadataobject
  • width: number视频宽度

    视频宽度

  • height: number视频高度

    视频高度

  • duration: number视频时长

    视频时长

Compatible with all platforms

Trigger when video metadata loading is completed. event.detail = {width, height, duration}. Supported by WeChat Mini Program Base Library 2.7.0 and above.

Navigate to specified positionseekcompleteobject
  • position: number视频位置

    小程序上,iOS 单位 s, Android 单位 ms

Compatible with all platforms

Trigger upon seek completion (position iOS unit s, Android unit ms), supported by mini program base library 2.12.0 and above

Properties API

Through the Property API, you can access the internal state and property values of components. You can access internal values using$w.componentId.propertyName, such as $w.input1.value. For details, please refer to Property API

Read-only Property Name
Property Identifier
Type
Description
instance of a video componentvideoContextobject

The Web side uses a VideoJS player instance. Refer to the documentation: https://docs.VideoJS.com/player#player-title. The mini program side uses a VideoContext instance. Refer to the documentation: https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.html

Method API

Through the Method API, you can programmatically trigger internal methods of components, such as submitting forms, displaying popups, etc. You can call component methods using $w.componentId.methodName, such as $w.form1.submit()

Method Name
Method Identifier
Parameters
Method Description
play videoplay

Use $w.video1.play() to play video. Mini Program API documentation: https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.play.html

pause videopause

Use $w.video1.pause() to pause video. Mini Program API document: https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.pause.html

stop videostop

Use $w.video1.stop() to stop video. Mini Program API document: https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.stop.html

Navigate to specified positionseekobject
  • position: number指定位置

    指定位置

Use $w.video1.seek({ position }) to navigate to the specified position. Mini Program API document: https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.seek.html

Set playback speedplaybackRateobject
  • rate: number倍速

    倍速

Use $w.video1.playbackRate({ rate }) to adjust playback speed. Mini Program API documentation: https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.playbackRate.html

Enter full screenrequestFullScreen

Use `$w.video1.requestFullScreen()` to enter full-screen mode. See the mini program API documentation: https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.requestFullScreen.html

Exit full screenexitFullScreen

Use `$w.video1.exitFullScreen()` to exit full screen mode. See the mini program API documentation: https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.exitFullScreen.html

Style API

None