LittleJS 1.31.0

UISystem

UIVideo

UIVideo - A UI object that plays video

Extends UIObject

Constructor

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

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

The video player

volume : numberuiSystem.js:1919

The video volume

Methods

Clean up video on destroy

getCurrentTime() → numberuiSystem.js:1998

Get current time in seconds

Returns

Current playback time

getDuration() → numberuiSystem.js:2002

Get duration in seconds

Returns

Total video duration

getVideoSize() → Vector2uiSystem.js:2006

Get the native video dimensions

Returns

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

hasEnded() → booleanuiSystem.js:1982

Check if video has ended playing

isLoading() → booleanuiSystem.js:1968

Check if video is currently loading

isPaused() → booleanuiSystem.js:1973

Check if video is currently paused

isPlaying() → booleanuiSystem.js:1977

Check if video is currently playing

Pause the video, it stays paused when a hidden page shows again

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

Play or resume the video; on a page hidden now it waits, as one paused by the page does, and plays when the page shows

Returns

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

Render video to UI canvas

setPlaybackRate(rate)uiSystem.js:1994

Set playback speed

rate number

Playback rate multiplier

setTime(time)uiSystem.js:2011

Seek to time in seconds

time number

Time in seconds to seek to

setVolume(volume)uiSystem.js:1986

Set volume (0-1)

volume number

Volume level (0-1)

Stop and reset the video, it stays stopped when a hidden page shows again