# ParsingLoadable

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

*** ** * ** ***


```
@UnstableApi
class ParsingLoadable<T> : Loader.Loadable
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader.Loadable` for objects that can be parsed from binary data using a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser`.

| Parameters |
|---|---|
| `<T>` | The type of the object being loaded. |

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Builder<T>` Builder for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable`. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T>` Parses an object from loaded data. |

| ### Public constructors |
|---|
| `[ParsingLoadable](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#ParsingLoadable(androidx.media3.datasource.DataSource,androidx.media3.datasource.DataSpec,int,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<? extends T>))( dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, dataSpec: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!, @https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, parser: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T!>! )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Builder` instead. <br /> |
| `[ParsingLoadable](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#ParsingLoadable(androidx.media3.datasource.DataSource,android.net.Uri,int,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<? extends T>))( dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, uri: https://developer.android.com/reference/android/net/Uri.html!, @https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, parser: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T!>! )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Builder` instead. <br /> |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#bytesLoaded()()` Returns the number of bytes loaded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#cancelLoad()()` Cancels the load. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#getResponseHeaders()()` Returns the response headers associated with the load. |
| `https://developer.android.com/reference/android/net/Uri.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#getUri()()` Returns the `https://developer.android.com/reference/android/net/Uri.html` from which data was read. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#load()()` Performs the load, returning on completion or cancellation. |
| `java-static T!` | `<T> https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#load(androidx.media3.datasource.DataSource,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<? extends T>,androidx.media3.datasource.DataSpec,int)( dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, parser: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T!>!, dataSpec: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!, @https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Loads a single parsable object. |
| `java-static T!` | `<T> https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#load(androidx.media3.datasource.DataSource,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<? extends T>,android.net.Uri,int)( dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, parser: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T!>!, uri: https://developer.android.com/reference/android/net/Uri.html!, @https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Loads a single parsable object. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#dataSpec()` The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec` that defines the data to be loaded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#loadTaskId()` Identifies the load task for this loadable. |
| `volatile T?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#result()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#steeredPathwayId()` The ID of the steered pathway from which data is being loaded, or `null` if not applicable. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#type()` The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType` of the data. |

## Public constructors

### ParsingLoadable

```
[ParsingLoadable](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#ParsingLoadable(androidx.media3.datasource.DataSource,androidx.media3.datasource.DataSpec,int,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<? extends T>))(
    dataSource: DataSource!,
    dataSpec: DataSpec!,
    @C.DataType type: Int,
    parser: ParsingLoadable.Parser<T!>!
)
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Builder` instead.

### ParsingLoadable

```
[ParsingLoadable](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable#ParsingLoadable(androidx.media3.datasource.DataSource,android.net.Uri,int,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<? extends T>))(
    dataSource: DataSource!,
    uri: Uri!,
    @C.DataType type: Int,
    parser: ParsingLoadable.Parser<T!>!
)
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Builder` instead.

## Public functions

### bytesLoaded

```
fun bytesLoaded(): Long
```

Returns the number of bytes loaded. In the case that the network response was compressed, the value returned is the size of the data *after* decompression. Must only be called after the load completed, failed, or was canceled.

### cancelLoad

```
fun cancelLoad(): Unit
```

Cancels the load.

Loadable implementations should ensure that a currently executing `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` call will exit reasonably quickly after this method is called. The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` call may exit either by returning or by throwing an `https://developer.android.com/reference/java/io/IOException.html`.

If there is a currently executing `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` call, then the thread on which that call is being made will be interrupted immediately after the call to this method. Hence implementations do not need to (and should not attempt to) interrupt the loading thread themselves.

Although the loading thread will be interrupted, Loadable implementations should not use the interrupted status of the loading thread in `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` to determine whether the load has been canceled. This approach is not robust \[Internal ref: b/79223737\]. Instead, implementations should use their own flag to signal cancelation (for example, using `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicBoolean.html`).

### getResponseHeaders

```
fun getResponseHeaders(): (Mutable)Map<String!, (Mutable)List<String!>!>!
```

Returns the response headers associated with the load. Must only be called after the load completed, failed, or was canceled.

### getUri

```
fun getUri(): Uri!
```

Returns the `https://developer.android.com/reference/android/net/Uri.html` from which data was read. If redirection occurred, this is the redirected uri. Must only be called after the load completed, failed, or was canceled.

### load

```
fun load(): Unit
```

Performs the load, returning on completion or cancellation.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If the input could not be loaded. |

### load

```
java-static fun <T> load(
    dataSource: DataSource!,
    parser: ParsingLoadable.Parser<T!>!,
    dataSpec: DataSpec!,
    @C.DataType type: Int
): T!
```

Loads a single parsable object.

| Parameters |
|---|---|
| `dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!` | The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` through which the object should be read. |
| `parser: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T!>!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser` to parse the object from the response. |
| `dataSpec: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec` of the object to read. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType` of the data. |

| Returns |
|---|---|
| `T!` | The parsed object |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | Thrown if there is an error while loading or parsing. |

### load

```
java-static fun <T> load(
    dataSource: DataSource!,
    parser: ParsingLoadable.Parser<T!>!,
    uri: Uri!,
    @C.DataType type: Int
): T!
```

Loads a single parsable object.

| Parameters |
|---|---|
| `dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!` | The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` through which the object should be read. |
| `parser: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T!>!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser` to parse the object from the response. |
| `uri: https://developer.android.com/reference/android/net/Uri.html!` | The `https://developer.android.com/reference/android/net/Uri.html` of the object to read. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType` of the data. |

| Returns |
|---|---|
| `T!` | The parsed object |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | Thrown if there is an error while loading or parsing. |

## Public properties

### dataSpec

```
val dataSpec: DataSpec!
```

The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec` that defines the data to be loaded.

### loadTaskId

```
val loadTaskId: Long
```

Identifies the load task for this loadable.

### result

```
volatile val result: T?
```

### steeredPathwayId

```
val steeredPathwayId: String?
```

The ID of the steered pathway from which data is being loaded, or `null` if not applicable.

### type

```
@C.DataType
val type: Int
```

The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.DataType` of the data. For reporting only.