# FileTypes

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/FileTypes.java+class:androidx.media3.common.FileTypes)

*** ** * ** ***


```
@UnstableApi
public final class FileTypes
```

<br />

*** ** * ** ***

Defines common file type constants and helper methods.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/androidx/media3/common/FileTypes.Type` File types. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#AC3() = 0` File type for the AC-3 and E-AC-3 formats. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#AC4() = 1` File type for the AC-4 format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#ADTS() = 2` File type for the ADTS format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#AMR() = 3` File type for the AMR format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#AVI() = 16` File type for the AVI format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#AVIF() = 21` File type for the AVIF format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#BMP() = 19` File type for the BMP format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#FLAC() = 4` File type for the FLAC format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#FLV() = 5` File type for the FLV format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#HEIF() = 20` File type for the HEIF format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#JPEG() = 14` File type for the JPEG format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#MATROSKA() = 6` File type for the Matroska and WebM formats. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#MIDI() = 15` File type for the MIDI format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#MP3() = 7` File type for the MP3 format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#MP4() = 8` File type for the MP4 format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#OGG() = 9` File type for the Ogg format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#PNG() = 17` File type for the PNG format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#PS() = 10` File type for the MPEG-PS format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#TS() = 11` File type for the MPEG-TS format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#UNKNOWN() = -1` Unknown file type. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#WAV() = 12` File type for the WAV format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#WEBP() = 18` File type for the WEBP format. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/FileTypes#WEBVTT() = 13` File type for the WebVTT format. |

| ### Public methods |
|---|---|
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/FileTypes.Type https://developer.android.com/reference/androidx/media3/common/FileTypes#inferFileTypeFromMimeType(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html mimeType)` Returns the `https://developer.android.com/reference/androidx/media3/common/FileTypes.Type` corresponding to the MIME type provided. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/FileTypes.Type https://developer.android.com/reference/androidx/media3/common/FileTypes#inferFileTypeFromResponseHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>>)( https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>> responseHeaders )` Returns the `https://developer.android.com/reference/androidx/media3/common/FileTypes.Type` corresponding to the response headers provided. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/FileTypes.Type https://developer.android.com/reference/androidx/media3/common/FileTypes#inferFileTypeFromUri(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html uri)` Returns the `https://developer.android.com/reference/androidx/media3/common/FileTypes.Type` corresponding to the `https://developer.android.com/reference/android/net/Uri.html` provided. |

## Constants

### AC3

```
public static final int AC3 = 0
```

File type for the AC-3 and E-AC-3 formats.

### AC4

```
public static final int AC4 = 1
```

File type for the AC-4 format.

### ADTS

```
public static final int ADTS = 2
```

File type for the ADTS format.

### AMR

```
public static final int AMR = 3
```

File type for the AMR format.

### AVI

```
public static final int AVI = 16
```

File type for the AVI format.

### AVIF

```
public static final int AVIF = 21
```

File type for the AVIF format.

### BMP

```
public static final int BMP = 19
```

File type for the BMP format.

### FLAC

```
public static final int FLAC = 4
```

File type for the FLAC format.

### FLV

```
public static final int FLV = 5
```

File type for the FLV format.

### HEIF

```
public static final int HEIF = 20
```

File type for the HEIF format.

### JPEG

```
public static final int JPEG = 14
```

File type for the JPEG format.

### MATROSKA

```
public static final int MATROSKA = 6
```

File type for the Matroska and WebM formats.

### MIDI

```
public static final int MIDI = 15
```

File type for the MIDI format.

### MP3

```
public static final int MP3 = 7
```

File type for the MP3 format.

### MP4

```
public static final int MP4 = 8
```

File type for the MP4 format.

### OGG

```
public static final int OGG = 9
```

File type for the Ogg format.

### PNG

```
public static final int PNG = 17
```

File type for the PNG format.

### PS

```
public static final int PS = 10
```

File type for the MPEG-PS format.

### TS

```
public static final int TS = 11
```

File type for the MPEG-TS format.

### UNKNOWN

```
public static final int UNKNOWN = -1
```

Unknown file type.

### WAV

```
public static final int WAV = 12
```

File type for the WAV format.

### WEBP

```
public static final int WEBP = 18
```

File type for the WEBP format.

### WEBVTT

```
public static final int WEBVTT = 13
```

File type for the WebVTT format.

## Public methods

### inferFileTypeFromMimeType

```
@FileTypes.Type
public static int inferFileTypeFromMimeType(@Nullable String mimeType)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/FileTypes.Type` corresponding to the MIME type provided.

Returns `https://developer.android.com/reference/androidx/media3/common/FileTypes#UNKNOWN()` if the MIME type is `null`.

### inferFileTypeFromResponseHeaders

```
@FileTypes.Type
public static int inferFileTypeFromResponseHeaders(
    Map<String, List<String>> responseHeaders
)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/FileTypes.Type` corresponding to the response headers provided.

### inferFileTypeFromUri

```
@FileTypes.Type
public static int inferFileTypeFromUri(Uri uri)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/FileTypes.Type` corresponding to the `https://developer.android.com/reference/android/net/Uri.html` provided.