AnimatedImage

Render animated GIFs, “stickers”, and small videos

Extends Group

The AnimatedImage node enables developers to render animated GIFs, stickers, and small videos. It is designed for low-frame-rate, simple animations that reside in a small area.

Only use a single, small animated image at a time to minimize CPU load and memory usage (large animations may consume CPU and memory resources; using too many animated images may cause choppy animations).

The AnimatedImage downloads the entire resource before decoding. Playback begins only after the download hasbeen completed.

This node is not supported on older Roku device models (Liberty, Littlefield, Austin, Briscoe, Ft. Worth, Gilbert, Amarillo).

Example

BrightScript

' main.brs
function init()
    m.top.setFocus(true)
    m.group = m.top.findNode("group")
    poster = CreateObject("roSGNode", "AnimatedImage")
    poster.uri = "pkg:/images/transform_demo.json"
    poster.mimeType = "video/lottie+json" ' optional hint
    poster.width = 200
    poster.height = 200
    poster.control = "loop"
    m.group.appendChild(poster)
end function

XML

<?xml version="1.0" encoding="utf-8" ?>
<component name="HelloWorld" extends="Scene">
<children>
<group id="group" />
</children>
<!-- BrightScript Portion -->
<script type="text/brightscript" uri="main.brs">
</script>
<!-- End of BrightScript Portion -->
</component>

Fields

FieldTypeDefaultAccess PermissionDescription
widthfloat0.0fREAD_WRITEDisplay width in pixels.
heightfloat0.0fREAD_WRITEDisplay height in pixels.
loadWidthfloat0.0fREAD_WRITEWidth for decoding animation (default is the original dimensions).
loadHeightfloat0.0fREAD_WRITEHeight for decoding animation (default is original dimensions).
loadDisplayModestringscaleToFitREAD_WRITEThe scaling behavior to be used. Select one of the following:
- scaleToFit: Scale preserving aspect ratio. Fit within bounds.
- scaleToZoom: Scale preserving aspect ratio. Fill entire bounds (crop overflow).
- scaleToFill: Fill node. Does not preserve aspect ratio.
- noScale: Fill node. Does not preserve aspect ratio.
- limitSize: Only scale down, if needed. Does not scale up.
uristring-READ_WRITEPath/URL to animated image.
mimeTypestring-READ_WRITEOptional MIME type hint, which may be one of the following values:

- video/mp4: vp9 encoded video in mp4 video container
- video/webp: animated WebP
-video/lottie+json: json Lottie or compressed dotLottie
controlstring-READ_WRITEIf not provided the system will attempt to automatically detect the file type. Playback control. loop pause play rewind
statestringstopREAD_WRITECurrent playback state (read-only). This may be one of the following values:
- downloading
- init
- first
- decode
- stop
- error
errorstring-READ_ONLYError message if failed.
mediaWidthint0READ_ONLYDecoded image width.
mediaHeightint0READ_ONLYDecoded image height.

Did this page help you?