Constructor
new UIVideo(posopt, sizeopt, src, autoplayopt, loopopt, volumeopt)
Create a video player UI object
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos | Vector2 | <optional> | ||
size | Vector2 | <optional> | ||
src | string | Video file path or URL | ||
autoplay | boolean | <optional> | false | Start playing immediately? |
loop | boolean | <optional> | false | Loop the video? |
volume | number | <optional> | 1 | Volume percent scaled by global volume (0-1) |
- Source
// Create a video player UI object
const video = new VideoPlayerUIObject(vec2(400, 300), vec2(320, 240), 'cutscene.mp4', true);
video.play();Extends
- UIObject
Members
video
Properties| Type | Description |
|---|---|
| HTMLVideoElement | The video player |
- Source
volume
Properties| Type | Description |
|---|---|
| number | The video volume |
- Source
Methods
destroy()
Clean up video on destroy
- Source
getCurrentTime() → {number}
Get current time in seconds
- Source
Current playback time
- Type:
- number
getDuration() → {number}
Get duration in seconds
- Source
Total video duration
- Type:
- number
getVideoSize() → {Vector2}
Get the native video dimensions
- Source
Video dimensions (may be 0,0 if metadata not loaded)
- Type:
- Vector2
hasEnded() → {boolean}
Check if video has ended playing
- Source
- Type:
- boolean
isLoading() → {boolean}
Check if video is currently loading
- Source
- Type:
- boolean
isPaused() → {boolean}
Check if video is currently paused
- Source
- Type:
- boolean
isPlaying() → {boolean}
Check if video is currently playing
- Source
- Type:
- boolean
pause()
Pause the video
- Source
play() → {Promise}
Play or resume the video
- Source
Promise that resolves when playback starts
- Type:
- Promise
render()
Render video to UI canvas
- Source
setPlaybackRate(rate)
Set playback speed
| Name | Type | Description |
|---|---|---|
rate | number | Playback rate multiplier |
- Source
setTime(time)
Seek to time in seconds
| Name | Type | Description |
|---|---|---|
time | number | Time in seconds to seek to |
- Source
setVolume(volume)
Set volume (0-1)
| Name | Type | Description |
|---|---|---|
volume | number | Volume level (0-1) |
- Source
stop()
Stop and reset the video
- Source