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 | string—The video to render, or an asset URL/name string.
layerstring"Default"The render layer.
widthnumber—Overrides the rendered width.
heightnumber—Overrides the rendered height.
sliceSlice—Region of the video to draw ({ x, y, width, height }).
offsetVector2(0, 0)Offset from the entity’s position.
rotationnumber0Rotation in radians.
flipHorizontallyboolean—Flips the video horizontally.
flipVerticallyboolean—Flips the video vertically.
opacitynumber—Opacity between 0 and 1.
tintColorstring—Color used to tint the video.
maskColorstring—Mask color applied to the video.
maskColorMixnumber—Mask 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.