public final class MimeTypes


Defines common MIME types and helper methods.

Summary

Constants

static final String
APPLICATION_AIT = "application/vnd.dvb.ait"
static final String
@UnstableApi
APPLICATION_CAMERA_MOTION = "application/x-camera-motion"
static final String
APPLICATION_CEA608 = "application/cea-608"
static final String
APPLICATION_CEA708 = "application/cea-708"
static final String
@UnstableApi
APPLICATION_DEPTH_METADATA = "application/x-depth-metadata"
static final String
APPLICATION_DVBSUBS = "application/dvbsubs"
static final String
@UnstableApi
APPLICATION_EMSG = "application/x-emsg"
static final String
@UnstableApi
APPLICATION_EXIF = "application/x-exif"
static final String

MIME type for an image URI loaded from an external image management framework.

static final String
@UnstableApi
APPLICATION_ICY = "application/x-icy"
static final String
APPLICATION_ID3 = "application/id3"
static final String
APPLICATION_M3U8 = "application/x-mpegURL"
static final String
APPLICATION_MATROSKA = "application/x-matroska"
static final String
@UnstableApi
APPLICATION_MEDIA3_CUES = "application/x-media3-cues"
static final String
APPLICATION_MP4 = "application/mp4"
static final String
APPLICATION_MP4CEA608 = "application/x-mp4-cea-608"
static final String
APPLICATION_MP4VTT = "application/x-mp4-vtt"
static final String
APPLICATION_MPD = "application/dash+xml"
static final String
APPLICATION_PGS = "application/pgs"
static final String
APPLICATION_RAWCC = "application/x-rawcc"

This field is deprecated.

RawCC is a Google-internal subtitle format that isn't supported by this version of Media3.

static final String
APPLICATION_RTSP = "application/x-rtsp"
static final String
@UnstableApi
APPLICATION_SCTE35 = "application/x-scte35"
static final String
APPLICATION_SDP = "application/sdp"
static final String
APPLICATION_SS = "application/vnd.ms-sstr+xml"
static final String
APPLICATION_SUBRIP = "application/x-subrip"
static final String
APPLICATION_TTML = "application/ttml+xml"
static final String
APPLICATION_TX3G = "application/x-quicktime-tx3g"
static final String
APPLICATION_VOBSUB = "application/vobsub"
static final String
APPLICATION_WEBM = "application/webm"
static final String
AUDIO_AAC = "audio/mp4a-latm"
static final String
AUDIO_AC3 = "audio/ac3"
static final String
AUDIO_AC4 = "audio/ac4"
static final String
AUDIO_ALAC = "audio/alac"
static final String
AUDIO_ALAW = "audio/g711-alaw"
static final String
AUDIO_AMR = "audio/amr"
static final String
AUDIO_AMR_NB = "audio/3gpp"
static final String
AUDIO_AMR_WB = "audio/amr-wb"
static final String
AUDIO_DTS = "audio/vnd.dts"
static final String
AUDIO_DTS_EXPRESS = "audio/vnd.dts.hd;profile=lbr"
static final String
AUDIO_DTS_HD = "audio/vnd.dts.hd"
static final String
@UnstableApi
AUDIO_DTS_X = "audio/vnd.dts.uhd;profile=p2"
static final String
@UnstableApi
AUDIO_EXOPLAYER_MIDI = "audio/x-exoplayer-midi"
static final String
AUDIO_E_AC3 = "audio/eac3"
static final String
AUDIO_E_AC3_JOC = "audio/eac3-joc"
static final String
AUDIO_FLAC = "audio/flac"
static final String
@UnstableApi
AUDIO_IAMF = "audio/iamf"
static final String
@UnstableApi
AUDIO_MATROSKA = "audio/x-matroska"
static final String
AUDIO_MIDI = "audio/midi"
static final String
AUDIO_MLAW = "audio/g711-mlaw"
static final String
AUDIO_MP4 = "audio/mp4"
static final String
AUDIO_MPEG = "audio/mpeg"
static final String
AUDIO_MPEGH_MHA1 = "audio/mha1"
static final String
AUDIO_MPEGH_MHM1 = "audio/mhm1"
static final String
AUDIO_MPEG_L1 = "audio/mpeg-L1"
static final String
AUDIO_MPEG_L2 = "audio/mpeg-L2"
static final String
AUDIO_MSGSM = "audio/gsm"
static final String
AUDIO_OGG = "audio/ogg"
static final String
AUDIO_OPUS = "audio/opus"
static final String
AUDIO_RAW = "audio/raw"
static final String
AUDIO_TRUEHD = "audio/true-hd"
static final String
@UnstableApi
AUDIO_UNKNOWN = "audio/x-unknown"
static final String
AUDIO_VORBIS = "audio/vorbis"
static final String
AUDIO_WAV = "audio/wav"
static final String
AUDIO_WEBM = "audio/webm"
static final String
static final String
static final String
static final String
static final String
static final String

