Skip to content

AnimatedResourceDecoder

final class AnimatedResourceDecoder
Implements: IResourceDecoder, IResourcePlayback
Package: dev.joid.lib.resource.decoder.impl · Module: core · Source: AnimatedResourceDecoder.java

Plays an animated image, GIF, APNG, animated WebP or a format of yours, by uploading the frame of the current time.

The formats pick it with the IResourceAnimationReader of the file; give it your own reader for another animated format. The frames are decoded once, in memory, and shared by every fork of the same file; each fork has its own playback. The time follows the JOID clock, so the animation keeps its pace whatever the frame rate.

ReturnsSignatureSummary
AnimatedResourceDecodercreate(Asset asset, IResourceAnimationReader reader) factoryCreates a decoder that reads asset with reader.

PropertyTypeDefaultSummary
loopbooleanthe loop count stored in the fileIf true, the animation plays forever; if false, once.
autoplaybooleantrueIf true, the animation starts once it is uploaded.

ReturnsSignatureSummary
booleanisPlaying()If true, the animation is running and not paused.
doublegetDuration()Returns the length of one play, in seconds, 0D before the decode.
doublegetProgress()Returns the time within the current play, on 1 of the duration.
doublegetCurrentTime()Returns the time within the current play, in seconds.
AssetgetAsset()Returns the animated file.
booleanisPaused()If true, the animation is paused.
ReturnsSignatureSummary
voidprepare(ResourceData resource)Gives the data a transparent placeholder texture until the first frame is uploaded.
voiddecode(ResourceData resource)Reads every frame, once for the file and its forks, and sets the size and the first frame of the data.
voidupload(ResourceData resource)Uploads the first frame and starts the playback when autoplay is true.
voidclear(ResourceData resource)Stops the playback and drops the frames.
AnimatedResourceDecoderfork()Returns a decoder that shares the frames of this file and plays on its own.
thisplay() fluentStarts the animation, or resumes it after pause(); after stop(), it starts from the start, or from the time of a seek made while stopped.
thisstop() fluentStops the animation on its current frame; the next play() starts from the start unless a seek comes first.
thispause() fluentPauses the animation on its current frame.
thisseek(double seconds) fluentMoves to seconds from the start, clamped to the length of one play; while stopped, the next play() starts there.
Inherited from IResourceDecoder (2)

isSettled · isMipmappable

Inherited from IResourcePlayback (1)

restart

AnimatedResourceDecoder create(Asset asset, IResourceAnimationReader reader) factory

Creates a decoder that reads asset with reader.

  • this loop(boolean loop) fluent
  • boolean isLoop()

Default: the loop count stored in the file

If true, the animation plays forever; if false, once. Without a call, the loop count stored in the file applies.

  • this autoplay(boolean autoplay) fluent
  • boolean isAutoplay()

Default: true

If true, the animation starts once it is uploaded.

boolean isPlaying()

If true, the animation is running and not paused.

double getDuration()

Returns the length of one play, in seconds, 0D before the decode.

double getProgress()

Returns the time within the current play, on 1 of the duration.

double getCurrentTime()

Returns the time within the current play, in seconds.

Asset getAsset()

Returns the animated file.

boolean isPaused()

If true, the animation is paused.

void prepare(ResourceData resource)

Gives the data a transparent placeholder texture until the first frame is uploaded.

void decode(ResourceData resource)

Reads every frame, once for the file and its forks, and sets the size and the first frame of the data. Throws UncheckedIOException when the file cannot be read.

void upload(ResourceData resource)

Uploads the first frame and starts the playback when autoplay is true.

void clear(ResourceData resource)

Stops the playback and drops the frames.

AnimatedResourceDecoder fork()

Returns a decoder that shares the frames of this file and plays on its own.

this play() fluent

Starts the animation, or resumes it after pause(); after stop(), it starts from the start, or from the time of a seek made while stopped.

this stop() fluent

Stops the animation on its current frame; the next play() starts from the start unless a seek comes first.

this pause() fluent

Pauses the animation on its current frame.

this seek(double seconds) fluent

Moves to seconds from the start, clamped to the length of one play; while stopped, the next play() starts there.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page