AudioPlaybackCaptureConfiguration


public final class AudioPlaybackCaptureConfiguration
extends Object

java.lang.Object
   ↳ android.media.AudioPlaybackCaptureConfiguration


Configuration for capturing audio played by other apps. When capturing audio signals played by other apps (and yours), you will only capture a mix of the audio signals played by players (such as AudioTrack or MediaPlayer) which present the following characteristics:

An example for creating a capture configuration for capturing all media playback:

     MediaProjection mediaProjection;
     // Retrieve a audio capable projection from the MediaProjectionManager
     AudioPlaybackCaptureConfiguration config =
         new AudioPlaybackCaptureConfiguration.Builder(mediaProjection)
         .addMatchingUsage(AudioAttributes.USAGE_MEDIA)
         .build();
     AudioRecord record = new AudioRecord.Builder()
         .setAudioPlaybackCaptureConfig(config)
         .build();
 

Summary

Nested classes

class AudioPlaybackCaptureConfiguration.Builder

Builder for creating AudioPlaybackCaptureConfiguration instances. 

Public methods

int[] getExcludeUids()
int[] getExcludeUsages()
int[] getMatchingUids()
int[] getMatchingUsages()
MediaProjection getMediaProjection()

Inherited methods

Public methods

getExcludeUids

Added in API level 29
public int[] getExcludeUids ()

Returns
int[] the UIDs passed to Builder#excludeUid(int). This value cannot be null.

getExcludeUsages

Added in API level 29
public int[] getExcludeUsages ()

Returns
int[] the usages passed to Builder#excludeUsage(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 This value cannot be null.

getMatchingUids

Added in API level 29
public int[] getMatchingUids ()

Returns
int[] the UIDs passed to Builder#addMatchingUid(int). This value cannot be null.

getMatchingUsages

Added in API level 29
public int[] getMatchingUsages ()

Returns
int[] the usages passed to Builder#addMatchingUsage(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 This value cannot be null.

getMediaProjection

Added in API level 29
public MediaProjection getMediaProjection ()

Returns
MediaProjection the MediaProjection used to build this object. This value cannot be null.