A non-standard codec string for E-AC3-JOC.

static final String
@UnstableApi
IMAGE_AVIF = "image/avif"
static final String
@UnstableApi
IMAGE_BMP = "image/bmp"
static final String
@UnstableApi
IMAGE_HEIC = "image/heic"
static final String
@UnstableApi
IMAGE_HEIF = "image/heif"
static final String
IMAGE_JPEG = "image/jpeg"
static final String
@UnstableApi
IMAGE_JPEG_R = "image/jpeg_r"
static final String
@UnstableApi
IMAGE_PNG = "image/png"
static final String
@UnstableApi
IMAGE_RAW = "image/raw"
static final String
@UnstableApi
IMAGE_WEBP = "image/webp"
static final String
TEXT_SSA = "text/x-ssa"
static final String
@UnstableApi
TEXT_UNKNOWN = "text/x-unknown"
static final String
TEXT_VTT = "text/vtt"
static final String
VIDEO_AV1 = "video/av01"
static final String
VIDEO_AVI = "video/x-msvideo"
static final String
VIDEO_DIVX = "video/divx"
static final String
VIDEO_DOLBY_VISION = "video/dolby-vision"
static final String
@UnstableApi
VIDEO_FLV = "video/x-flv"
static final String
VIDEO_H263 = "video/3gpp"
static final String
VIDEO_H264 = "video/avc"
static final String
VIDEO_H265 = "video/hevc"
static final String
@UnstableApi
VIDEO_MATROSKA = "video/x-matroska"
static final String
VIDEO_MJPEG = "video/mjpeg"
static final String
VIDEO_MP2T = "video/mp2t"
static final String
VIDEO_MP4 = "video/mp4"
static final String
VIDEO_MP42 = "video/mp42"
static final String
VIDEO_MP43 = "video/mp43"
static final String
VIDEO_MP4V = "video/mp4v-es"
static final String
VIDEO_MPEG = "video/mpeg"
static final String
VIDEO_MPEG2 = "video/mpeg2"
static final String
@UnstableApi
VIDEO_MV_HEVC = "video/mv-hevc"
static final String
VIDEO_OGG = "video/ogg"
static final String
VIDEO_PS = "video/mp2p"
static final String
@UnstableApi
VIDEO_RAW = "video/raw"
static final String
@UnstableApi
VIDEO_UNKNOWN = "video/x-unknown"
static final String
VIDEO_VC1 = "video/wvc1"
static final String
@UnstableApi
VIDEO_VP8 = "video/x-vnd.on2.vp8"
static final String
@UnstableApi
VIDEO_VP9 = "video/x-vnd.on2.vp9"
static final String
VIDEO_WEBM = "video/webm"

Public methods

static boolean

Returns true if it is known that all samples in a stream of the given MIME type and codec are guaranteed to be sync samples (i.e., BUFFER_FLAG_KEY_FRAME is guaranteed to be set on every sample) and the inherent duration of each sample is negligible (i.e., we never expect to require a sample because playback partially falls into its duration).

static boolean

Returns whether the given codecs string contains a codec which corresponds to the given mimeType.

static @Nullable String

Returns the first audio MIME type derived from an RFC 6381 codecs string.

