# Class: VideoSource

**`Advanced`**

A texture source that uses a video as its resource.
It automatically resizes the texture based on the video dimensions.
It also provides methods to control playback and handle video events.
This class supports automatic loading, playback, and frame updates.
It can also handle cross-origin videos and provides options for looping, muting, and inline playback.

## Extends

- [`TextureSource`](rendering.TextureSource.html.md)\<[`VideoResource`](rendering.VideoResource.html.md)\>

## Constructors

### Constructor

> **new VideoSource**(`options`): `VideoSource`

#### Parameters

##### options

[`VideoSourceOptions`](rendering.VideoSourceOptions.html.md)

#### Returns

`VideoSource`

#### Overrides

[`TextureSource`](rendering.TextureSource.html.md).[`constructor`](rendering.TextureSource.html#constructor)

## Properties

### \_gcData?

> `optional` **\_gcData**: [`GCData`](rendering.GCData.html.md)

GC tracking data, undefined if not being tracked

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`_gcData`](rendering.TextureSource.html#_gcdata)

***

### alphaMode

> **alphaMode**: [`ALPHA_MODES`](rendering.ALPHA_MODES.html.md)

the alpha mode of the texture

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`alphaMode`](rendering.TextureSource.html#alphamode)

***

### antialias

> **antialias**: `boolean` = `false`

Only really affects RenderTextures.
Should we use antialiasing for this texture. It will look better, but may impact performance as a
Blit operation will be required to resolve the texture.

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`antialias`](rendering.TextureSource.html#antialias)

***

### arrayLayerCount

> **arrayLayerCount**: `number` = `1`

how many array layers this texture has (WebGPU depthOrArrayLayers)

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`arrayLayerCount`](rendering.TextureSource.html#arraylayercount)

***

### autoGarbageCollect

> **autoGarbageCollect**: `boolean`

If true, the Garbage Collector will unload this texture if it is not used after a period of time

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`autoGarbageCollect`](rendering.TextureSource.html#autogarbagecollect)

***

### autoGenerateMipmaps

> **autoGenerateMipmaps**: `boolean` = `false`

Should we auto generate mipmaps for this texture? This will automatically generate mipmaps
for this texture when uploading to the GPU. Mipmapped textures take up more memory, but
can look better when scaled down.

For performance reasons, it is recommended to NOT use this with RenderTextures, as they are often updated every frame.
If you do, make sure to call `updateMipmaps` after you update the texture.

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`autoGenerateMipmaps`](rendering.TextureSource.html#autogeneratemipmaps)

***

### destroyed

> `readonly` **destroyed**: `boolean`

Has the source been destroyed?

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`destroyed`](rendering.TextureSource.html#destroyed)

***

### dimension

> **dimension**: [`TEXTURE_DIMENSIONS`](rendering.TEXTURE_DIMENSIONS.html.md) = `'2d'`

how many dimensions does this texture have? currently v8 only supports 2d

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`dimension`](rendering.TextureSource.html#dimension)

***

### format

> **format**: [`TEXTURE_FORMATS`](rendering.TEXTURE_FORMATS.html.md) = `'rgba8unorm'`

the format that the texture data has

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`format`](rendering.TextureSource.html#format)

***

### height

> **height**: `number` = `1`

the height of this texture source, accounting for resolution
eg pixelHeight 200, resolution 2, then height will be 100

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`height`](rendering.TextureSource.html#height)

***

### isPowerOfTwo

> **isPowerOfTwo**: `boolean`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`isPowerOfTwo`](rendering.TextureSource.html#ispoweroftwo)

***

### isReady

> **isReady**: `boolean` = `false`

Whether or not the video is ready to play.

***

### label

> **label**: `string`

optional label, can be used for debugging

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`label`](rendering.TextureSource.html#label)

***

### mipLevelCount

> **mipLevelCount**: `number` = `1`

The number of mip levels to generate for this texture.
this is overridden if autoGenerateMipmaps is true. it is read only!

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`mipLevelCount`](rendering.TextureSource.html#miplevelcount)

***

### pixelHeight

> **pixelHeight**: `number` = `1`

the pixel height of this texture source. This is the REAL pure number, not accounting resolution

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`pixelHeight`](rendering.TextureSource.html#pixelheight)

***

### pixelWidth

> **pixelWidth**: `number` = `1`

the pixel width of this texture source. This is the REAL pure number, not accounting resolution

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`pixelWidth`](rendering.TextureSource.html#pixelwidth)

***

### resource

> **resource**: [`HTMLVideoElement`](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement)

the resource that will be uploaded to the GPU. This is where we get our pixels from
eg an ImageBimt / Canvas / Video etc

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`resource`](rendering.TextureSource.html#resource)

***

### uid

> `readonly` **uid**: `number`

unique id for this Texture source

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`uid`](rendering.TextureSource.html#uid)

***

### uploadMethodId

> **uploadMethodId**: `string` = `'video'`

The upload method for this texture.

#### Overrides

`TextureSource.uploadMethodId`

***

### viewDimension

> **viewDimension**: [`TEXTURE_VIEW_DIMENSIONS`](rendering.TEXTURE_VIEW_DIMENSIONS.html.md) = `'2d'`

how this texture is viewed/sampled by shaders (WebGPU view dimension)

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`viewDimension`](rendering.TextureSource.html#viewdimension)

***

### width

> **width**: `number` = `1`

the width of this texture source, accounting for resolution
eg pixelWidth 200, resolution 2, then width will be 100

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`width`](rendering.TextureSource.html#width)

***

### defaultOptions

> `static` **defaultOptions**: [`VideoSourceOptions`](rendering.VideoSourceOptions.html.md)

The default options for video sources.

#### Overrides

[`TextureSource`](rendering.TextureSource.html.md).[`defaultOptions`](rendering.TextureSource.html#defaultoptions)

***

### extension

> `static` **extension**: [`ExtensionMetadata`](extensions.ExtensionMetadata.html.md) = `ExtensionType.TextureSource`

***

### from()

> `static` **from**: (`resource`) => [`TextureSource`](rendering.TextureSource.html.md)

A helper function that creates a new TextureSource based on the resource you provide.

#### Parameters

##### resource

[`TextureResourceOrOptions`](rendering.TextureResourceOrOptions.html.md)

The resource to create the texture source from.

#### Returns

[`TextureSource`](rendering.TextureSource.html.md)

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`from`](rendering.TextureSource.html#from)

***

### MIME\_TYPES

> `readonly` `static` **MIME\_TYPES**: [`Dict`](utils.Dict.html.md)\<`string`\>

Map of video MIME types that can't be directly derived from file extensions.

## Accessors

### addressMode

#### Get Signature

> **get** **addressMode**(): [`WRAP_MODE`](rendering.WRAP_MODE.html.md)

setting this will set wrapModeU, wrapModeV and wrapModeW all at once!

##### Returns

[`WRAP_MODE`](rendering.WRAP_MODE.html.md)

#### Set Signature

> **set** **addressMode**(`value`): `void`

##### Parameters

###### value

[`WRAP_MODE`](rendering.WRAP_MODE.html.md)

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`addressMode`](rendering.TextureSource.html#addressmode)

***

### autoUpdate

#### Get Signature

> **get** **autoUpdate**(): `boolean`

Should the base texture automatically update itself, set to true by default.

##### Returns

`boolean`

#### Set Signature

> **set** **autoUpdate**(`value`): `void`

##### Parameters

###### value

`boolean`

##### Returns

`void`

***

### isValid

#### Get Signature

> **get** **isValid**(): `boolean`

Checks if the resource has valid dimensions.

##### Returns

`boolean`

True if width and height are set, otherwise false.

***

### lodMaxClamp

#### Get Signature

> **get** **lodMaxClamp**(): `number`

Specifies the minimum and maximum levels of detail, respectively, used internally when sampling a texture.

##### Returns

`number`

#### Set Signature

> **set** **lodMaxClamp**(`value`): `void`

##### Parameters

###### value

`number`

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`lodMaxClamp`](rendering.TextureSource.html#lodmaxclamp)

***

### lodMinClamp

#### Get Signature

> **get** **lodMinClamp**(): `number`

Specifies the minimum and maximum levels of detail, respectively, used internally when sampling a texture.

##### Returns

`number`

#### Set Signature

> **set** **lodMinClamp**(`value`): `void`

##### Parameters

###### value

`number`

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`lodMinClamp`](rendering.TextureSource.html#lodminclamp)

***

### magFilter

#### Get Signature

> **get** **magFilter**(): [`SCALE_MODE`](rendering.SCALE_MODE.html.md)

Specifies the sampling behavior when the sample footprint is smaller than or equal to one texel.

##### Returns

[`SCALE_MODE`](rendering.SCALE_MODE.html.md)

#### Set Signature

> **set** **magFilter**(`value`): `void`

##### Parameters

###### value

[`SCALE_MODE`](rendering.SCALE_MODE.html.md)

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`magFilter`](rendering.TextureSource.html#magfilter)

***

### maxAnisotropy

#### Get Signature

> **get** **maxAnisotropy**(): `number`

##### Returns

`number`

#### Set Signature

> **set** **maxAnisotropy**(`value`): `void`

Specifies the maximum anisotropy value clamp used by the sampler.

##### Parameters

###### value

`number`

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`maxAnisotropy`](rendering.TextureSource.html#maxanisotropy)

***

### minFilter

#### Get Signature

> **get** **minFilter**(): [`SCALE_MODE`](rendering.SCALE_MODE.html.md)

Specifies the sampling behavior when the sample footprint is larger than one texel.

##### Returns

[`SCALE_MODE`](rendering.SCALE_MODE.html.md)

#### Set Signature

> **set** **minFilter**(`value`): `void`

##### Parameters

###### value

[`SCALE_MODE`](rendering.SCALE_MODE.html.md)

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`minFilter`](rendering.TextureSource.html#minfilter)

***

### mipmapFilter

#### Get Signature

> **get** **mipmapFilter**(): [`SCALE_MODE`](rendering.SCALE_MODE.html.md)

Specifies behavior for sampling between mipmap levels.

##### Returns

[`SCALE_MODE`](rendering.SCALE_MODE.html.md)

#### Set Signature

> **set** **mipmapFilter**(`value`): `void`

##### Parameters

###### value

[`SCALE_MODE`](rendering.SCALE_MODE.html.md)

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`mipmapFilter`](rendering.TextureSource.html#mipmapfilter)

***

### repeatMode

#### Get Signature

> **get** **repeatMode**(): [`WRAP_MODE`](rendering.WRAP_MODE.html.md)

setting this will set wrapModeU, wrapModeV and wrapModeW all at once!

##### Returns

[`WRAP_MODE`](rendering.WRAP_MODE.html.md)

#### Set Signature

> **set** **repeatMode**(`value`): `void`

##### Parameters

###### value

[`WRAP_MODE`](rendering.WRAP_MODE.html.md)

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`repeatMode`](rendering.TextureSource.html#repeatmode)

***

### resolution

#### Get Signature

> **get** **resolution**(): `number`

the resolution of the texture. Changing this number, will not change the number of pixels in the actual texture
but will the size of the texture when rendered.

changing the resolution of this texture to 2 for example will make it appear twice as small when rendered (as pixel
density will have increased)

##### Returns

`number`

#### Set Signature

> **set** **resolution**(`resolution`): `void`

##### Parameters

###### resolution

`number`

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`resolution`](rendering.TextureSource.html#resolution)

***

### resourceHeight

#### Get Signature

> **get** **resourceHeight**(): `number`

the height of the resource. This is the REAL pure number, not accounting resolution

##### Returns

`number`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`resourceHeight`](rendering.TextureSource.html#resourceheight)

***

### resourceWidth

#### Get Signature

> **get** **resourceWidth**(): `number`

the width of the resource. This is the REAL pure number, not accounting resolution

##### Returns

`number`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`resourceWidth`](rendering.TextureSource.html#resourcewidth)

***

### scaleMode

#### Get Signature

> **get** **scaleMode**(): [`SCALE_MODE`](rendering.SCALE_MODE.html.md)

setting this will set magFilter,minFilter and mipmapFilter all at once!

##### Returns

[`SCALE_MODE`](rendering.SCALE_MODE.html.md)

#### Set Signature

> **set** **scaleMode**(`value`): `void`

##### Parameters

###### value

[`SCALE_MODE`](rendering.SCALE_MODE.html.md)

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`scaleMode`](rendering.TextureSource.html#scalemode)

***

### source

#### Get Signature

> **get** **source**(): [`TextureSource`](rendering.TextureSource.html.md)

returns itself

##### Returns

[`TextureSource`](rendering.TextureSource.html.md)

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`source`](rendering.TextureSource.html#source)

***

### style

#### Get Signature

> **get** **style**(): [`TextureStyle`](rendering.TextureStyle.html.md)

the style of the texture

##### Returns

[`TextureStyle`](rendering.TextureStyle.html.md)

#### Set Signature

> **set** **style**(`value`): `void`

##### Parameters

###### value

[`TextureStyle`](rendering.TextureStyle.html.md)

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`style`](rendering.TextureSource.html#style)

***

### updateFPS

#### Get Signature

> **get** **updateFPS**(): `number`

How many times a second to update the texture from the video.
Leave at 0 to update at every render.
A lower fps can help performance, as updating the texture at 60fps on a 30ps video may not be efficient.

##### Returns

`number`

#### Set Signature

> **set** **updateFPS**(`value`): `void`

##### Parameters

###### value

`number`

##### Returns

`void`

***

### wrapMode

#### Get Signature

> **get** **wrapMode**(): [`WRAP_MODE`](rendering.WRAP_MODE.html.md)

##### Returns

[`WRAP_MODE`](rendering.WRAP_MODE.html.md)

#### Set Signature

> **set** **wrapMode**(`value`): `void`

##### Parameters

###### value

[`WRAP_MODE`](rendering.WRAP_MODE.html.md)

##### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`wrapMode`](rendering.TextureSource.html#wrapmode)

## Methods

### destroy()

> **destroy**(): `void`

Cleans up resources and event listeners associated with this texture.

#### Returns

`void`

#### Overrides

[`TextureSource`](rendering.TextureSource.html.md).[`destroy`](rendering.TextureSource.html#destroy)

***

### load()

> **load**(): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`VideoSource`\>

Start preloading the video resource.

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`VideoSource`\>

Handle the validate event

***

### resize()

> **resize**(`width?`, `height?`, `resolution?`): `boolean`

Resize the texture, this is handy if you want to use the texture as a render texture

#### Parameters

##### width?

`number`

the new width of the texture

##### height?

`number`

the new height of the texture

##### resolution?

`number`

the new resolution of the texture

#### Returns

`boolean`

- if the texture was resized

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`resize`](rendering.TextureSource.html#resize)

***

### unload()

> **unload**(): `void`

This will unload the Texture source from the GPU. This will free up the GPU memory
As soon as it is required fore rendering, it will be re-uploaded.

#### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`unload`](rendering.TextureSource.html#unload)

***

### update()

> **update**(): `void`

call this if you have modified the texture outside of the constructor

#### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`update`](rendering.TextureSource.html#update)

***

### updateMipmaps()

> **updateMipmaps**(): `void`

Lets the renderer know that this texture has been updated and its mipmaps should be re-generated.
This is only important for RenderTexture instances, as standard Texture instances will have their
mipmaps generated on upload. You should call this method after you make any change to the texture

The reason for this is is can be quite expensive to update mipmaps for a texture. So by default,
We want you, the developer to specify when this action should happen.

Generally you don't want to have mipmaps generated on Render targets that are changed every frame,

#### Returns

`void`

#### Inherited from

[`TextureSource`](rendering.TextureSource.html.md).[`updateMipmaps`](rendering.TextureSource.html#updatemipmaps)

***

### test()

> `static` **test**(`resource`): `resource is HTMLVideoElement`

#### Parameters

##### resource

`any`

#### Returns

`resource is HTMLVideoElement`

#### Overrides

[`TextureSource`](rendering.TextureSource.html.md).[`test`](rendering.TextureSource.html#test)
