VideoRenderer

The VideoRenderer component renders video content to the screen. It supports scaling, rotation, flipping, opacity, color masking, tinting, slicing, looping, and volume control, and playback can be controlled programmatically. It uses the entity’s Transform for position. See Rendering for an overview.

Options

OptionTypeDefaultDescription
videoHTMLVideoElement | stringThe video to render, or an asset URL/name string.
layerstring"Default"The render layer.
widthnumberOverrides the rendered width.
heightnumberOverrides the rendered height.
sliceSliceRegion of the video to draw ({ x, y, width, height }).
offsetVector2(0, 0)Offset from the entity’s position.
rotationnumber0Rotation in radians.
flipHorizontallybooleanFlips the video horizontally.
flipVerticallybooleanFlips the video vertically.
opacitynumberOpacity between 0 and 1.
tintColorstringColor used to tint the video.
maskColorstringMask color applied to the video.
maskColorMixnumberMask color opacity between 0 and 1.
volumenumber1Volume between 0 and 1.
loopbooleanfalseWhether the video repeats.
fixedToTimeScalebooleanfalseWhether the playback rate follows the time scale.

Read-only properties

PropertyTypeDescription
playingbooleantrue while the video is playing.

Methods

MethodDescription
play(video?)Plays the video. An optional video overrides video.
pause()Pauses playback.
stop()Stops playback.

Example

import { Transform, VideoRenderer } from "angry-pixel";

this.entityManager.createEntity([
    new Transform(),
    new VideoRenderer({
        video: this.assetManager.getVideo("intro.mp4"),
        width: 1920,
        height: 1080,
        layer: "Default",
    }),
]);

The video is loaded through the asset manager, typically in the scene’s loadAssets method.