static @Nullable String

Returns a subsequence of codecs containing the codec strings that correspond to the given mimeType.

static int

Returns the C.Encoding constant corresponding to the specified audio MIME type and RFC 6381 codec string, or ENCODING_INVALID if the corresponding C.Encoding cannot be determined.

static @Nullable String

Returns the MIME type corresponding to an RFC 6381 codec string, or null if it could not be determined.

static @Nullable String

Returns the MIME type corresponding to an MP4 object type identifier, as defined in RFC 6381 and https://mp4ra.org/#/object_types.

static @Nullable Byte

Returns the MP4 object type identifier corresponding to a MIME type, as defined in RFC 6381 and MPEG-4 Object Types.

static @Nullable String

Returns the first text MIME type derived from an RFC 6381 codecs string.

static int

Returns the track type constant corresponding to a specified MIME type, which may be TRACK_TYPE_UNKNOWN if it could not be determined.

static int

Equivalent to getTrackType(getMediaMimeType(codec)).

static @Nullable String

Returns the first video MIME type derived from an RFC 6381 codecs string.

static boolean

Returns whether the given string is an audio MIME type.

static boolean

Returns whether the given string is an image MIME type.

static boolean

Returns whether the given mimeType is a Matroska MIME type, including WebM.

static boolean

Returns whether the given string is a text MIME type, including known text types that use "application" as their base type.

static boolean

Returns whether the given string is a video MIME type.

static @PolyNull String

Normalizes the MIME type provided so that equivalent MIME types are uniquely represented.

static void
@UnstableApi
registerCustomMimeType(
    String mimeType,
    String codecPrefix,
    @C.TrackType int trackType
)

Registers a custom MIME type.

Constants

APPLICATION_AIT

public static final String APPLICATION_AIT = "application/vnd.dvb.ait"

APPLICATION_CAMERA_MOTION

@UnstableApi
public static final String APPLICATION_CAMERA_MOTION = "application/x-camera-motion"

APPLICATION_CEA608

public static final String APPLICATION_CEA608 = "application/cea-608"

APPLICATION_CEA708

public static final String APPLICATION_CEA708 = "application/cea-708"

APPLICATION_DEPTH_METADATA

@UnstableApi
public static final String APPLICATION_DEPTH_METADATA = "application/x-depth-metadata"

APPLICATION_DVBSUBS

public static final String APPLICATION_DVBSUBS = "application/dvbsubs"

APPLICATION_EMSG

@UnstableApi
public static final String APPLICATION_EMSG = "application/x-emsg"

APPLICATION_EXIF

@UnstableApi
public static final String APPLICATION_EXIF = "application/x-exif"

APPLICATION_EXTERNALLY_LOADED_IMAGE

@UnstableApi
public static final String APPLICATION_EXTERNALLY_LOADED_IMAGE = "application/x-image-uri"

MIME type for an image URI loaded from an external image management framework.

APPLICATION_ICY

@UnstableApi
public static final String APPLICATION_ICY = "application/x-icy"

APPLICATION_ID3

public static final String APPLICATION_ID3 = "application/id3"

APPLICATION_M3U8

public static final String APPLICATION_M3U8 = "application/x-mpegURL"

APPLICATION_MATROSKA

public static final String APPLICATION_MATROSKA = "application/x-matroska"

APPLICATION_MEDIA3_CUES

@UnstableApi
public static final String APPLICATION_MEDIA3_CUES = "application/x-media3-cues"

APPLICATION_MP4

public static final String APPLICATION_MP4 = "application/mp4"

APPLICATION_MP4CEA608

public static final String APPLICATION_MP4CEA608 = "application/x-mp4-cea-608"

APPLICATION_MP4VTT

public static final String APPLICATION_MP4VTT = "application/x-mp4-vtt"

APPLICATION_MPD

public static final String APPLICATION_MPD = "application/dash+xml"

APPLICATION_PGS

public static final String APPLICATION_PGS = "application/pgs"

APPLICATION_RAWCC

public static final String APPLICATION_RAWCC = "application/x-rawcc"

