LittleJS 1.28.0

UISystem

UIVideo

UIVideo - A UI object that plays video

Extends UIObject

Constructor

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

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
const video = new UIVideo(vec2(400, 300), vec2(320, 240), 'video.mp4', true);
video.play();

Members

Methods

Inherited from UIObject

Members

video : HTMLVideoElementuiSystem.js:1816

The video player

volume : numberuiSystem.js:1812

The video volume

Methods

Clean up video on destroy

getCurrentTime() → numberuiSystem.js:1876

Get current time in seconds

Returns

Current playback time

getDuration() → numberuiSystem.js:1880

Get duration in seconds

Returns

Total video duration

getVideoSize() → Vector2uiSystem.js:1884

Get the native video dimensions

Returns

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

hasEnded() → booleanuiSystem.js:1860

Check if video has ended playing

isLoading() → booleanuiSystem.js:1846

Check if video is currently loading

isPaused() → booleanuiSystem.js:1851

Check if video is currently paused

isPlaying() → booleanuiSystem.js:1855

Check if video is currently playing

Pause the video

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

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:1872

Set playback speed

rate number

Playback rate multiplier

setTime(time)uiSystem.js:1889

Seek to time in seconds

time number

Time in seconds to seek to

setVolume(volume)uiSystem.js:1864

Set volume (0-1)

volume number

Volume level (0-1)

Stop and reset the video