MusicTrackController

class MusicTrackController(volume: Float)

Wraps one Gdx Music instance and manages threaded loading, playback, fading and cleanup

Constructors

MusicTrackController
Link copied to clipboard
fun MusicTrackController(volume: Float)

Types

State
Link copied to clipboard
enum State(canPlay: Boolean) : Enum<MusicTrackController.State>

Internal state of this Music track

Functions

clear
Link copied to clipboard
fun clear()

Clean up and dispose resources

clearLoader
Link copied to clipboard
private fun clearLoader()
clearMusic
Link copied to clipboard
private fun clearMusic()
equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
fadeInStep
Link copied to clipboard
private fun fadeInStep()
fadeOutStep
Link copied to clipboard
private fun fadeOutStep()
hashCode
Link copied to clipboard
open fun hashCode(): Int
isPlaying
Link copied to clipboard
fun isPlaying(): Boolean
load
Link copied to clipboard
fun load(file: FileHandle, onError: (MusicTrackController) -> Unit? = null, onSuccess: (MusicTrackController) -> Unit? = null)

Loads file into this controller's music and optionally calls onSuccess when done. Failures are silently logged to console, and onError is called. Callbacks run on the background thread.

play
Link copied to clipboard
fun play(): Boolean

Calls play() on the wrapped Gdx Music, catching exceptions to console.

setVolume
Link copied to clipboard
fun setVolume(newVolume: Float)

Adjust master volume without affecting a fade-in/out

shutdownTick
Link copied to clipboard
fun shutdownTick(): Boolean

Graceful shutdown tick event - fade out then report Idle

startFade
Link copied to clipboard
fun startFade(fade: MusicTrackController.State, step: Float = 0f)

Starts fadeIn or fadeOut.

timerTick
Link copied to clipboard
fun timerTick(): MusicTrackController.State

Called by the MusicController in its timer "tick" event handler, implements fading

toString
Link copied to clipboard
open fun toString(): String
tryPlay
Link copied to clipboard
private fun tryPlay(music: Music): Boolean

Properties

fadeStep
Link copied to clipboard
private var fadeStep: Float
fadeVolume
Link copied to clipboard
private var fadeVolume: Float = 1f
loaderThread
Link copied to clipboard
private var loaderThread: Thread? = null
music
Link copied to clipboard
var music: Music? = null
state
Link copied to clipboard
var state: MusicTrackController.State
volume
Link copied to clipboard
private var volume: Float

Sources

jvm source
Link copied to clipboard