APPLICATION_RTSP

public static final String APPLICATION_RTSP = "application/x-rtsp"

APPLICATION_SCTE35

@UnstableApi
public static final String APPLICATION_SCTE35 = "application/x-scte35"

APPLICATION_SDP

public static final String APPLICATION_SDP = "application/sdp"

APPLICATION_SS

public static final String APPLICATION_SS = "application/vnd.ms-sstr+xml"

APPLICATION_SUBRIP

public static final String APPLICATION_SUBRIP = "application/x-subrip"

APPLICATION_TTML

public static final String APPLICATION_TTML = "application/ttml+xml"

APPLICATION_TX3G

public static final String APPLICATION_TX3G = "application/x-quicktime-tx3g"

APPLICATION_VOBSUB

public static final String APPLICATION_VOBSUB = "application/vobsub"

APPLICATION_WEBM

public static final String APPLICATION_WEBM = "application/webm"

AUDIO_AAC

public static final String AUDIO_AAC = "audio/mp4a-latm"

AUDIO_AC3

public static final String AUDIO_AC3 = "audio/ac3"

AUDIO_AC4

public static final String AUDIO_AC4 = "audio/ac4"

AUDIO_ALAC

public static final String AUDIO_ALAC = "audio/alac"

AUDIO_ALAW

public static final String AUDIO_ALAW = "audio/g711-alaw"

AUDIO_AMR

public static final String AUDIO_AMR = "audio/amr"

AUDIO_AMR_NB

public static final String AUDIO_AMR_NB = "audio/3gpp"

AUDIO_AMR_WB

public static final String AUDIO_AMR_WB = "audio/amr-wb"

AUDIO_DTS

public static final String AUDIO_DTS = "audio/vnd.dts"

AUDIO_DTS_EXPRESS

public static final String AUDIO_DTS_EXPRESS = "audio/vnd.dts.hd;profile=lbr"

AUDIO_DTS_HD

public static final String AUDIO_DTS_HD = "audio/vnd.dts.hd"

AUDIO_DTS_X

@UnstableApi
public static final String AUDIO_DTS_X = "audio/vnd.dts.uhd;profile=p2"

AUDIO_EXOPLAYER_MIDI

@UnstableApi
public static final String AUDIO_EXOPLAYER_MIDI = "audio/x-exoplayer-midi"

AUDIO_E_AC3

public static final String AUDIO_E_AC3 = "audio/eac3"

AUDIO_E_AC3_JOC

public static final String AUDIO_E_AC3_JOC = "audio/eac3-joc"

AUDIO_FLAC

public static final String AUDIO_FLAC = "audio/flac"

AUDIO_IAMF

@UnstableApi
public static final String AUDIO_IAMF = "audio/iamf"

AUDIO_MATROSKA

@UnstableApi
public static final String AUDIO_MATROSKA = "audio/x-matroska"

AUDIO_MIDI

public static final String AUDIO_MIDI = "audio/midi"

AUDIO_MLAW

public static final String AUDIO_MLAW = "audio/g711-mlaw"

AUDIO_MP4

public static final String AUDIO_MP4 = "audio/mp4"

AUDIO_MPEG

public static final String AUDIO_MPEG = "audio/mpeg"

AUDIO_MPEGH_MHA1

public static final String AUDIO_MPEGH_MHA1 = "audio/mha1"

AUDIO_MPEGH_MHM1

public static final String AUDIO_MPEGH_MHM1 = "audio/mhm1"

AUDIO_MPEG_L1

public static final String AUDIO_MPEG_L1 = "audio/mpeg-L1"

AUDIO_MPEG_L2

public static final String AUDIO_MPEG_L2 = "audio/mpeg-L2"

AUDIO_MSGSM

public static final String AUDIO_MSGSM = "audio/gsm"

AUDIO_OGG

public static final String AUDIO_OGG = "audio/ogg"

AUDIO_OPUS

public static final String AUDIO_OPUS = "audio/opus"

AUDIO_RAW

public static final String AUDIO_RAW = "audio/raw"

AUDIO_TRUEHD

