new PIXI.VideoBaseTexture(source, scaleMode)
A texture of a [playing] Video.
Video base textures mimic Pixi BaseTexture.from.... method in their creation process.
This can be used in several ways, such as:
var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4');
var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' });
var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']);
var texture = PIXI.VideoBaseTexture.fromUrls([
{ src: '/video.webm', mime: 'video/webm' },
{ src: '/video.mp4', mime: 'video/mp4' }
]);
See the "deus" demo.
Name | Type | Description |
---|---|---|
source |
HTMLVideoElement | |
scaleMode |
number |
optional
See PIXI.SCALE_MODES for possible values |
Extends
Members
-
autoUpdateboolean
-
Should the base texture automatically update itself, set to true by default
- Default Value:
- true
-
readonlyhasLoadedboolean
-
Set to true once the base texture has successfully loaded.
This is never true if the underlying source fails to load or has no texture data.
-
readonlyheightnumber
-
The height of the base texture set when the image has loaded
-
imageUrlstring
-
-
readonlyisLoadingboolean
-
Set to true if the source is currently loading.
If an Image source is loading the 'loaded' or 'error' event will be
dispatched when the operation ends. An underyling source that is
immediately-available bypasses loading entirely. -
mipmapboolean
-
Set this to true if a mipmap of this texture needs to be generated. This value needs to be set before the texture is used
Also the texture must be a power of two size to work -
premultipliedAlphaboolean
-
Controls if RGB channels should be pre-multiplied by Alpha (WebGL only)
All blend modes, and shaders written for default value. Change it on your own risk.- Default Value:
- true
-
readonlyrealHeightnumber
-
Used to store the actual height of the source of this texture
-
readonlyrealWidthnumber
-
Used to store the actual width of the source of this texture
-
resolutionnumber
-
The Resolution of the texture.
-
scaleModenumber
-
The scale mode to apply when scaling this texture
- Default Value:
- PIXI.SCALE_MODES.DEFAULT
- See:
-
readonlysourceImage Canvas
-
The image source that is used to create the texture.
TODO: Make this a setter that calls loadSource();
-
readonlywidthnumber
-
The width of the base texture set when the image has loaded
Methods
-
staticPIXI.VideoBaseTexture.fromUrl(videoSrc, scaleMode){PIXI.VideoBaseTexture}
-
Helper function that creates a new BaseTexture based on the given video element.
This BaseTexture can then be used to create a textureName Type Description videoSrc
string | object | Array.<string> | Array.<object> The URL(s) for the video.
Name Type Description src
string optional One of the source urls for the video
mime
string optional The mimetype of the video (e.g. 'video/mp4'). If not specified
the url's extension will be used as the second part of the mime type.scaleMode
number See PIXI.SCALE_MODES for possible values
Returns:
Type Description PIXI.VideoBaseTexture -
staticPIXI.VideoBaseTexture.fromVideo(video, scaleMode){PIXI.VideoBaseTexture}
-
Mimic Pixi BaseTexture.from.... method.
Name Type Description video
HTMLVideoElement scaleMode
number See PIXI.SCALE_MODES for possible values
Returns:
Type Description PIXI.VideoBaseTexture -
destroy()
-
Destroys this texture
-
inherited dispose()
-
Frees the texture from WebGL memory without destroying this texture object.
This means you can still use the texture later which will upload it to GPU
memory again. -
inherited protectedloadSource(source)
-
Load a source.
If the source is not-immediately-available, such as an image that needs to be
downloaded, then the 'loaded' or 'error' event will be dispatched in the future
andhasLoaded
will remain false after this call.The logic state after calling
loadSource
directly or indirectly (eg.fromImage
,new BaseTexture
) is:if (texture.hasLoaded)
{
// texture ready for use
} else if (texture.isLoading)
{
// listen to 'loaded' and/or 'error' events on texture
} else {
// not loading, not going to load UNLESS the source is reloaded
// (it may still make sense to listen to the events)
}Name Type Description source
Image | Canvas the source object of the texture.
-
inherited update()
-
Updates the texture on all the webgl renderers, this also assumes the src has changed.
Fires:
- event:update
-
inherited updateSourceImage(newSrc)
-
Changes the source image of the texture.
The original source must be an Image element.Name Type Description newSrc
string the path of the image