Skip to content

sud.createVideo ​

JS
Video sud.createVideo(Object object)

Creates a video object.

Parameters ​

Object object ​

PropertyTypeDefaultRequiredDescription
xnumber0NoThe x-coordinate of the video's top-left corner
ynumber0NoThe y-coordinate of the video's top-left corner
widthnumber300NoThe width of the video
heightnumber150NoThe height of the video
srcstringYesThe resource URL of the video
posterstringNoThe cover image of the video
initialTimenumber0NoThe initial playback position of the video, in seconds (s)
playbackRatenumber1.0NoThe playback rate of the video; valid values are 0.5, 0.8, 1.0, 1.25, 1.5
livebooleanfalseNoWhether the video is a live stream
objectFitstring'contain'NoThe scaling mode of the video. Valid values: fill, contain, cover
controlsbooleantrueNoWhether the video shows controls
showProgressbooleantrueNoWhether to show the progress bar at the bottom of the video
showProgressInControlModebooleantrueNoWhether to show the progress bar in the control bar
backgroundColorstring'#000000'NoThe background color of the video
autoplaybooleanfalseNoWhether the video plays automatically
loopbooleanfalseNoWhether the video plays in a loop
mutedbooleanfalseNoWhether the video plays muted
obeyMuteSwitchbooleanfalseNoWhether the video obeys the system mute switch setting (iOS only)
enableProgressGesturebooleantrueNoWhether to enable gesture control of the playback progress
enablePlayGesturebooleanfalseNoWhether to enable the double-tap-to-play gesture
showCenterPlayBtnbooleantrueNoWhether to show the play button in the center of the video
underGameViewbooleanfalseNoWhether the video is displayed beneath the game canvas
autoPauseIfNavigatebooleantrueNoAutomatically pause playback after the video navigates away
autoPauseIfOpenNativebooleantrueNoAutomatically pause playback after the video navigates to a native page

Valid values of objectFit ​

ValueDescription
fillStretches the video to fill the entire container without necessarily preserving its original aspect ratio.
containPreserves the original aspect ratio and scales the video to fit entirely within the container. Some empty space may remain.
coverPreserves the original aspect ratio and scales the video to cover the entire container, with at least one dimension matching the container. Parts of the video may be cropped.

Return Value ​

  • Video: the video object