public static final String AUDIO_TRUEHD = "audio/true-hd"

AUDIO_UNKNOWN

@UnstableApi
public static final String AUDIO_UNKNOWN = "audio/x-unknown"

AUDIO_VORBIS

public static final String AUDIO_VORBIS = "audio/vorbis"

AUDIO_WAV

public static final String AUDIO_WAV = "audio/wav"

AUDIO_WEBM

public static final String AUDIO_WEBM = "audio/webm"

BASE_TYPE_APPLICATION

@UnstableApi
public static final String BASE_TYPE_APPLICATION = "application"

BASE_TYPE_AUDIO

@UnstableApi
public static final String BASE_TYPE_AUDIO = "audio"

BASE_TYPE_IMAGE

@UnstableApi
public static final String BASE_TYPE_IMAGE = "image"

BASE_TYPE_TEXT

@UnstableApi
public static final String BASE_TYPE_TEXT = "text"

BASE_TYPE_VIDEO

@UnstableApi
public static final String BASE_TYPE_VIDEO = "video"

CODEC_E_AC3_JOC

@UnstableApi
public static final String CODEC_E_AC3_JOC = "ec+3"

A non-standard codec string for E-AC3-JOC. Use of this constant allows for disambiguation between regular E-AC3 ("ec-3") and E-AC3-JOC ("ec+3") streams from the codec string alone. The standard is to use "ec-3" for both, as per the MP4RA registered codec types.

IMAGE_AVIF

@UnstableApi
public static final String IMAGE_AVIF = "image/avif"

IMAGE_BMP

@UnstableApi
public static final String IMAGE_BMP = "image/bmp"

IMAGE_HEIC

@UnstableApi
public static final String IMAGE_HEIC = "image/heic"

IMAGE_HEIF

@UnstableApi
public static final String IMAGE_HEIF = "image/heif"

IMAGE_JPEG

public static final String IMAGE_JPEG = "image/jpeg"

IMAGE_JPEG_R

@UnstableApi
public static final String IMAGE_JPEG_R = "image/jpeg_r"

IMAGE_PNG

@UnstableApi
public static final String IMAGE_PNG = "image/png"

IMAGE_RAW

@UnstableApi
public static final String IMAGE_RAW = "image/raw"

IMAGE_WEBP

@UnstableApi
public static final String IMAGE_WEBP = "image/webp"

TEXT_SSA

public static final String TEXT_SSA = "text/x-ssa"

TEXT_UNKNOWN

@UnstableApi
public static final String TEXT_UNKNOWN = "text/x-unknown"

TEXT_VTT

public static final String TEXT_VTT = "text/vtt"

VIDEO_AV1

public static final String VIDEO_AV1 = "video/av01"

VIDEO_AVI

public static final String VIDEO_AVI = "video/x-msvideo"

VIDEO_DIVX

public static final String VIDEO_DIVX = "video/divx"

VIDEO_DOLBY_VISION

public static final String VIDEO_DOLBY_VISION = "video/dolby-vision"

VIDEO_FLV

@UnstableApi
public static final String VIDEO_FLV = "video/x-flv"

VIDEO_H263

public static final String VIDEO_H263 = "video/3gpp"

VIDEO_H264

public static final String VIDEO_H264 = "video/avc"

VIDEO_H265

public static final String VIDEO_H265 = "video/hevc"

VIDEO_MATROSKA

@UnstableApi
public static final String VIDEO_MATROSKA = "video/x-matroska"

VIDEO_MJPEG

public static final String VIDEO_MJPEG = "video/mjpeg"

VIDEO_MP2T

public static final String VIDEO_MP2T = "video/mp2t"

VIDEO_MP4

public static final String VIDEO_MP4 = "video/mp4"

VIDEO_MP42

public static final String VIDEO_MP42 = "video/mp42"

VIDEO_MP43

public static final String VIDEO_MP43 = "video/mp43"

VIDEO_MP4V

public static final String VIDEO_MP4V = "video/mp4v-es"

VIDEO_MPEG

public static final String VIDEO_MPEG = "video/mpeg"

