# FlacMetadataReader

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

*** ** * ** ***


```
@UnstableApi
public final class FlacMetadataReader
```

<br />

*** ** * ** ***

Reads and peeks FLAC stream metadata elements according to RFC 9639.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader.FlacStreamMetadataHolder` Holds a `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata`. |

| ### Public methods |
|---|---|
| `static boolean` | `https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader#checkAndPeekStreamMarker(androidx.media3.extractor.ExtractorInput)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input)` Peeks the FLAC stream marker. |
| `static int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader#getFrameStartMarker(androidx.media3.extractor.ExtractorInput)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input)` Returns the frame start marker, consisting of the 2 first bytes of the first frame. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Metadata` | `https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader#peekId3Metadata(androidx.media3.extractor.ExtractorInput,boolean,boolean)( https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input, boolean parseData, boolean ignoreArtwork )` Peeks ID3 Data. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Metadata` | `https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader#readId3Metadata(androidx.media3.extractor.ExtractorInput,boolean,boolean)( https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input, boolean parseData, boolean ignoreArtwork )` Reads ID3 Data. |
| `static boolean` | `https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader#readMetadataBlock(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder,boolean)( https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input, https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader.FlacStreamMetadataHolder metadataHolder, boolean ignoreArtwork )` Reads one FLAC metadata block. |
| `static https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata.SeekTable` | `https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader#readSeekTableMetadataBlock(androidx.media3.common.util.ParsableByteArray)(https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray data)` Reads a FLAC seek table metadata block. |
| `static void` | `https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader#readStreamMarker(androidx.media3.extractor.ExtractorInput)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input)` Reads the FLAC stream marker. |

## Public methods

### checkAndPeekStreamMarker

```
public static boolean checkAndPeekStreamMarker(ExtractorInput input)
```

Peeks the FLAC stream marker.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | Input stream to peek the stream marker from. |

| Returns |
|---|---|
| `boolean` | Whether the data peeked is the FLAC stream marker. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If peeking from the input fails. In this case, the peek position is left unchanged. |

### getFrameStartMarker

```
public static int getFrameStartMarker(ExtractorInput input)
```

Returns the frame start marker, consisting of the 2 first bytes of the first frame.

The read position of `input` is left unchanged and the peek position is aligned with the read position.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | Input stream to get the start marker from (starting from the read position). |

| Returns |
|---|---|
| `int` | The frame start marker (which must be the same for all the frames in the stream). |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/ParserException` | If an error occurs parsing the frame start marker. |
| `https://developer.android.com/reference/java/io/IOException.html` | If peeking from the input fails. |

### peekId3Metadata

```
public static @Nullable Metadata peekId3Metadata(
    ExtractorInput input,
    boolean parseData,
    boolean ignoreArtwork
)
```

Peeks ID3 Data.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | Input stream to peek the ID3 data from. |
| `boolean parseData` | Whether to parse the ID3 frames. |
| `boolean ignoreArtwork` | Whether to ignore artwork metadata. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Metadata` | The parsed ID3 data, or `null` if there is no such data or if `parseData` is `false`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If peeking from the input fails. In this case, there is no guarantee on the peek position. |

### readId3Metadata

```
public static @Nullable Metadata readId3Metadata(
    ExtractorInput input,
    boolean parseData,
    boolean ignoreArtwork
)
```

Reads ID3 Data.

If no exception is thrown, the peek position of `input` is aligned with the read position.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | Input stream to read the ID3 data from. |
| `boolean parseData` | Whether to parse the ID3 frames. |
| `boolean ignoreArtwork` | Whether to ignore artwork metadata. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Metadata` | The parsed ID3 data, or `null` if there is no such data or if `parseData` is `false`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If reading from the input fails. In this case, the read position is left unchanged and there is no guarantee on the peek position. |

### readMetadataBlock

```
public static boolean readMetadataBlock(
    ExtractorInput input,
    FlacMetadataReader.FlacStreamMetadataHolder metadataHolder,
    boolean ignoreArtwork
)
```

Reads one FLAC metadata block.

If no exception is thrown, the peek position of `input` is aligned with the read position.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | Input stream to read the metadata block from (header included). |
| `https://developer.android.com/reference/androidx/media3/extractor/FlacMetadataReader.FlacStreamMetadataHolder metadataHolder` | A holder for the metadata read. If the stream info block (which must be the first metadata block) is read, the holder contains a new instance representing the stream info data. If the block read is a Vorbis comment block or a picture block, the holder contains a copy of the existing stream metadata with the corresponding metadata added. Otherwise, the metadata in the holder is unchanged. |
| `boolean ignoreArtwork` | Whether to ignore artwork metadata blocks. |

| Returns |
|---|---|
| `boolean` | Whether the block read is the last metadata block. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the block read is not a stream info block and the metadata in `metadataHolder` is `null`. In this case, the read position will be at the start of a metadata block and there is no guarantee on the peek position. |
| `https://developer.android.com/reference/java/io/IOException.html` | If reading from the input fails. In this case, the read position will be at the start of a metadata block and there is no guarantee on the peek position. |

### readSeekTableMetadataBlock

```
public static FlacStreamMetadata.SeekTable readSeekTableMetadataBlock(ParsableByteArray data)
```

Reads a FLAC seek table metadata block.

The position of `data` is moved to the byte following the seek table metadata block (placeholder points included).

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray data` | The array to read the data from, whose position must correspond to the seek table metadata block (header included). |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata.SeekTable` | The seek table, without the placeholder points. |

### readStreamMarker

```
public static void readStreamMarker(ExtractorInput input)
```

Reads the FLAC stream marker.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | Input stream to read the stream marker from. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/ParserException` | If an error occurs parsing the stream marker. In this case, the position of `input` is advanced by `https://developer.android.com/reference/androidx/media3/extractor/flac/FlacConstants#STREAM_MARKER_SIZE()` bytes. |
| `https://developer.android.com/reference/java/io/IOException.html` | If reading from the input fails. In this case, the position is left unchanged. |