Added in API level 29
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:
- the usage value MUST be
AudioAttributes.USAGE_UNKNOWNorAudioAttributes.USAGE_GAMEorAudioAttributes.USAGE_MEDIA. All other usages CAN NOT be captured. - AND the capture policy set by their app (with
AudioManager.setAllowedCapturePolicy) or on each player (withAudioAttributes.Builder.setAllowedCapturePolicy) isAudioAttributes.ALLOW_CAPTURE_BY_ALL, whichever is the most strict. - AND their app attribute allowAudioPlaybackCapture in their manifest MUST either be:
- set to "true"
- not set, and their
targetSdkVersionMUST be equal to or greater thanBuild.VERSION_CODES.Q. Ie. Apps that do not target at least Android Q must explicitly opt-in to be captured by a MediaProjection.
- AND their apps MUST be in the same user profile as your app (eg work profile cannot capture user profile apps and vice-versa).
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();
See also:
Summary
Nested classes | |
|---|---|
class | AudioPlaybackCaptureConfiguration.Builder Builder for creating |
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 ()
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 ()
getMediaProjection
Added in API level 29
public MediaProjection getMediaProjection ()
| Returns | |
|---|---|
MediaProjection | the MediaProjection used to build this object. This value cannot be null. |
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 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[]]