VIDEO_MPEG2

public static final String VIDEO_MPEG2 = "video/mpeg2"

VIDEO_MV_HEVC

@UnstableApi
public static final String VIDEO_MV_HEVC = "video/mv-hevc"

VIDEO_OGG

public static final String VIDEO_OGG = "video/ogg"

VIDEO_PS

public static final String VIDEO_PS = "video/mp2p"

VIDEO_RAW

@UnstableApi
public static final String VIDEO_RAW = "video/raw"

VIDEO_UNKNOWN

@UnstableApi
public static final String VIDEO_UNKNOWN = "video/x-unknown"

VIDEO_VC1

public static final String VIDEO_VC1 = "video/wvc1"

VIDEO_VP8

@UnstableApi
public static final String VIDEO_VP8 = "video/x-vnd.on2.vp8"

VIDEO_VP9

@UnstableApi
public static final String VIDEO_VP9 = "video/x-vnd.on2.vp9"

VIDEO_WEBM

public static final String VIDEO_WEBM = "video/webm"

Public methods

allSamplesAreSyncSamples

@UnstableApi
public static boolean allSamplesAreSyncSamples(@Nullable String mimeType, @Nullable String codec)

Returns true if it is known that all samples in a stream of the given MIME type and codec are guaranteed to be sync samples (i.e., BUFFER_FLAG_KEY_FRAME is guaranteed to be set on every sample) and the inherent duration of each sample is negligible (i.e., we never expect to require a sample because playback partially falls into its duration).

Parameters
@Nullable String mimeType

The MIME type of the stream.

@Nullable String codec

The RFC 6381 codec string of the stream, or null if unknown.

Returns
boolean

Whether it is known that all samples in the stream are guaranteed to be sync samples.

containsCodecsCorrespondingToMimeType

@UnstableApi
public static boolean containsCodecsCorrespondingToMimeType(
    @Nullable String codecs,
    String mimeType
)

Returns whether the given codecs string contains a codec which corresponds to the given mimeType.

Parameters
@Nullable String codecs

An RFC 6381 codecs string.

String mimeType

A MIME type to look for.

Returns
boolean

Whether the given codecs string contains a codec which corresponds to the given mimeType.

getAudioMediaMimeType

@UnstableApi
public static @Nullable String getAudioMediaMimeType(@Nullable String codecs)

Returns the first audio MIME type derived from an RFC 6381 codecs string.

Parameters
@Nullable String codecs

An RFC 6381 codecs string.

Returns
@Nullable String

The first derived audio MIME type, or null.

getCodecsCorrespondingToMimeType

@UnstableApi
public static @Nullable String getCodecsCorrespondingToMimeType(
    @Nullable String codecs,
    @Nullable String mimeType
)

Returns a subsequence of codecs containing the codec strings that correspond to the given mimeType. Returns null if mimeType is null, codecs is null, or codecs does not contain a codec that corresponds to mimeType.

Parameters
@Nullable String codecs

An RFC 6381 codecs string.

@Nullable String mimeType

A MIME type to look for.

Returns
@Nullable String

A subsequence of codecs containing the codec strings that correspond to the given mimeType. Returns null if mimeType is null, codecs is null, or codecs does not contain a codec that corresponds to mimeType.

getEncoding

@UnstableApi
@C.Encoding
public static int getEncoding(String mimeType, @Nullable String codec)

Returns the C.Encoding constant corresponding to the specified audio MIME type and RFC 6381 codec string, or ENCODING_INVALID if the corresponding C.Encoding cannot be determined.

Parameters
String mimeType

A MIME type.

@Nullable String codec

An RFC 6381 codec string, or null if unknown or not applicable.

Returns
int

The corresponding C.Encoding, or ENCODING_INVALID.

getMediaMimeType

@UnstableApi
public static @Nullable String getMediaMimeType(@Nullable String codec)

Returns the MIME type corresponding to an RFC 6381 codec string, or null if it could not be determined.

Parameters
@Nullable String codec

An RFC 6381 codec string.

Returns
@Nullable String

The corresponding MIME type, or null if it could not be determined.

