Class MimeTypes


  • @Deprecated
    public final class MimeTypes
    extends Object
    Deprecated.
    com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
    Defines common MIME types and helper methods.
    • Method Detail

      • registerCustomMimeType

        public static void registerCustomMimeType​(String mimeType,
                                                  String codecPrefix,
                                                  @com.google.android.exoplayer2.C.TrackType int trackType)
        Deprecated.
        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 track type 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)
        Deprecated.
        Returns whether the given string is an audio MIME type.
      • isVideo

        public static boolean isVideo​(@Nullable
                                      String mimeType)
        Deprecated.
        Returns whether the given string is a video MIME type.
      • isText

        public static boolean isText​(@Nullable
                                     String mimeType)
        Deprecated.
        Returns whether the given string is a text MIME type, including known text types that use "application" as their base type.
      • isImage

        public static boolean isImage​(@Nullable
                                      String mimeType)
        Deprecated.
        Returns whether the given string is an image MIME type.
      • allSamplesAreSyncSamples

        public static boolean allSamplesAreSyncSamples​(@Nullable
                                                       String mimeType,
                                                       @Nullable
                                                       String codec)
        Deprecated.
        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)
        Deprecated.
        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)
        Deprecated.
        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)
        Deprecated.
        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)
        Deprecated.
        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)
        Deprecated.
        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)
        Deprecated.
        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)
        Deprecated.
        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 @com.google.android.exoplayer2.C.TrackType int getTrackType​(@Nullable
                                                                                  String mimeType)
        Deprecated.
        Returns the track type constant corresponding to a specified MIME type, which may be C.TRACK_TYPE_UNKNOWN if it could not be determined.
        Parameters:
        mimeType - A MIME type.
        Returns:
        The corresponding track type, which may be C.TRACK_TYPE_UNKNOWN if it could not be determined.
      • getEncoding

        public static @com.google.android.exoplayer2.C.Encoding int getEncoding​(String mimeType,
                                                                                @Nullable
                                                                                String codec)
        Deprecated.
        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 @com.google.android.exoplayer2.C.TrackType int getTrackTypeOfCodec​(String codec)
        Deprecated.
        Equivalent to getTrackType(getMediaMimeType(codec)).
        Parameters:
        codec - An RFC 6381 codec string.
        Returns:
        The corresponding track type, which may be C.TRACK_TYPE_UNKNOWN if it could not be determined.
      • normalizeMimeType

        public static String normalizeMimeType​(String mimeType)
        Deprecated.
        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)
        Deprecated.
        Returns whether the given mimeType is a Matroska MIME type, including WebM.