AudioPlaybackCaptureConfiguration.Builder


public static final class AudioPlaybackCaptureConfiguration.Builder
extends Object

java.lang.Object
   ↳ android.media.AudioPlaybackCaptureConfiguration.Builder


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

Public constructors

Builder

Added in API level 29
public Builder (MediaProjection projection)

Parameters
projection MediaProjection: A MediaProjection that supports audio projection. This value cannot be null.

Public methods

addMatchingUid

Added in API level 29
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

Added in API level 29
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

Added in API level 29
public AudioPlaybackCaptureConfiguration build ()

Builds the configuration instance.

Returns
AudioPlaybackCaptureConfiguration This value cannot be null.

Throws
UnsupportedOperationException if the parameters set are incompatible.

excludeUid

Added in API level 29
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

Added in API level 29
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).