Package com.google.android.exoplayer2.util

## Class MimeTypes

- java.lang.Object
- - com.google.android.exoplayer2.util.MimeTypes

-     public final class MimeTypes
      extends Object

  Defines common MIME types and helper methods.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `APPLICATION_AIT` |
    `static String` | `APPLICATION_CAMERA_MOTION` |
    `static String` | `APPLICATION_CEA608` |
    `static String` | `APPLICATION_CEA708` |
    `static String` | `APPLICATION_DVBSUBS` |
    `static String` | `APPLICATION_EMSG` |
    `static String` | `APPLICATION_EXIF` |
    `static String` | `APPLICATION_ICY` |
    `static String` | `APPLICATION_ID3` |
    `static String` | `APPLICATION_M3U8` |
    `static String` | `APPLICATION_MATROSKA` |
    `static String` | `APPLICATION_MP4` |
    `static String` | `APPLICATION_MP4CEA608` |
    `static String` | `APPLICATION_MP4VTT` |
    `static String` | `APPLICATION_MPD` |
    `static String` | `APPLICATION_PGS` |
    `static String` | `APPLICATION_RAWCC` |
    `static String` | `APPLICATION_RTSP` |
    `static String` | `APPLICATION_SCTE35` |
    `static String` | `APPLICATION_SS` |
    `static String` | `APPLICATION_SUBRIP` |
    `static String` | `APPLICATION_TTML` |
    `static String` | `APPLICATION_TX3G` |
    `static String` | `APPLICATION_VOBSUB` |
    `static String` | `APPLICATION_WEBM` |
    `static String` | `AUDIO_AAC` |
    `static String` | `AUDIO_AC3` |
    `static String` | `AUDIO_AC4` |
    `static String` | `AUDIO_ALAC` |
    `static String` | `AUDIO_ALAW` |
    `static String` | `AUDIO_AMR` |
    `static String` | `AUDIO_AMR_NB` |
    `static String` | `AUDIO_AMR_WB` |
    `static String` | `AUDIO_DTS` |
    `static String` | `AUDIO_DTS_EXPRESS` |
    `static String` | `AUDIO_DTS_HD` |
    `static String` | `AUDIO_E_AC3` |
    `static String` | `AUDIO_E_AC3_JOC` |
    `static String` | `AUDIO_FLAC` |
    `static String` | `AUDIO_MATROSKA` |
    `static String` | `AUDIO_MLAW` |
    `static String` | `AUDIO_MP4` |
    `static String` | `AUDIO_MPEG` |
    `static String` | `AUDIO_MPEG_L1` |
    `static String` | `AUDIO_MPEG_L2` |
    `static String` | `AUDIO_MPEGH_MHA1` |
    `static String` | `AUDIO_MPEGH_MHM1` |
    `static String` | `AUDIO_MSGSM` |
    `static String` | `AUDIO_OGG` |
    `static String` | `AUDIO_OPUS` |
    `static String` | `AUDIO_RAW` |
    `static String` | `AUDIO_TRUEHD` |
    `static String` | `AUDIO_UNKNOWN` |
    `static String` | `AUDIO_VORBIS` |
    `static String` | `AUDIO_WAV` |
    `static String` | `AUDIO_WEBM` |
    `static String` | `BASE_TYPE_APPLICATION` |
    `static String` | `BASE_TYPE_AUDIO` |
    `static String` | `BASE_TYPE_IMAGE` |
    `static String` | `BASE_TYPE_TEXT` |
    `static String` | `BASE_TYPE_VIDEO` |
    `static String` | `IMAGE_JPEG` |
    `static String` | `TEXT_SSA` |
    `static String` | `TEXT_VTT` |
    `static String` | `VIDEO_AV1` |
    `static String` | `VIDEO_DIVX` |
    `static String` | `VIDEO_DOLBY_VISION` |
    `static String` | `VIDEO_FLV` |
    `static String` | `VIDEO_H263` |
    `static String` | `VIDEO_H264` |
    `static String` | `VIDEO_H265` |
    `static String` | `VIDEO_MATROSKA` |
    `static String` | `VIDEO_MP2T` |
    `static String` | `VIDEO_MP4` |
    `static String` | `VIDEO_MP4V` |
    `static String` | `VIDEO_MPEG` |
    `static String` | `VIDEO_MPEG2` |
    `static String` | `VIDEO_OGG` |
    `static String` | `VIDEO_PS` |
    `static String` | `VIDEO_UNKNOWN` |
    `static String` | `VIDEO_VC1` |
    `static String` | `VIDEO_VP8` |
    `static String` | `VIDEO_VP9` |
    `static String` | `VIDEO_WEBM` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static boolean` | `allSamplesAreSyncSamples​(String mimeType, 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., `C.BUFFER_FLAG_KEY_FRAME` is guaranteed to be set on every sample).
    `static boolean` | `containsCodecsCorrespondingToMimeType​(String codecs, String mimeType)` | Returns whether the given `codecs` string contains a codec which corresponds to the given `mimeType`.
    `static String` | `getAudioMediaMimeType​(String codecs)` | Returns the first audio MIME type derived from an RFC 6381 codecs string.
    `static String` | `getCodecsCorrespondingToMimeType​(String codecs, String mimeType)` | Returns a subsequence of `codecs` containing the codec strings that correspond to the given `mimeType`.
    `static int` | `getEncoding​(String mimeType, String codec)` | Returns the `C.Encoding` constant corresponding to the specified audio MIME type and RFC 6381 codec string, or `C.ENCODING_INVALID` if the corresponding `C.Encoding` cannot be determined.
    `static String` | `getMediaMimeType​(String codec)` | Returns the MIME type corresponding to an RFC 6381 codec string, or `null` if it could not be determined.
    `static 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.
    `static String` | `getTextMediaMimeType​(String codecs)` | Returns the first text MIME type derived from an RFC 6381 codecs string.
    `static int` | `getTrackType​(String mimeType)` | Returns the `C``.TRACK_TYPE_*` constant corresponding to a specified MIME type, or `C.TRACK_TYPE_UNKNOWN` if it could not be determined.
    `static int` | `getTrackTypeOfCodec​(String codec)` | Equivalent to `getTrackType(getMediaMimeType(codec))`.
    `static String` | `getVideoMediaMimeType​(String codecs)` | Returns the first video MIME type derived from an RFC 6381 codecs string.
    `static boolean` | `isAudio​(String mimeType)` | Returns whether the given string is an audio MIME type.
    `static boolean` | `isMatroska​(String mimeType)` | Returns whether the given `mimeType` is a Matroska MIME type, including WebM.
    `static boolean` | `isText​(String mimeType)` | Returns whether the given string is a text MIME type, including known text types that use "application" as their base type.
    `static boolean` | `isVideo​(String mimeType)` | Returns whether the given string is a video MIME type.
    `static String` | `normalizeMimeType​(String mimeType)` | Normalizes the MIME type provided so that equivalent MIME types are uniquely represented.
    `static void` | `registerCustomMimeType​(String mimeType, String codecPrefix, int trackType)` | Registers a custom MIME type.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BASE_TYPE_VIDEO

          public static final String BASE_TYPE_VIDEO

      See Also:
        Constant Field Values

    - #### BASE_TYPE_AUDIO

          public static final String BASE_TYPE_AUDIO

      See Also:
        Constant Field Values

    - #### BASE_TYPE_TEXT

          public static final String BASE_TYPE_TEXT

      See Also:
        Constant Field Values

    - #### BASE_TYPE_IMAGE

          public static final String BASE_TYPE_IMAGE

      See Also:
        Constant Field Values

    - #### BASE_TYPE_APPLICATION

          public static final String BASE_TYPE_APPLICATION

      See Also:
        Constant Field Values

    - #### VIDEO_MP4

          public static final String VIDEO_MP4

      See Also:
        Constant Field Values

    - #### VIDEO_MATROSKA

          public static final String VIDEO_MATROSKA

      See Also:
        Constant Field Values

    - #### VIDEO_WEBM

          public static final String VIDEO_WEBM

      See Also:
        Constant Field Values

    - #### VIDEO_H263

          public static final String VIDEO_H263

      See Also:
        Constant Field Values

    - #### VIDEO_H264

          public static final String VIDEO_H264

      See Also:
        Constant Field Values

    - #### VIDEO_H265

          public static final String VIDEO_H265

      See Also:
        Constant Field Values

    - #### VIDEO_VP8

          public static final String VIDEO_VP8

      See Also:
        Constant Field Values

    - #### VIDEO_VP9

          public static final String VIDEO_VP9

      See Also:
        Constant Field Values

    - #### VIDEO_AV1

          public static final String VIDEO_AV1

      See Also:
        Constant Field Values

    - #### VIDEO_MP2T

          public static final String VIDEO_MP2T

      See Also:
        Constant Field Values

    - #### VIDEO_MP4V

          public static final String VIDEO_MP4V

      See Also:
        Constant Field Values

    - #### VIDEO_MPEG

          public static final String VIDEO_MPEG

      See Also:
        Constant Field Values

    - #### VIDEO_PS

          public static final String VIDEO_PS

      See Also:
        Constant Field Values

    - #### VIDEO_MPEG2

          public static final String VIDEO_MPEG2

      See Also:
        Constant Field Values

    - #### VIDEO_VC1

          public static final String VIDEO_VC1

      See Also:
        Constant Field Values

    - #### VIDEO_DIVX

          public static final String VIDEO_DIVX

      See Also:
        Constant Field Values

    - #### VIDEO_FLV

          public static final String VIDEO_FLV

      See Also:
        Constant Field Values

    - #### VIDEO_DOLBY_VISION

          public static final String VIDEO_DOLBY_VISION

      See Also:
        Constant Field Values

    - #### VIDEO_OGG

          public static final String VIDEO_OGG

      See Also:
        Constant Field Values

    - #### VIDEO_UNKNOWN

          public static final String VIDEO_UNKNOWN

      See Also:
        Constant Field Values

    - #### AUDIO_MP4

          public static final String AUDIO_MP4

      See Also:
        Constant Field Values

    - #### AUDIO_AAC

          public static final String AUDIO_AAC

      See Also:
        Constant Field Values

    - #### AUDIO_MATROSKA

          public static final String AUDIO_MATROSKA

      See Also:
        Constant Field Values

    - #### AUDIO_WEBM

          public static final String AUDIO_WEBM

      See Also:
        Constant Field Values

    - #### AUDIO_MPEG

          public static final String AUDIO_MPEG

      See Also:
        Constant Field Values

    - #### AUDIO_MPEG_L1

          public static final String AUDIO_MPEG_L1

      See Also:
        Constant Field Values

    - #### AUDIO_MPEG_L2

          public static final String AUDIO_MPEG_L2

      See Also:
        Constant Field Values

    - #### AUDIO_MPEGH_MHA1

          public static final String AUDIO_MPEGH_MHA1

      See Also:
        Constant Field Values

    - #### AUDIO_MPEGH_MHM1

          public static final String AUDIO_MPEGH_MHM1

      See Also:
        Constant Field Values

    - #### AUDIO_RAW

          public static final String AUDIO_RAW

      See Also:
        Constant Field Values

    - #### AUDIO_ALAW

          public static final String AUDIO_ALAW

      See Also:
        Constant Field Values

    - #### AUDIO_MLAW

          public static final String AUDIO_MLAW

      See Also:
        Constant Field Values

    - #### AUDIO_AC3

          public static final String AUDIO_AC3

      See Also:
        Constant Field Values

    - #### AUDIO_E_AC3

          public static final String AUDIO_E_AC3

      See Also:
        Constant Field Values

    - #### AUDIO_E_AC3_JOC

          public static final String AUDIO_E_AC3_JOC

      See Also:
        Constant Field Values

    - #### AUDIO_AC4

          public static final String AUDIO_AC4

      See Also:
        Constant Field Values

    - #### AUDIO_TRUEHD

          public static final String AUDIO_TRUEHD

      See Also:
        Constant Field Values

    - #### AUDIO_DTS

          public static final String AUDIO_DTS

      See Also:
        Constant Field Values

    - #### AUDIO_DTS_HD

          public static final String AUDIO_DTS_HD

      See Also:
        Constant Field Values

    - #### AUDIO_DTS_EXPRESS

          public static final String AUDIO_DTS_EXPRESS

      See Also:
        Constant Field Values

    - #### AUDIO_VORBIS

          public static final String AUDIO_VORBIS

      See Also:
        Constant Field Values

    - #### AUDIO_OPUS

          public static final String AUDIO_OPUS

      See Also:
        Constant Field Values

    - #### AUDIO_AMR

          public static final String AUDIO_AMR

      See Also:
        Constant Field Values

    - #### AUDIO_AMR_NB

          public static final String AUDIO_AMR_NB

      See Also:
        Constant Field Values

    - #### AUDIO_AMR_WB

          public static final String AUDIO_AMR_WB

      See Also:
        Constant Field Values

    - #### AUDIO_FLAC

          public static final String AUDIO_FLAC

      See Also:
        Constant Field Values

    - #### AUDIO_ALAC

          public static final String AUDIO_ALAC

      See Also:
        Constant Field Values

    - #### AUDIO_MSGSM

          public static final String AUDIO_MSGSM

      See Also:
        Constant Field Values

    - #### AUDIO_OGG

          public static final String AUDIO_OGG

      See Also:
        Constant Field Values

    - #### AUDIO_WAV

          public static final String AUDIO_WAV

      See Also:
        Constant Field Values

    - #### AUDIO_UNKNOWN

          public static final String AUDIO_UNKNOWN

      See Also:
        Constant Field Values

    - #### TEXT_VTT

          public static final String TEXT_VTT

      See Also:
        Constant Field Values

    - #### TEXT_SSA

          public static final String TEXT_SSA

      See Also:
        Constant Field Values

    - #### APPLICATION_MP4

          public static final String APPLICATION_MP4

      See Also:
        Constant Field Values

    - #### APPLICATION_WEBM

          public static final String APPLICATION_WEBM

      See Also:
        Constant Field Values

    - #### APPLICATION_MATROSKA

          public static final String APPLICATION_MATROSKA

      See Also:
        Constant Field Values

    - #### APPLICATION_MPD

          public static final String APPLICATION_MPD

      See Also:
        Constant Field Values

    - #### APPLICATION_M3U8

          public static final String APPLICATION_M3U8

      See Also:
        Constant Field Values

    - #### APPLICATION_SS

          public static final String APPLICATION_SS

      See Also:
        Constant Field Values

    - #### APPLICATION_ID3

          public static final String APPLICATION_ID3

      See Also:
        Constant Field Values

    - #### APPLICATION_CEA608

          public static final String APPLICATION_CEA608

      See Also:
        Constant Field Values

    - #### APPLICATION_CEA708

          public static final String APPLICATION_CEA708

      See Also:
        Constant Field Values

    - #### APPLICATION_SUBRIP

          public static final String APPLICATION_SUBRIP

      See Also:
        Constant Field Values

    - #### APPLICATION_TTML

          public static final String APPLICATION_TTML

      See Also:
        Constant Field Values

    - #### APPLICATION_TX3G

          public static final String APPLICATION_TX3G

      See Also:
        Constant Field Values

    - #### APPLICATION_MP4VTT

          public static final String APPLICATION_MP4VTT

      See Also:
        Constant Field Values

    - #### APPLICATION_MP4CEA608

          public static final String APPLICATION_MP4CEA608

      See Also:
        Constant Field Values

    - #### APPLICATION_RAWCC

          public static final String APPLICATION_RAWCC

      See Also:
        Constant Field Values

    - #### APPLICATION_VOBSUB

          public static final String APPLICATION_VOBSUB

      See Also:
        Constant Field Values

    - #### APPLICATION_PGS

          public static final String APPLICATION_PGS

      See Also:
        Constant Field Values

    - #### APPLICATION_SCTE35

          public static final String APPLICATION_SCTE35

      See Also:
        Constant Field Values

    - #### APPLICATION_CAMERA_MOTION

          public static final String APPLICATION_CAMERA_MOTION

      See Also:
        Constant Field Values

    - #### APPLICATION_EMSG

          public static final String APPLICATION_EMSG

      See Also:
        Constant Field Values

    - #### APPLICATION_DVBSUBS

          public static final String APPLICATION_DVBSUBS

      See Also:
        Constant Field Values

    - #### APPLICATION_EXIF

          public static final String APPLICATION_EXIF

      See Also:
        Constant Field Values

    - #### APPLICATION_ICY

          public static final String APPLICATION_ICY

      See Also:
        Constant Field Values

    - #### APPLICATION_AIT

          public static final String APPLICATION_AIT

      See Also:
        Constant Field Values

    - #### APPLICATION_RTSP

          public static final String APPLICATION_RTSP

      See Also:
        Constant Field Values

    - #### IMAGE_JPEG

          public static final String IMAGE_JPEG

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### registerCustomMimeType

          public static void registerCustomMimeType​(String mimeType,
                                                    String codecPrefix,
                                                    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:
        `mimeType` - The custom MIME type to register.
        `codecPrefix` - The RFC 6381 codec string prefix associated with the MIME type.
        `trackType` - The `C``.TRACK_TYPE_*` constant associated with the MIME type. This value is ignored if the top-level type of `mimeType` is audio, video or text.

    - #### isAudio

          public static boolean isAudio​(@Nullable
                                        String mimeType)

      Returns whether the given string is an audio MIME type.

    - #### isVideo

          public static boolean isVideo​(@Nullable
                                        String mimeType)

      Returns whether the given string is a video MIME type.

    - #### isText

          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.

    - #### allSamplesAreSyncSamples

          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., `C.BUFFER_FLAG_KEY_FRAME` is guaranteed to be set on every sample).
      Parameters:
        `mimeType` - The MIME type of the stream.
        `codec` - The RFC 6381 codec string of the stream, or `null` if unknown.
      Returns:
        Whether it is known that all samples in the stream are guaranteed to be sync samples.

    - #### getVideoMediaMimeType

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

      Returns the first video MIME type derived from an RFC 6381 codecs string.
      Parameters:
        `codecs` - An RFC 6381 codecs string.
      Returns:
        The first derived video MIME type, or `null`.

    - #### containsCodecsCorrespondingToMimeType

          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:
        `codecs` - An RFC 6381 codecs string.
        `mimeType` - A MIME type to look for.
      Returns:
        Whether the given `codecs` string contains a codec which corresponds to the given `mimeType`.

    - #### getCodecsCorrespondingToMimeType

          @Nullable
          public static 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:
        `codecs` - An RFC 6381 codecs string.
        `mimeType` - A MIME type to look for.
      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`.

    - #### getAudioMediaMimeType

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

      Returns the first audio MIME type derived from an RFC 6381 codecs string.
      Parameters:
        `codecs` - An RFC 6381 codecs string.
      Returns:
        The first derived audio MIME type, or `null`.

    - #### getTextMediaMimeType

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

      Returns the first text MIME type derived from an RFC 6381 codecs string.
      Parameters:
        `codecs` - An RFC 6381 codecs string.
      Returns:
        The first derived text MIME type, or `null`.

    - #### getMediaMimeType

          @Nullable
          public static 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:
        `codec` - An RFC 6381 codec string.
      Returns:
        The corresponding MIME type, or `null` if it could not be determined.

    - #### getMimeTypeFromMp4ObjectType

          @Nullable
          public static 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:
        `objectType` - An MP4 object type identifier.
      Returns:
        The corresponding MIME type, or `null` if it could not be determined.

    - #### getTrackType

          public static int getTrackType​(@Nullable
                                         String mimeType)

      Returns the `C``.TRACK_TYPE_*` constant corresponding to a specified MIME type, or `C.TRACK_TYPE_UNKNOWN` if it could not be determined.
      Parameters:
        `mimeType` - A MIME type.
      Returns:
        The corresponding `C``.TRACK_TYPE_*`, or `C.TRACK_TYPE_UNKNOWN` if it could not be determined.

    - #### getEncoding

          @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 `C.ENCODING_INVALID` if the corresponding `C.Encoding` cannot be determined.
      Parameters:
        `mimeType` - A MIME type.
        `codec` - An RFC 6381 codec string, or `null` if unknown or not applicable.
      Returns:
        The corresponding `C.Encoding`, or `C.ENCODING_INVALID`.

    - #### getTrackTypeOfCodec

          public static int getTrackTypeOfCodec​(String codec)

      Equivalent to `getTrackType(getMediaMimeType(codec))`.
      Parameters:
        `codec` - An RFC 6381 codec string.
      Returns:
        The corresponding `C``.TRACK_TYPE_*`, or `C.TRACK_TYPE_UNKNOWN` if it could not be determined.

    - #### normalizeMimeType

          public static String normalizeMimeType​(String mimeType)

      Normalizes the MIME type provided so that equivalent MIME types are uniquely represented.
      Parameters:
        `mimeType` - A MIME type to normalize.
      Returns:
        The normalized MIME type, or the argument MIME type if its normalized form is unknown.

    - #### isMatroska

          public static boolean isMatroska​(@Nullable
                                           String mimeType)

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