Skip to content

Play GIF, animated WebP and SVG, with an optional loop count - #55

Merged
514sid merged 1 commit into
mainfrom
animated-images
Nov 24, 2026
Merged

514sid merged 1 commit into
mainfrom
animated-images

Conversation

@514sid

@514sid 514sid commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Only Coil's core decoders were included, so a GIF or animated WebP showed its first frame and an SVG failed to load. The library now depends on coil-gif and coil-svg. Both register through Coil's service loader, so they also work with an app's own ImageLoader. Animated WebP needs Android 9 or newer.

A preloaded animation would start playing while hidden, and be part way through or already done by its cut. Each image slot now holds its animation until it is on screen, then starts it from the first frame.

GaplessAsset.animationLoops: null, the default, loops until the next play(). A count plays it that many times, holds the last frame and emits Completed, as a video does at its end. Stopping an animation also reports an end, so only one that runs out while on screen counts. Zero or negative counts are rejected.

The sample app gets image_animated_gif, the same GIF as image_animated_gif_3_loops, image_animated_webp and image_svg, in an animated playlist. The animations number their frames so a restart is visible.

Checked on both TVs: a screen recording showed every cut to an animation starting at frame 1, after a video and after a still. The 3-loop GIF reported Completed 3.6 s after starting and held on its last frame, the looping GIF never reported, and the SVG rendered.

Adds coil-gif and coil-svg. An animation is held while staged and starts
from its first frame when it comes on screen. GaplessAsset.animationLoops
plays it that many times, holds the last frame and emits Completed. The
sample app gets an animated GIF and WebP that number their frames, an SVG,
and an animated playlist.
@514sid
514sid merged commit 3152f5d into main Nov 24, 2026
1 check passed
@514sid
514sid deleted the animated-images branch November 24, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant