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.
Description
Section titled “Description”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.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
AnimatedResourceDecoder | create(Asset asset, IResourceAnimationReader reader) factory | Creates a decoder that reads asset with reader. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| loop | boolean | the loop count stored in the file | If true, the animation plays forever; if false, once. |
| autoplay | boolean | true | If true, the animation starts once it is uploaded. |
Methods
Section titled “Methods”Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
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. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
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. |
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. |
Inherited from IResourceDecoder (2)
Inherited from IResourcePlayback (1)
Creation details
Section titled “Creation details”create
Section titled “create”AnimatedResourceDecoder create(Asset asset, IResourceAnimationReader reader) factory
Creates a decoder that reads asset with reader.
Property details
Section titled “Property details”this loop(boolean loop)fluentboolean 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.
autoplay
Section titled “autoplay”this autoplay(boolean autoplay)fluentboolean isAutoplay()
Default: true
If true, the animation starts once it is uploaded.
Method details
Section titled “Method details”isPlaying
Section titled “isPlaying”boolean isPlaying()
If true, the animation is running and not paused.
getDuration
Section titled “getDuration”double getDuration()
Returns the length of one play, in seconds, 0D before the decode.
getProgress
Section titled “getProgress”double getProgress()
Returns the time within the current play, on 1 of the duration.
getCurrentTime
Section titled “getCurrentTime”double getCurrentTime()
Returns the time within the current play, in seconds.
getAsset
Section titled “getAsset”Asset getAsset()
Returns the animated file.
isPaused
Section titled “isPaused”boolean isPaused()
If true, the animation is paused.
prepare
Section titled “prepare”void prepare(ResourceData resource)
Gives the data a transparent placeholder texture until the first frame is uploaded.
decode
Section titled “decode”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.
upload
Section titled “upload”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
