androidx.media3.common


Interfaces

AdViewProvider

Provides information about views for the ad playback UI.

DataReader

Reads bytes from a data stream.

DebugViewProvider

Provider for views to show diagnostic information during an export, for debugging.

Effect

Marker interface for a video frame effect.

ErrorMessageProvider

Converts throwables into error codes and user readable error messages.

GlObjectsProvider

Provider to customize the creation and maintenance of GL objects.

Metadata.Entry

A metadata entry.

OnInputFrameProcessedListener

A listener for processing input frames.

Player

A media player interface defining high-level functionality, such as the ability to play, pause, seek and query properties of the currently playing media.

Player.Listener

Listener for changes in a Player.

PreviewingVideoGraph

A VideoGraph specific to previewing.

PreviewingVideoGraph.Factory

A factory for creating a PreviewingVideoGraph.

SimpleBasePlayer.PositionSupplier

A supplier for a position.

VideoFrameProcessor

Interface for a video frame processor that applies changes to individual video frames.

VideoFrameProcessor.Factory

A factory for VideoFrameProcessor instances.

VideoFrameProcessor.Listener

Listener for asynchronous frame processing events.

VideoGraph

Represents a graph for processing raw video frames.

VideoGraph.Listener

Listener for video frame processing events.

Classes

AdOverlayInfo

Provides information about an overlay view shown on top of an ad view group.

AdOverlayInfo.Builder

A builder for AdOverlayInfo instances.

AdPlaybackState

Represents ad group times and information on the state and URIs of ads within each ad group.

AdPlaybackState.AdGroup

Represents a group of ads, with information about their states.

AudioAttributes

Attributes for audio playback, which configure the underlying platform .

AudioAttributes.AudioAttributesV21

A direct wrapper around android.media.AudioAttributes.

AudioAttributes.Builder

Builder for AudioAttributes.

AuxEffectInfo

Represents auxiliary effect information, which can be used to attach an auxiliary effect to an underlying AudioTrack.

BasePlayer

Abstract base Player which implements common implementation independent methods.

BundleListRetriever

A Binder to transfer a list of Bundles across processes by splitting the list into multiple transactions.

C

Defines constants used by the library.

ColorInfo

Stores color info.

ColorInfo.Builder

Builds ColorInfo instances.

DeviceInfo

Information about the playback device.

DeviceInfo.Builder

Builder for DeviceInfo.

DrmInitData

Initialization data for one or more DRM schemes.

DrmInitData.SchemeData

Scheme initialization data.

FileTypes

Defines common file type constants and helper methods.

FlagSet

A set of integer flags.

FlagSet.Builder

A builder for FlagSet instances.

Format

Represents a media format.

Format.Builder

Builds Format instances.

ForwardingPlayer

A Player that forwards method calls to another Player.

ForwardingSimpleBasePlayer

A SimpleBasePlayer that forwards all calls to another Player instance.

FrameInfo

Value class specifying information about a decoded video frame.

FrameInfo.Builder

A builder for FrameInfo instances.

GlTextureInfo

Contains information describing an OpenGL texture.

HeartRating

A rating expressed as "heart" or "no heart".

Label

A label for a Format.

MediaItem

Representation of a media item.

MediaItem.AdsConfiguration

Configuration for playing back linear ads with a media item.

MediaItem.AdsConfiguration.Builder

Builder for AdsConfiguration instances.

MediaItem.Builder

A builder for MediaItem instances.

MediaItem.ClippingConfiguration

Optionally clips the media item to a custom start and end position.

MediaItem.ClippingConfiguration.Builder

Builder for ClippingConfiguration instances.

MediaItem.ClippingProperties

This class is deprecated.

Use ClippingConfiguration instead.

MediaItem.DrmConfiguration

DRM configuration for a media item.

MediaItem.DrmConfiguration.Builder

Builder for DrmConfiguration.

MediaItem.LiveConfiguration

Live playback configuration.

MediaItem.LiveConfiguration.Builder

Builder for LiveConfiguration instances.

MediaItem.LocalConfiguration

Properties for local playback.

MediaItem.RequestMetadata

Metadata that helps the player to understand a playback request represented by a .

MediaItem.RequestMetadata.Builder

Builder for RequestMetadata instances.

MediaItem.Subtitle

This class is deprecated.

Use MediaItem.SubtitleConfiguration instead

MediaItem.SubtitleConfiguration

Properties for a text track.

MediaItem.SubtitleConfiguration.Builder

Builder for SubtitleConfiguration instances.

MediaLibraryInfo

Information about the media libraries.

MediaMetadata

Metadata of a MediaItem, playlist, or a combination of multiple sources of .

MediaMetadata.Builder

A builder for MediaMetadata instances.

Metadata

A collection of metadata entries.

MimeTypes

Defines common MIME types and helper methods.

PercentageRating

A rating expressed as a percentage.

PlaybackParameters

Parameters that apply to playback, including speed setting.

Player.Commands

A set of commands.

Player.Commands.Builder

A builder for Commands instances.

Player.Events

A set of events.

Player.PositionInfo

Position info describing a playback position involved in a discontinuity.

PriorityTaskManager

Allows tasks with associated priorities to control how they proceed relative to one another.

Rating

A rating for media content.

SimpleBasePlayer

A base implementation for Player that reduces the number of methods to implement to a minimum.

SimpleBasePlayer.MediaItemData

An immutable description of an item in the playlist, containing both static setup information like MediaItem and dynamic data that is generally read from the media like the duration.

SimpleBasePlayer.MediaItemData.Builder

A builder for MediaItemData objects.

SimpleBasePlayer.PeriodData

Data describing the properties of a period inside a MediaItemData.

SimpleBasePlayer.PeriodData.Builder

A builder for PeriodData objects.

SimpleBasePlayer.State

An immutable state description of the player.

SimpleBasePlayer.State.Builder

A builder for State objects.

StarRating

A rating expressed as a fractional number of stars.

StreamKey

A key for a subset of media that can be separately loaded (a "stream").

SurfaceInfo

Immutable value class for a Surface and supporting information.

ThumbRating

A rating expressed as "thumbs up" or "thumbs down".

Timeline

A flexible representation of the structure of media.

Timeline.Period

Holds information about a period in a Timeline.

Timeline.RemotableTimeline

A concrete class of Timeline to restore a Timeline instance from a sent by another process via IBinder.

Timeline.Window

Holds information about a window in a Timeline.

TrackGroup

An immutable group of tracks available within a media stream.

TrackSelectionOverride

A track selection override, consisting of a TrackGroup and the indices of the tracks within the group that should be selected.

TrackSelectionParameters

Parameters for controlling track selection.

TrackSelectionParameters.AudioOffloadPreferences

Preferences and constraints for enabling audio offload.

TrackSelectionParameters.AudioOffloadPreferences.Builder

A builder for AudioOffloadPreferences.

TrackSelectionParameters.Builder

A builder for TrackSelectionParameters.

Tracks

Information about groups of tracks.

Tracks.Group

Information about a single group of tracks, including the underlying TrackGroup, the level to which each track is supported by the player, and whether any of the tracks are selected.

VideoSize

Represents the video size.

Exceptions

IllegalSeekPositionException

Thrown when an attempt is made to seek to a position that does not exist in the player's .

ParserException

Thrown when an error occurs parsing media data and metadata.

PlaybackException

Thrown when a non locally recoverable playback failure occurs.

PriorityTaskManager.PriorityTooLowException

Thrown when task attempts to proceed when another registered task has a higher priority.

VideoFrameProcessingException

Thrown when an exception occurs while preparing an Effect, or applying an Effect to video frames.

Annotations

AdOverlayInfo.Purpose

The purpose of the overlay.

AdPlaybackState.AdState

Represents the state of an ad in an ad group.

C.AudioAllowedCapturePolicy

Capture policies for audio attributes.

C.AudioContentType

Content types for audio attributes.

C.AudioFlags

Flags for audio attributes.

C.AudioUsage

Usage types for audio attributes.

C.AuxiliaryTrackType

Auxiliary track types.

C.BufferFlags

Flags which can apply to a buffer containing a media sample.

C.ColorRange

Video color range.

C.ColorSpace

Video color spaces, also referred to as color standards.

C.ColorTransfer

Video/image color transfer characteristics.

C.ContentType

Represents a streaming or other media type.

C.CryptoMode

Crypto modes for a codec.

C.CryptoType

Types of crypto implementation.

C.DataType

Represents a type of data.

C.Encoding

Represents an audio encoding, or an invalid or unset value.

C.FirstFrameState

State of the first frame in a video renderer.

C.FormatSupport

Level of support for a format.

C.NetworkType

Network connection type.

C.PcmEncoding

Represents a PCM audio encoding, or an invalid or unset value.

C.Priority

A value indicating the priority of a operation.

C.Projection

Video projection types.

C.RoleFlags

Track role flags.

C.SelectionFlags

Track selection flags.

C.SelectionReason

Represents a reason for selection.

C.SpatializationBehavior

Represents the behavior affecting whether spatialization will be used.

C.StereoMode

The stereo mode for 360/3D/VR videos.

C.StreamType

Stream types for an android.media.AudioTrack.

C.TrackType

Represents a type of media track.

C.VideoChangeFrameRateStrategy

Strategies for calling setFrameRate.

C.VideoOutputMode

Video decoder output modes.

C.VideoScalingMode

Video scaling modes for MediaCodec-based renderers.

C.VolumeFlags

Volume flags to be used when setting or adjusting device volume.

C.WakeMode

Mode specifying whether the player should hold a WakeLock and a WifiLock.

DeviceInfo.PlaybackType

Types of playback.

FileTypes.Type

File types.

Format.CueReplacementBehavior

The replacement behaviors for consecutive samples in a text track of type APPLICATION_MEDIA3_CUES.

MediaMetadata.FolderType

This annotation is deprecated.

Use isBrowsable to indicate if an item is a browsable folder and use mediaType to indicate the type of the folder.

MediaMetadata.MediaType

The type of content described by the media item.

MediaMetadata.PictureType

The picture type of the artwork.

PlaybackException.ErrorCode

Codes that identify causes of player errors.

Player.Command

Commands that indicate which method calls are currently permitted on a particular Player instance.

Player.DiscontinuityReason

Reasons for position discontinuities.

Player.Event

Events that can be reported via onEvents.

Player.MediaItemTransitionReason

Reasons for media item transitions.

Player.PlayWhenReadyChangeReason

Reasons for playWhenReady changes.

Player.PlaybackSuppressionReason

Reason why playback is suppressed even though getPlayWhenReady is true.

Player.RepeatMode

Repeat modes for playback.

Player.State

Playback state.

Player.TimelineChangeReason

Reasons for timeline changes.

TrackSelectionParameters.AudioOffloadPreferences.AudioOffloadMode

The preference level for enabling audio offload on the audio sink.

VideoFrameProcessor.InputType

Specifies how the input frames are made available to the VideoFrameProcessor.

Extension functions summary

suspend Nothing

Continuously listens to the Player.Listener.onEvents callback, passing the received Player.Events to the provided onEvents function.

Extension functions

@UnstableApi
suspend fun Player.listen(onEvents: Player.(Player.Events) -> Unit): Nothing

Continuously listens to the Player.Listener.onEvents callback, passing the received Player.Events to the provided onEvents function.

This function can be called from any thread. The onEvents function will be invoked on the thread associated with Player.getApplicationLooper.

If, during the execution of onEvents, an exception is thrown, the coroutine corresponding to listening to the Player will be terminated. Any used resources will be cleaned up (e.g. removing of the listeners) and exception will be re-thrown right after the last suspension point.

Parameters
onEvents: Player.(Player.Events) -> Unit

The function to handle player events.

Returns
Nothing

Nothing This function never returns normally. It will either continue indefinitely or terminate due to an exception or cancellation.