Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
Added in API level 1
package

android.media

Provides classes that manage various media interfaces in audio and video.

The Media APIs are used to play and, in some cases, record media files. This includes audio (e.g., play MP3s or other music files, ringtones, game sound effects, or DTMF tones) and video (e.g., play a video streamed over the web or from local storage).

Other special classes in the package offer the ability to detect the faces of people in Bitmaps ( FaceDetector ), control audio routing (to the device or a headset) and control alerts such as ringtones and phone vibrations ( AudioManager ).

Interfaces

AudioManager.OnAudioFocusChangeListener Interface definition for a callback to be invoked when the audio focus of the system is updated. 
AudioRecord.OnRecordPositionUpdateListener Interface definition for a callback to be invoked when an AudioRecord has reached a notification marker set by setNotificationMarkerPosition(int) or for periodic updates on the progress of the record head, as set by setPositionNotificationPeriod(int)
AudioTrack.OnPlaybackPositionUpdateListener Interface definition for a callback to be invoked when the playback head position of an AudioTrack has reached a notification marker or has increased by a certain period. 
ImageReader.OnImageAvailableListener Callback interface for being notified that a new image is available. 
JetPlayer.OnJetEventListener Handles the notification when the JET engine generates an event. 
MediaDrm.OnEventListener Interface definition for a callback to be invoked when a drm event occurs  
MediaPlayer.OnBufferingUpdateListener Interface definition of a callback to be invoked indicating buffering status of a media resource being streamed over the network. 
MediaPlayer.OnCompletionListener Interface definition for a callback to be invoked when playback of a media source has completed. 
MediaPlayer.OnErrorListener Interface definition of a callback to be invoked when there has been an error during an asynchronous operation (other errors will throw exceptions at method call time). 
MediaPlayer.OnInfoListener Interface definition of a callback to be invoked to communicate some info and/or warning about the media or its playback. 
MediaPlayer.OnPreparedListener Interface definition for a callback to be invoked when the media source is ready for playback. 
MediaPlayer.OnSeekCompleteListener Interface definition of a callback to be invoked indicating the completion of a seek operation. 
MediaPlayer.OnTimedTextListener Interface definition of a callback to be invoked when a timed text is available for display. 
MediaPlayer.OnVideoSizeChangedListener Interface definition of a callback to be invoked when the video size is first known or updated  
MediaRecorder.OnErrorListener Interface definition for a callback to be invoked when an error occurs while recording. 
MediaRecorder.OnInfoListener Interface definition for a callback to be invoked when an error occurs while recording. 
MediaScannerConnection.MediaScannerConnectionClient An interface for notifying clients of MediaScannerConnection when a connection to the MediaScanner service has been established and when the scanning of a file has completed. 
MediaScannerConnection.OnScanCompletedListener Interface for notifying clients of the result of scanning a requested media file. 
RemoteControlClient.OnGetPlaybackPositionListener Interface definition for a callback to be invoked when the media playback position is queried. 
RemoteControlClient.OnMetadataUpdateListener Interface definition for a callback to be invoked when one of the metadata values has been updated. 
RemoteControlClient.OnPlaybackPositionUpdateListener Interface definition for a callback to be invoked when the media playback position is requested to be updated. 
RemoteController.OnClientUpdateListener Interface definition for the callbacks to be invoked whenever media events, metadata and playback status are available. 
SoundPool.OnLoadCompleteListener  

Classes

AsyncPlayer Plays a series of audio URIs, but does all the hard work on another thread so that any slowness with preparing or loading doesn't block the calling thread. 
AudioFormat The AudioFormat class is used to access a number of audio format and channel configuration constants. 
AudioManager AudioManager provides access to volume and ringer mode control. 
AudioRecord The AudioRecord class manages the audio resources for Java applications to record audio from the audio input hardware of the platform. 
AudioTimestamp Structure that groups a position in frame units relative to an assumed audio stream, together with the estimated time when that frame was presented or is committed to be presented. 
AudioTrack The AudioTrack class manages and plays a single audio resource for Java applications. 
CamcorderProfile Retrieves the predefined camcorder profile settings for camcorder applications. 
CameraProfile The CameraProfile class is used to retrieve the pre-defined still image capture (jpeg) quality levels (0-100) used for low, medium, and high quality settings in the Camera application. 
ExifInterface This is a class for reading and writing Exif tags in a JPEG file. 
FaceDetector Identifies the faces of people in a Bitmap graphic object. 
FaceDetector.Face A Face contains all the information identifying the location of a face in a bitmap. 
Image

A single complete image buffer to use with a media source such as a MediaCodec

Image.Plane

A single color plane of image data. 

ImageReader

The ImageReader class allows direct application access to image data rendered into a Surface

Several Android media API classes accept Surface objects as targets to render to, including MediaPlayer , MediaCodec , and RenderScript Allocations

JetPlayer JetPlayer provides access to JET content playback and control. 
MediaActionSound

A class for producing sounds that match those produced by various actions taken by the media and camera APIs. 

