AudioPlayerController

class AudioPlayerController : Closeable

A handle that is used to control audio playback,including playing, pausing, resuming, stopping an audio, and checking the playback status of an audio.

Properties

Link copied to clipboard

The entity that the audio is playing on.

Link copied to clipboard
@get:JvmName(name = "isValid")
val valid: Boolean

The controller is valid.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
fun fade(targetVolume: Float = 1.0f, duration: Long, fadeMode: AudioInterpolatorType = AudioInterpolatorType.CUBIC): Boolean

Fade the audio to the specified volume over a specified duration.

Link copied to clipboard
fun getCurrentPosition(): Long

Gets the current playback position of the audio file in milliseconds.

Link copied to clipboard
fun getDuration(): Long

Gets the total duration of the audio file in milliseconds.

Link copied to clipboard
fun getPlaybackSpeed(): Float

Gets the current playback speed for the audio.

Link copied to clipboard
fun getVolume(): Float

Gets the playback volume.

Link copied to clipboard
fun isCompleted(): Boolean

Checks if an audio is finished playing or not.

Link copied to clipboard
fun isPlaying(): Boolean

Checks if an audio is playing or not.

Link copied to clipboard
fun pause(): Boolean

Pauses an audio that is playing.

Link copied to clipboard
fun play(): Boolean

Plays an audio.

Link copied to clipboard
fun resume(): Boolean

Resumes an paused audio.

Link copied to clipboard
fun seekTo(position: Long): Boolean

Seeks to the specified playback position in the current audio.

Link copied to clipboard
fun setLoop(loop: Boolean): Boolean

Enables or disables looping for audio playback.

Link copied to clipboard
fun setPlaybackSpeed(rate: Float): Boolean

Sets the playback speed for the audio.

Link copied to clipboard
fun setVolume(@FloatRange(from = 0.0, to = 1.0) volume: Float = 1.0f): Boolean

Set the playback volume.

Link copied to clipboard
fun stop(): Boolean

Stops an audio.