Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/media/AudioTrack.StreamEventCallback#pubctors) \| [Methods](https://developer.android.com/reference/android/media/AudioTrack.StreamEventCallback#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/AudioTrack.StreamEventCallback#inhmethods)

# AudioTrack.StreamEventCallback

*** ** * ** ***

` public static abstract class AudioTrack.StreamEventCallback `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.AudioTrack.StreamEventCallback |

<br />

*** ** * ** ***

Abstract class to receive event notifications about the stream playback in offloaded mode. See `https://developer.android.com/reference/android/media/AudioTrack#registerStreamEventCallback(java.util.concurrent.Executor,%20android.media.AudioTrack.StreamEventCallback)` to register the callback on the given `https://developer.android.com/reference/android/media/AudioTrack` instance.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/media/AudioTrack.StreamEventCallback#StreamEventCallback()() ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/media/AudioTrack.StreamEventCallback#onDataRequest(android.media.AudioTrack,%20int)(https://developer.android.com/reference/android/media/AudioTrack track, int sizeInFrames) ` Called when more audio data can be written without blocking on an offloaded track. |
| ` void` | ` https://developer.android.com/reference/android/media/AudioTrack.StreamEventCallback#onPresentationEnded(android.media.AudioTrack)(https://developer.android.com/reference/android/media/AudioTrack track) ` 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 `https://developer.android.com/reference/android/media/AudioTrack#stop()` has been called. |
| ` void` | ` https://developer.android.com/reference/android/media/AudioTrack.StreamEventCallback#onTearDown(android.media.AudioTrack)(https://developer.android.com/reference/android/media/AudioTrack track) ` Called when an offloaded track is no longer valid and has been discarded by the system. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### StreamEventCallback

```
public StreamEventCallback ()
```

<br />

<br />

## Public methods

### onDataRequest

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onDataRequest (AudioTrack track, 
                int sizeInFrames)
```

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

<br />

| Parameters ||
|---|---|
| `track` | `AudioTrack`: the `https://developer.android.com/reference/android/media/AudioTrack` on which the event happened. This value cannot be `null`. <br /> |
| `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 <br /> |

### onPresentationEnded

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPresentationEnded (AudioTrack track)
```

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 `https://developer.android.com/reference/android/media/AudioTrack#stop()` has been called.

<br />

| Parameters ||
|---|---|
| `track` | `AudioTrack`: the `https://developer.android.com/reference/android/media/AudioTrack` on which the event happened. This value cannot be `null`. <br /> |

### onTearDown

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTearDown (AudioTrack track)
```

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.

<br />

| Parameters ||
|---|---|
| `track` | `AudioTrack`: the `https://developer.android.com/reference/android/media/AudioTrack` on which the event happened. This value cannot be `null`. <br /> |