VideoControls
Description
This component allows entities to control video playback on textures applied to materials. It is automatically added when a video is set through the Studio configurator. If the video is added programmatically, this component must be added manually to enable playback controls.
Properties
Property | Type | Default | Description |
---|---|---|---|
url (Required) | string | '' | Source URL of the video |
volume | number | 1 | How loud the video will be played. A value between 0 and 1 |
loop | boolean | false | Whether the video restarts after it finishes |
paused | boolean | false | Whether the video is currently paused |
speed | number | 1 | The playback speed of the video. Also affects the pitch of the audio |
positional | boolean | false | Whether the video's audio is played positionally |
refDistance | number | 1 | Only applied if positional is true. The distance at which the audio begins to diminish in volume. Must be a non-negative value |
distanceModel | string | 'inverse' | Only applied if positional is true. The algorithm used to reduce volume as the distance increases between this video source and the listener. Options: 'linear', 'inverse', 'exponential' |
rolloffFactor | number | 1 | Only applied if positional is true. How quickly volume is reduced as distance increases. The acceptable range varies depending on the distanceModel: linear: 0–1, inverse: 0–∞, exponential: 0–∞ |
maxDistance | number | 10000 | Only applied if positional is true and distanceModel is 'linear'. Beyond this distance, the volume will not reduce further. Must be a positive value |
Functions
Get
Returns a read-only reference.
Example
ecs.VideoControls.get(world, component.eid)
Set
Ensures the component exists on the entity, then assigns the (optional) data to the component.
Example
ecs.VideoControls.set(world, component.eid, {
url: './assets/video.mp4',
volume: 1,
loop: false,
paused: false,
speed: 1,
positional: false,
refDistance: 1,
distanceModel: ''inverse'',
rolloffFactor: 1,
maxDistance: 10000
})
Mutate
Perform an update to the component within a callback function. Return true
to indicate no changes made.
Example
ecs.VideoControls.mutate(world, component.eid, (cursor) => {
cursor.volume = 0.5;
cursor.loop = true;
return false;
})