MediaCodec MediaCodec class can be used to access low-level media codec, i.e. 
MediaCodec.BufferInfo Per buffer metadata includes an offset and size specifying the range of valid data in the associated codec buffer. 
MediaCodec.CryptoInfo Metadata describing the structure of a (at least partially) encrypted input sample. 
MediaCodecInfo Provides information about a given media codec available on the device. 
MediaCodecInfo.CodecCapabilities Encapsulates the capabilities of a given codec component. 
MediaCodecInfo.CodecProfileLevel Encapsulates the profiles available for a codec component. 
MediaCodecList Allows you to enumerate available codecs, each specified as a MediaCodecInfo object, find a codec supporting a given format and query the capabilities of a given codec. 
MediaCrypto MediaCrypto class can be used in conjunction with MediaCodec to decode encrypted media data. 
MediaDrm MediaDrm can be used to obtain keys for decrypting protected media streams, in conjunction with MediaCrypto
MediaDrm.CryptoSession In addition to supporting decryption of DASH Common Encrypted Media, the MediaDrm APIs provide the ability to securely deliver session keys from an operator's session key server to a client device, based on the factory-installed root of trust, and then perform encrypt, decrypt, sign and verify operations with the session key on arbitrary user data. 
MediaDrm.KeyRequest Contains the opaque data an app uses to request keys from a license server  
MediaDrm.ProvisionRequest Contains the opaque data an app uses to request a certificate from a provisioning server  
MediaExtractor MediaExtractor facilitates extraction of demuxed, typically encoded, media data from a data source. 
MediaFormat Encapsulates the information describing the format of media data, be it audio or video. 
MediaMetadataEditor An abstract class for editing and storing metadata that can be published by RemoteControlClient
MediaMetadataRetriever MediaMetadataRetriever class provides a unified interface for retrieving frame and meta data from an input media file. 
MediaMuxer MediaMuxer facilitates muxing elementary streams. 
MediaMuxer.OutputFormat Defines the output format. 
MediaPlayer MediaPlayer class can be used to control playback of audio/video files and streams. 
MediaPlayer.TrackInfo Class for MediaPlayer to return each audio/video/subtitle track's metadata. 
MediaRecorder Used to record audio and video. 
MediaRecorder.AudioEncoder Defines the audio encoding. 
MediaRecorder.AudioSource Defines the audio source. 
MediaRecorder.OutputFormat Defines the output format. 
MediaRecorder.VideoEncoder Defines the video encoding. 
MediaRecorder.VideoSource Defines the video source. 
MediaRouter MediaRouter allows applications to control the routing of media channels and streams from the current device to external speakers and destination devices. 
MediaRouter.Callback Interface for receiving events about media routing changes. 
MediaRouter.RouteCategory Definition of a category of routes. 
MediaRouter.RouteGroup Information about a route that consists of multiple other routes in a group. 
MediaRouter.RouteInfo Information about a media route. 
MediaRouter.SimpleCallback Stub implementation of MediaRouter.Callback
MediaRouter.UserRouteInfo Information about a route that the application may define and modify. 
MediaRouter.VolumeCallback Interface for receiving events about volume changes. 
MediaScannerConnection MediaScannerConnection provides a way for applications to pass a newly created or downloaded media file to the media scanner service. 
MediaSyncEvent The MediaSyncEvent class defines events that can be used to synchronize playback or capture actions between different players and recorders. 
Rating A class to encapsulate rating information used as content metadata. 
RemoteControlClient RemoteControlClient enables exposing information meant to be consumed by remote controls capable of displaying metadata, artwork and media transport control buttons. 
RemoteControlClient.MetadataEditor Class used to modify metadata in a RemoteControlClient object. 
RemoteController The RemoteController class is used to control media playback, display and update media metadata and playback status, published by applications using the RemoteControlClient class. 
RemoteController.MetadataEditor A class to read the metadata published by a RemoteControlClient , or send a RemoteControlClient new values for keys that can be edited. 
Ringtone Ringtone provides a quick method for playing a ringtone, notification, or other similar types of sounds. 
RingtoneManager RingtoneManager provides access to ringtones, notification, and other types of sounds. 
SoundPool The SoundPool class manages and plays audio resources for applications. 
ThumbnailUtils Thumbnail generation routines for media provider. 
TimedText Class to hold the timed text's metadata, including:
  • The characters for rendering
  • The rendering position for the timed text

To render the timed text, applications need to do the following:

 

ToneGenerator This class provides methods to play DTMF tones (ITU-T Recommendation Q.23), call supervisory tones (3GPP TS 22.001, CEPT) and proprietary tones (3GPP TS 31.111). 

Exceptions

DeniedByServerException Exception thrown when the provisioning server or key server denies a certficate or license for a device. 
MediaCodec.CryptoException Thrown when a crypto error occurs while queueing a secure input buffer. 
MediaCryptoException Exception thrown if MediaCrypto object could not be instantiated for whatever reason. 
MediaDrmException Base class for MediaDrm exceptions  
NotProvisionedException Exception thrown when an operation on a MediaDrm object is attempted and the device does not have a certificate. 
ResourceBusyException Exception thrown when an operation on a MediaDrm object is attempted and hardware resources are not available, due to being in use. 
UnsupportedSchemeException Exception thrown when an attempt is made to construct a MediaDrm object using a crypto scheme UUID that is not supported by the device