AudioTap

interface AudioTap

Sees every block of decoded audio on its way to the speaker.

For a level meter, a spectrum or a visualiser: anything that wants the sound the player is actually playing, with the time each block plays at. Attach one with KitePlayer.attachAudioTap.

The engine calls it on the audio feed worker, once per decoded block, after a seek has trimmed the block that straddles its target and before any conversion. So the samples are in the decoder's own rate and layout, and the time is on the media's own axis at any playback speed.

That worker also feeds the audio device. A tap that takes long starves the device and the sound breaks up, so copy what you need and return. A tap that throws is detached and reported as PlaybackWarning.AudioTapFailed, and playback carries on.

Functions

Link copied to clipboard
abstract fun onAudio(pts: Pts, interleaved: FloatArray, frames: Int, format: AudioFormat)

One block of decoded audio that plays at pts.

open fun onAudio(generation: Generation, pts: Pts, interleaved: FloatArray, frames: Int, format: AudioFormat)

A block with its continuous audio timeline identity, matching KitePlayer.audioClock.

Link copied to clipboard
open fun onDiscontinuity()

Whatever the tap holds is stale: the player sought, changed the audio track or opened a new audio path, and the next onAudio continues from somewhere else. It may arrive on another thread than onAudio.

open fun onDiscontinuity(generation: Generation)

Retires all deliveries before generation. May race with a callback still completing from a retired session; that callback retains its old generation. The default notifies legacy taps.