Added in API level 29

StreamEventCallback


abstract class StreamEventCallback
kotlin.Any
   ↳ android.media.AudioTrack.StreamEventCallback

Abstract class to receive event notifications about the stream playback in offloaded mode. See AudioTrack#registerStreamEventCallback(Executor, StreamEventCallback) to register the callback on the given AudioTrack instance.

Summary

Public constructors

Public methods
open Unit
onDataRequest(track: AudioTrack, sizeInFrames: Int)

Called when more audio data can be written without blocking on an offloaded track.

open Unit

Called when all the buffers of an offloaded track that were queued in the audio system (e.g. the combination of the Android audio framework and the device's audio hardware) have been played after

open Unit

Called when an offloaded track is no longer valid and has been discarded by the system.

Public constructors

StreamEventCallback

StreamEventCallback()

Public methods

onDataRequest

Added in API level 29
open fun onDataRequest(
    track: AudioTrack,
    sizeInFrames: Int
): Unit

Called when more audio data can be written without blocking on an offloaded track.

Parameters
track AudioTrack: the AudioTrack on which the event happened. This value cannot be null.
sizeInFrames Int: the number of frames available to write without blocking. Note that the frame size of a compressed stream is 1 byte. Value is 0 or greater

onPresentationEnded

Added in API level 29
open fun onPresentationEnded(track: AudioTrack): Unit

Called when all the buffers of an offloaded track that were queued in the audio system (e.g. the combination of the Android audio framework and the device's audio hardware) have been played after AudioTrack#stop() has been called.

Parameters
track AudioTrack: the AudioTrack on which the event happened. This value cannot be null.

onTearDown

Added in API level 29
open fun onTearDown(track: AudioTrack): Unit

Called when an offloaded track is no longer valid and has been discarded by the system. An example of this happening is when an offloaded track has been paused too long, and gets invalidated by the system to prevent any other offload.

Parameters
track AudioTrack: the AudioTrack on which the event happened. This value cannot be null.