-
- All Implemented Interfaces:
-
app.rive.AssetOps
public class AudioAsset.Companion implements AssetOps<AudioHandle, AudioAsset>
-
-
Method Summary
Modifier and Type Method Description final AudioAssetcreate(CommandQueue riveWorker, ByteArray bytes)Creates and decodes an audio asset from the given byte array on the provided Rive worker. final Result<AudioAsset>fromBytes(CommandQueue riveWorker, ByteArray bytes)Decodes an audio asset from bytes. AudioHandledecode(CommandQueue worker, ByteArray bytes)Decode the asset from the given byte array on the provided Rive worker. Unitdelete(CommandQueue worker, AudioHandle handle)Delete the asset from the provided Rive worker. Unitregister(CommandQueue worker, String key, AudioHandle handle)Register the asset with the provided Rive worker under the given key. Unitunregister(CommandQueue worker, String key)Unregister the asset from the provided Rive worker for the given key. AudioAssetconstruct(AudioHandle handle, CommandQueue worker)Construct the asset by taking ownership of the worker reference acquired by the factory. StringgetTag()The tag used for logging purposes. StringgetLabel()A label for the asset type, used in logging. -
-
Method Detail
-
create
final AudioAsset create(CommandQueue riveWorker, ByteArray bytes)
Creates and decodes an audio asset from the given byte array on the provided Rive worker.
The audio can only be used on the same RiveWorker it was created on.
Must be registered with AudioAsset.register to be used for referenced audio. Remove every registration with AudioAsset.unregister, preferably before closing the audio.
⚠️ The lifetime of the returned audio is managed by the caller. Make sure to call close when you are done with it to release its resources. The returned audio holds a reference to riveWorker, so closing it is required before the worker can fully release memory associated with this audio.
This is the replacement for fromBytes. Its temporary name avoids a source-incompatible overload; it will be renamed to
fromBytesin 12.0 when the result-returning API is removed.- Parameters:
riveWorker- The Rive worker that owns the audio.bytes- The byte array containing the audio data to decode.
-
fromBytes
@Deprecated(message = Use create. This result-returning implementation will be removed in 12.0, when create will be renamed to fromBytes and return the audio directly.) final Result<AudioAsset> fromBytes(CommandQueue riveWorker, ByteArray bytes)
Decodes an audio asset from bytes.
- Parameters:
riveWorker- The Rive worker that owns the audio.bytes- The encoded audio bytes.
-
decode
AudioHandle decode(CommandQueue worker, ByteArray bytes)
Decode the asset from the given byte array on the provided Rive worker.
-
delete
Unit delete(CommandQueue worker, AudioHandle handle)
Delete the asset from the provided Rive worker.
-
register
Unit register(CommandQueue worker, String key, AudioHandle handle)
Register the asset with the provided Rive worker under the given key.
-
unregister
Unit unregister(CommandQueue worker, String key)
Unregister the asset from the provided Rive worker for the given key.
-
construct
AudioAsset construct(AudioHandle handle, CommandQueue worker)
Construct the asset by taking ownership of the worker reference acquired by the factory.
-
-
-
-