LittleJS 1.30.1

UISystem

UIVideo

UIVideo - A UI object that plays video

Extends UIObject

Constructor

new UIVideo(pos, size, src, autoplay, loop, volume)uiSystem.js:1809

Create a video player UI object

pos Vector2
size Vector2
src string

Video file path or URL

autoplay boolean optional, default false

Start playing immediately?

loop boolean optional, default false

Loop the video?

volume number optional, default 1

Volume percent scaled by global volume (0-1)

// Create a video player UI object, in the middle of the canvas
const video = new UIVideo(vec2(), vec2(320, 240), 'video.mp4', true);
video.play();

Members

Methods

Inherited from UIObject

Members

video : HTMLVideoElementuiSystem.js:1834

The video player

volume : numberuiSystem.js:1830

The video volume

Methods

Clean up video on destroy

getCurrentTime() → numberuiSystem.js:1897

Get current time in seconds

Returns

Current playback time

getDuration() → numberuiSystem.js:1901

Get duration in seconds

Returns

Total video duration

getVideoSize() → Vector2uiSystem.js:1905

Get the native video dimensions

Returns

Video dimensions (may be 0,0 if metadata not loaded)

hasEnded() → booleanuiSystem.js:1881

Check if video has ended playing

isLoading() → booleanuiSystem.js:1867

Check if video is currently loading

isPaused() → booleanuiSystem.js:1872

Check if video is currently paused

isPlaying() → booleanuiSystem.js:1876

Check if video is currently playing

Pause the video

play() → Promise<boolean>asyncuiSystem.js:1852

Play or resume the video

Returns

Resolves true once playback starts, false if the browser refused it

Render video to UI canvas

setPlaybackRate(rate)uiSystem.js:1893

Set playback speed

rate number

Playback rate multiplier

setTime(time)uiSystem.js:1910

Seek to time in seconds

time number

Time in seconds to seek to

setVolume(volume)uiSystem.js:1885

Set volume (0-1)

volume number

Volume level (0-1)

Stop and reset the video