Stay organized with collections Save and categorize content based on your preferences.

public static final class AudioPlaybackCaptureConfiguration.Builder
extends Object



Builder for creating AudioPlaybackCaptureConfiguration instances.

Summary

Public constructors

Builder(MediaProjection projection)

Public methods

AudioPlaybackCaptureConfiguration.Builder addMatchingUid(int uid)

Only capture audio output by app with the matching uid.

AudioPlaybackCaptureConfiguration.Builder addMatchingUsage(int usage)

Only capture audio output with the given AudioAttributes.

AudioPlaybackCaptureConfiguration build()

Builds the configuration instance.

AudioPlaybackCaptureConfiguration.Builder excludeUid(int uid)

Only capture audio output by apps that do not have the matching uid.

AudioPlaybackCaptureConfiguration.Builder excludeUsage(int usage)

Only capture audio output that does not match the given AudioAttributes.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(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 wait(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 wait()

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

Public constructors

Builder

public Builder (MediaProjection projection)
Parameters
projection MediaProjection: A MediaProjection that supports audio projection. This value cannot be null.

Public methods

addMatchingUid

public AudioPlaybackCaptureConfiguration.Builder addMatchingUid (int uid)

Only capture audio output by app with the matching uid.

If called multiple times, will capture audio output by apps whose uid is any of the given uids.

Parameters
uid int
Returns
AudioPlaybackCaptureConfiguration.Builder This value cannot be null.
Throws
IllegalStateException if called in conjunction with excludeUid(int).

addMatchingUsage

public AudioPlaybackCaptureConfiguration.Builder addMatchingUsage (int usage)

Only capture audio output with the given AudioAttributes.

If called multiple times, will capture audio output that matches any of the given attributes.

Parameters
usage int: Value is AudioAttributes.USAGE_UNKNOWN, AudioAttributes.USAGE_MEDIA, AudioAttributes.USAGE_VOICE_COMMUNICATION, AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING, AudioAttributes.USAGE_ALARM, AudioAttributes.USAGE_NOTIFICATION, AudioAttributes.USAGE_NOTIFICATION_RINGTONE, AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST, AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT, AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_DELAYED, AudioAttributes.USAGE_NOTIFICATION_EVENT, AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY, AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE, AudioAttributes.USAGE_ASSISTANCE_SONIFICATION, AudioAttributes.USAGE_GAME, AudioAttributes.USAGE_ASSISTANT, android.media.AudioAttributes.USAGE_CALL_ASSISTANT, android.media.AudioAttributes.USAGE_EMERGENCY, android.media.AudioAttributes.USAGE_SAFETY, android.media.AudioAttributes.USAGE_VEHICLE_STATUS, or android.media.AudioAttributes.USAGE_ANNOUNCEMENT
Returns
AudioPlaybackCaptureConfiguration.Builder This value cannot be null.
Throws
IllegalStateException if called in conjunction with excludeUsage(int).

build

public AudioPlaybackCaptureConfiguration build ()

Builds the configuration instance.

Returns
AudioPlaybackCaptureConfiguration This value cannot be null.
Throws
UnsupportedOperationException if the parameters set are incompatible.

excludeUid

public AudioPlaybackCaptureConfiguration.Builder excludeUid (int uid)

Only capture audio output by apps that do not have the matching uid.

If called multiple times, will capture audio output by apps whose uid is not any of the given uids.

Parameters
uid int
Returns
AudioPlaybackCaptureConfiguration.Builder This value cannot be null.
Throws
IllegalStateException if called in conjunction with addMatchingUid(int).

excludeUsage

public AudioPlaybackCaptureConfiguration.Builder excludeUsage (int usage)

Only capture audio output that does not match the given AudioAttributes.

If called multiple times, will capture audio output that does not match any of the given attributes.

Parameters
usage int: Value is AudioAttributes.USAGE_UNKNOWN, AudioAttributes.USAGE_MEDIA, AudioAttributes.USAGE_VOICE_COMMUNICATION, AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING, AudioAttributes.USAGE_ALARM, AudioAttributes.USAGE_NOTIFICATION, AudioAttributes.USAGE_NOTIFICATION_RINGTONE, AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST, AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT, AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_DELAYED, AudioAttributes.USAGE_NOTIFICATION_EVENT, AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY, AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE, AudioAttributes.USAGE_ASSISTANCE_SONIFICATION, AudioAttributes.USAGE_GAME, AudioAttributes.USAGE_ASSISTANT, android.media.AudioAttributes.USAGE_CALL_ASSISTANT, android.media.AudioAttributes.USAGE_EMERGENCY, android.media.AudioAttributes.USAGE_SAFETY, android.media.AudioAttributes.USAGE_VEHICLE_STATUS, or android.media.AudioAttributes.USAGE_ANNOUNCEMENT
Returns
AudioPlaybackCaptureConfiguration.Builder This value cannot be null.
Throws
IllegalStateException if called in conjunction with addMatchingUsage(int).

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2023-02-08 UTC.