# 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
public final class ParsingLoadable<T> implements Loader.Loadable
```

<br />

*** ** * ** ***

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

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

## Summary

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

| ### Public fields |
|---|---|
| `final https://developer.android.com/reference/androidx/media3/datasource/DataSpec` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#dataSpec()` The `https://developer.android.com/reference/androidx/media3/datasource/DataSpec` that defines the data to be loaded. |
| `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#loadTaskId()` Identifies the load task for this loadable. |
| `volatile @https://developer.android.com/reference/androidx/annotation/Nullable T` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#result()` |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#steeredPathwayId()` The ID of the steered pathway from which data is being loaded, or `null` if not applicable. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/C.DataType https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#type()` The `https://developer.android.com/reference/androidx/media3/common/C.DataType` of the data. |

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

| ### Public methods |
|---|---|
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#bytesLoaded()()` Returns the number of bytes loaded. |
| `final void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#cancelLoad()()` Cancels the load. |
| `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>>` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#getResponseHeaders()()` Returns the response headers associated with the load. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable T` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#getResult()()` Returns the loaded object, or null if an object has not been loaded. |
| `https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#getUri()()` Returns the `https://developer.android.com/reference/android/net/Uri.html` from which data was read. |
| `final void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#load()()` Performs the load, returning on completion or cancellation. |
| `static T` | `<T> https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#load(androidx.media3.datasource.DataSource,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<? extends T>,androidx.media3.datasource.DataSpec,int)( https://developer.android.com/reference/androidx/media3/datasource/DataSource dataSource, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T> parser, https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec, @https://developer.android.com/reference/androidx/media3/common/C.DataType int type )` Loads a single parsable object. |
| `static T` | `<T> https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable#load(androidx.media3.datasource.DataSource,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<? extends T>,android.net.Uri,int)( https://developer.android.com/reference/androidx/media3/datasource/DataSource dataSource, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T> parser, https://developer.android.com/reference/android/net/Uri.html uri, @https://developer.android.com/reference/androidx/media3/common/C.DataType int type )` Loads a single parsable object. |

## Public fields

### dataSpec

```
public final DataSpec dataSpec
```

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

### loadTaskId

```
public final long loadTaskId
```

Identifies the load task for this loadable.

### result

```
volatile public @Nullable T result
```

### steeredPathwayId

```
public final @Nullable String steeredPathwayId
```

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

### type

```
@C.DataType
public final int type
```

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

## Public constructors

### ParsingLoadable

```
public [ParsingLoadable](https://developer.android.com/reference/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 int type,
    ParsingLoadable.Parser<T> parser
)
```

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

### ParsingLoadable

```
public [ParsingLoadable](https://developer.android.com/reference/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 int type,
    ParsingLoadable.Parser<T> parser
)
```

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

## Public methods

### bytesLoaded

```
public long bytesLoaded()
```

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

```
public final void cancelLoad()
```

Cancels the load.

Loadable implementations should ensure that a currently executing `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` call will exit reasonably quickly after this method is called. The `https://developer.android.com/reference/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/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/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

```
public Map<String, List<String>> getResponseHeaders()
```

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

### getResult

```
public final @Nullable T getResult()
```

Returns the loaded object, or null if an object has not been loaded.

### getUri

```
public Uri getUri()
```

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

```
public final void load()
```

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

```
public static T <T> load(
    DataSource dataSource,
    ParsingLoadable.Parser<T> parser,
    DataSpec dataSpec,
    @C.DataType int type
)
```

Loads a single parsable object.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/datasource/DataSource dataSource` | The `https://developer.android.com/reference/androidx/media3/datasource/DataSource` through which the object should be read. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T> parser` | The `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser` to parse the object from the response. |
| `https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec` | The `https://developer.android.com/reference/androidx/media3/datasource/DataSpec` of the object to read. |
| `@https://developer.android.com/reference/androidx/media3/common/C.DataType int type` | The `https://developer.android.com/reference/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

```
public static T <T> load(
    DataSource dataSource,
    ParsingLoadable.Parser<T> parser,
    Uri uri,
    @C.DataType int type
)
```

Loads a single parsable object.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/datasource/DataSource dataSource` | The `https://developer.android.com/reference/androidx/media3/datasource/DataSource` through which the object should be read. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<T> parser` | The `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser` to parse the object from the response. |
| `https://developer.android.com/reference/android/net/Uri.html uri` | The `https://developer.android.com/reference/android/net/Uri.html` of the object to read. |
| `@https://developer.android.com/reference/androidx/media3/common/C.DataType int type` | The `https://developer.android.com/reference/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. |