# 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
class FlacMetadataReader
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacMetadataReader#checkAndPeekStreamMarker(androidx.media3.extractor.ExtractorInput)(input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!)` Peeks the FLAC stream marker. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacMetadataReader#getFrameStartMarker(androidx.media3.extractor.ExtractorInput)(input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!)` Returns the frame start marker, consisting of the 2 first bytes of the first frame. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/Metadata?` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacMetadataReader#peekId3Metadata(androidx.media3.extractor.ExtractorInput,boolean,boolean)( input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!, parseData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, ignoreArtwork: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Peeks ID3 Data. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/Metadata?` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacMetadataReader#readId3Metadata(androidx.media3.extractor.ExtractorInput,boolean,boolean)( input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!, parseData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, ignoreArtwork: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Reads ID3 Data. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacMetadataReader#readMetadataBlock(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.FlacMetadataReader.FlacStreamMetadataHolder,boolean)( input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!, metadataHolder: https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacMetadataReader.FlacStreamMetadataHolder!, ignoreArtwork: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Reads one FLAC metadata block. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacStreamMetadata.SeekTable!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacMetadataReader#readSeekTableMetadataBlock(androidx.media3.common.util.ParsableByteArray)(data: https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray!)` Reads a FLAC seek table metadata block. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacMetadataReader#readStreamMarker(androidx.media3.extractor.ExtractorInput)(input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!)` Reads the FLAC stream marker. |

## Public functions

### checkAndPeekStreamMarker

```
java-static fun checkAndPeekStreamMarker(input: ExtractorInput!): Boolean
```

Peeks the FLAC stream marker.

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | 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

```
java-static fun getFrameStartMarker(input: ExtractorInput!): Int
```

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 |
|---|---|
| `input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!` | Input stream to get the start marker from (starting from the read position). |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The frame start marker (which must be the same for all the frames in the stream). |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/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

```
java-static fun peekId3Metadata(
    input: ExtractorInput!,
    parseData: Boolean,
    ignoreArtwork: Boolean
): Metadata?
```

Peeks ID3 Data.

| Parameters |
|---|---|
| `input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!` | Input stream to peek the ID3 data from. |
| `parseData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to parse the ID3 frames. |
| `ignoreArtwork: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to ignore artwork metadata. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/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

```
java-static fun readId3Metadata(
    input: ExtractorInput!,
    parseData: Boolean,
    ignoreArtwork: Boolean
): Metadata?
```

Reads ID3 Data.

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

| Parameters |
|---|---|
| `input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!` | Input stream to read the ID3 data from. |
| `parseData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to parse the ID3 frames. |
| `ignoreArtwork: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to ignore artwork metadata. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/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

```
java-static fun readMetadataBlock(
    input: ExtractorInput!,
    metadataHolder: FlacMetadataReader.FlacStreamMetadataHolder!,
    ignoreArtwork: Boolean
): Boolean
```

Reads one FLAC metadata block.

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

| Parameters |
|---|---|
| `input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!` | Input stream to read the metadata block from (header included). |
| `metadataHolder: https://developer.android.com/reference/kotlin/androidx/media3/extractor/FlacMetadataReader.FlacStreamMetadataHolder!` | 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. |
| `ignoreArtwork: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to ignore artwork metadata blocks. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | 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

```
java-static fun readSeekTableMetadataBlock(data: ParsableByteArray!): FlacStreamMetadata.SeekTable!
```

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 |
|---|---|
| `data: https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray!` | 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/kotlin/androidx/media3/extractor/FlacStreamMetadata.SeekTable!` | The seek table, without the placeholder points. |

### readStreamMarker

```
java-static fun readStreamMarker(input: ExtractorInput!): Unit
```

Reads the FLAC stream marker.

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

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/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/kotlin/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. |