Android Guides | Samples

Android.Media.AudioAttributes Class

A class to encapsulate a collection of attributes describing information about an audio stream.

See Also: AudioAttributes

Syntax

[Android.Runtime.Register("android/media/AudioAttributes", DoNotGenerateAcw=true)]
public sealed class AudioAttributes : Object, IParcelable, IDisposable

Remarks

A class to encapsulate a collection of attributes describing information about an audio stream.

AudioAttributes supersede the notion of stream types (see for instance AudioManager.STREAM_MUSIC or AudioManager.STREAM_ALARM) for defining the behavior of audio playback. Attributes allow an application to specify more information than is conveyed in a stream type by allowing the application to define:

  • usage: "why" you are playing a sound, what is this sound used for. This is achieved with the "usage" information. Examples of usage are AudioAttributes.USAGE_MEDIA and AudioAttributes.USAGE_ALARM. These two examples are the closest to stream types, but more detailed use cases are available. Usage information is more expressive than a stream type, and allows certain platforms or routing policies to use this information for more refined volume or routing decisions. Usage is the most important information to supply in AudioAttributes and it is recommended to build any instance with this information supplied, see NoType:android/media/AudioAttributes$Builder;Href=../../../reference/android/media/AudioAttributes.Builder.html for exceptions.
  • content type: "what" you are playing. The content type expresses the general category of the content. This information is optional. But in case it is known (for instance AudioAttributes.CONTENT_TYPE_MOVIE for a movie streaming service or AudioAttributes.CONTENT_TYPE_MUSIC for a music playback application) this information might be used by the audio framework to selectively configure some audio post-processing blocks.
  • flags: "how" is playback to be affected, see the flag definitions for the specific playback behaviors they control.

AudioAttributes are used for example in one of the AudioTrack constructors (see AudioTrack.AudioTrack(IntPtr,JniHandleOwnership)), to configure a MediaPlayer (see MediaPlayer.SetAudioAttributes(AudioAttributes) or a Notification (see Notification.AudioAttributes). An AudioAttributes instance is built through its builder, NoType:android/media/AudioAttributes$Builder;Href=../../../reference/android/media/AudioAttributes.Builder.html.

[Android Documentation]

Requirements

Namespace: Android.Media
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0

The members of Android.Media.AudioAttributes are listed below.

See Also: Object

Public Properties

[read-only]
ContentTypeAudioContentType. Return the content type.
[read-only]
static
CreatorIParcelableCreator.
[read-only]
FlagsAudioFlags. Return the flags.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

DescribeContents() : Int32
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
WriteToParcel(Parcel, ParcelableWriteFlags)
Flatten this object in to a Parcel.