Kodio 0.1.1 Help

Playback

Kodio provides flexible audio playback APIs, from a simple one-liner to a full-featured Player class with pause, resume, and device selection.

Simple playback

The easiest way to play audio is directly on a recording. This suspends until playback completes:

recording.play()

Playback with controls

When you need to pause, resume, or monitor playback, use Kodio.play() with a lambda:

Kodio.play(recording) { player -> player.start() // Pause after 2 seconds delay(2.seconds) player.pause() // Resume after 1 second delay(1.seconds) player.resume() // Wait for playback to finish player.awaitComplete() }

The lambda receives a Player instance that gives you full control over playback.

Using Player directly

For maximum flexibility, create a Player instance directly. This is useful for:

  • Loading different recordings into the same player

  • Managing the player's lifecycle explicitly

  • Building custom playback UIs

val player = Kodio.player() player.use { p -> p.load(recording) p.start() p.awaitComplete() }

Output device selection

Play audio to a specific output device (headphones, speakers, etc.):

// List available output devices val outputs = Kodio.listOutputDevices() println(outputs.map { it.name }) // ["Built-in Speakers", "AirPods Pro", ...] // Play to a specific device val headphones = outputs.find { it.name.contains("AirPods") } Kodio.play(recording, device = headphones)

Player API reference

Properties

isPlaying: Boolean

true while audio is actively playing.

isPaused: Boolean

true if playback was started and then paused.

isReady: Boolean

true when audio is loaded and ready to play.

isFinished: Boolean

true after playback has completed.

stateFlow: StateFlow<State>

Observable state changes for reactive UIs.

Methods

load(recording)

Load an AudioRecording for playback.

start()

Begin or resume playback.

pause()

Pause playback. Use resume() to continue.

resume()

Continue playback after pausing.

stop()

Stop playback and reset to the beginning.

toggle()

Play if stopped/paused, pause if playing. Convenient for single-button UIs.

release()

Release all resources. Called automatically when using use {}.

awaitComplete()

Suspend until playback finishes.

Last modified: 13 January 2026