メインコンテンツへスキップ

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

PropertyTypeDefaultDescription
url (Required)string''Source URL of the video
volumenumber1How loud the video will be played. A value between 0 and 1
loopbooleanfalseWhether the video restarts after it finishes
pausedbooleanfalseWhether the video is currently paused
speednumber1The playback speed of the video. Also affects the pitch of the audio
positionalbooleanfalseWhether the video's audio is played positionally
refDistancenumber1Only applied if positional is true. The distance at which the audio begins to diminish in volume. Must be a non-negative value
distanceModelstring'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'
rolloffFactornumber1Only 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–∞
maxDistancenumber10000Only 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;
})

Remove

Removes the component from the entity.

Example

ecs.VideoControls.remove(world, component.eid)

Has

Returns true if the component is present on the entity.

Example

ecs.VideoControls.has(world, component.eid)

Reset

Adds, or resets the component to its default state.

Example

ecs.VideoControls.reset(world, component.eid)

Advanced Functions

Cursor

Returns a mutable reference. Cursors are reused so only one cursor for each component can exist at a time.

Example
ecs.VideoControls.cursor(world, component.eid)

Acquire

Same behavior as cursor, but commit must be called after the cursor is done being used.

Example
ecs.VideoControls.acquire(world, component.eid)

Commit

Called after acquire. An optional third argument determines whether the cursor was mutated or not.

Example
ecs.VideoControls.commit(world, component.eid)
ecs.VideoControls.commit(world, component.eid, false)

Dirty

Mark the entity as having been mutated. Only needed in a specific case where systems are mutating data.

Example
ecs.VideoControls.dirty(world, component.eid)