getMimeTypeFromMp4ObjectType

@UnstableApi
public static @Nullable String getMimeTypeFromMp4ObjectType(int objectType)

Returns the MIME type corresponding to an MP4 object type identifier, as defined in RFC 6381 and https://mp4ra.org/#/object_types.

Parameters
int objectType

An MP4 object type identifier.

Returns
@Nullable String

The corresponding MIME type, or null if it could not be determined.

getMp4ObjectTypeFromMimeType

@UnstableApi
public static @Nullable Byte getMp4ObjectTypeFromMimeType(String sampleMimeType)

Returns the MP4 object type identifier corresponding to a MIME type, as defined in RFC 6381 and MPEG-4 Object Types.

Parameters
String sampleMimeType

The MIME type of the track.

Returns
@Nullable Byte

The corresponding MP4 object type identifier, or null if it could not be determined.

getTextMediaMimeType

@UnstableApi
public static @Nullable String getTextMediaMimeType(@Nullable String codecs)

Returns the first text MIME type derived from an RFC 6381 codecs string.

Parameters
@Nullable String codecs

An RFC 6381 codecs string.

Returns
@Nullable String

The first derived text MIME type, or null.

getTrackType

@UnstableApi
@C.TrackType
public static int getTrackType(@Nullable String mimeType)

Returns the track type constant corresponding to a specified MIME type, which may be TRACK_TYPE_UNKNOWN if it could not be determined.

Parameters
@Nullable String mimeType

A MIME type.

Returns
int

The corresponding track type, which may be TRACK_TYPE_UNKNOWN if it could not be determined.

getTrackTypeOfCodec

@UnstableApi
@C.TrackType
public static int getTrackTypeOfCodec(String codec)

Equivalent to getTrackType(getMediaMimeType(codec)).

Parameters
String codec

An RFC 6381 codec string.

Returns
int

The corresponding track type, which may be TRACK_TYPE_UNKNOWN if it could not be determined.

getVideoMediaMimeType

@UnstableApi
public static @Nullable String getVideoMediaMimeType(@Nullable String codecs)

Returns the first video MIME type derived from an RFC 6381 codecs string.

Parameters
@Nullable String codecs

An RFC 6381 codecs string.

Returns
@Nullable String

The first derived video MIME type, or null.

isAudio

@UnstableApi
public static boolean isAudio(@Nullable String mimeType)

Returns whether the given string is an audio MIME type.

isImage

@UnstableApi
public static boolean isImage(@Nullable String mimeType)

Returns whether the given string is an image MIME type.

isMatroska

@UnstableApi
public static boolean isMatroska(@Nullable String mimeType)

Returns whether the given mimeType is a Matroska MIME type, including WebM.

isText

@UnstableApi
@Pure
public static boolean isText(@Nullable String mimeType)

Returns whether the given string is a text MIME type, including known text types that use "application" as their base type.

isVideo

@UnstableApi
public static boolean isVideo(@Nullable String mimeType)

Returns whether the given string is a video MIME type.

normalizeMimeType

@UnstableApi
@PolyNull
public static @PolyNull String normalizeMimeType(@PolyNull @PolyNull String mimeType)

Normalizes the MIME type provided so that equivalent MIME types are uniquely represented.

Parameters
@PolyNull @PolyNull String mimeType

A MIME type to normalize, or null.

Returns
@PolyNull String

The normalized MIME type, or the argument MIME type if its normalized form is unknown.

registerCustomMimeType

@UnstableApi
public static void registerCustomMimeType(
    String mimeType,
    String codecPrefix,
    @C.TrackType int trackType
)

Registers a custom MIME type. Most applications do not need to call this method, as handling of standard MIME types is built in. These built-in MIME types take precedence over any registered via this method. If this method is used, it must be called before creating any player(s).

Parameters
String mimeType

The custom MIME type to register.

String codecPrefix

The RFC 6381 codec string prefix associated with the MIME type.

@C.TrackType int trackType

The track type associated with the MIME type. This value is ignored if the top-level type of mimeType is audio, video or text.