# DefaultHlsPlaylistTracker

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

*** ** * ** ***


```
@UnstableApi
public final class DefaultHlsPlaylistTracker implements HlsPlaylistTracker, Loader.Callback<ParsingLoadable<HlsPlaylist>>
```

<br />

*** ** * ** ***

Default implementation for `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker`.

## Summary

| ### Constants |
|---|---|
| `static final double` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#DEFAULT_PLAYLIST_STUCK_TARGET_DURATION_COEFFICIENT() = 3.5` Default coefficient applied on the target duration of a playlist to determine the amount of time after which an unchanging playlist is considered stuck. |
| `static final https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker.Factory` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#FACTORY()` Factory for `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker` instances. |

| ### Public fields |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsContentSteeringTracker` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#contentSteeringTracker()` |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#initialStartTimeUs()` |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#isLive()` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMultivariantPlaylist` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#multivariantPlaylist()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#DefaultHlsPlaylistTracker(androidx.media3.exoplayer.hls.HlsDataSourceFactory,androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy,androidx.media3.exoplayer.hls.playlist.HlsPlaylistParserFactory,androidx.media3.exoplayer.upstream.CmcdConfiguration,com.google.common.base.Supplier<androidx.media3.exoplayer.util.ReleasableExecutor>)( https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsDataSourceFactory dataSourceFactory, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy loadErrorHandlingPolicy, https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistParserFactory playlistParserFactory, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration cmcdConfiguration, @https://developer.android.com/reference/androidx/annotation/Nullable https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<https://developer.android.com/reference/androidx/media3/exoplayer/util/ReleasableExecutor> downloadExecutorSupplier )` Creates an instance. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#DefaultHlsPlaylistTracker(androidx.media3.exoplayer.hls.HlsDataSourceFactory,androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy,androidx.media3.exoplayer.hls.playlist.HlsPlaylistParserFactory,androidx.media3.exoplayer.upstream.CmcdConfiguration,double,com.google.common.base.Supplier<androidx.media3.exoplayer.util.ReleasableExecutor>)( https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsDataSourceFactory dataSourceFactory, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy loadErrorHandlingPolicy, https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistParserFactory playlistParserFactory, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration cmcdConfiguration, double playlistStuckTargetDurationCoefficient, @https://developer.android.com/reference/androidx/annotation/Nullable https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<https://developer.android.com/reference/androidx/media3/exoplayer/util/ReleasableExecutor> downloadExecutorSupplier )` Creates an instance. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#addListener(androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker.PlaylistEventListener)(https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker.PlaylistEventListener listener)` Registers a listener to receive events from the playlist tracker. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#deactivatePlaylistForPlayback(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html url)` Deactivate the playlist for playback. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#excludeMediaPlaylist(android.net.Uri,long)(https://developer.android.com/reference/android/net/Uri.html playlistUrl, long exclusionDurationMs)` Excludes the given media playlist for the given duration, in milliseconds. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsContentSteeringTracker` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#getContentSteeringTracker()()` Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsContentSteeringTracker`. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#getInitialStartTimeUs()()` Returns the start time of the first loaded primary playlist, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if no media playlist has been loaded. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMultivariantPlaylist` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#getMultivariantPlaylist()()` Returns the multivariant playlist. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#getPlaylistSnapshot(android.net.Uri,boolean)(https://developer.android.com/reference/android/net/Uri.html url, boolean isForPlayback)` Returns the most recent snapshot available of the playlist referenced by the provided `https://developer.android.com/reference/android/net/Uri.html`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#getRedundantGroup(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html playlistUrl)` Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup` where the `playlistUrl` belongs. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup>` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#getRedundantGroups(int)(@https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup.Type int type)` Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup` list corresponding to the `type`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#isExcluded(android.net.Uri,long)(https://developer.android.com/reference/android/net/Uri.html playlistUrl, long nowMs)` Returns whether the `playlistUrl` is excluded at the given `nowMs` time. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#isExcluded(androidx.media3.exoplayer.hls.playlist.HlsRedundantGroup,long)(https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup redundantGroup, long nowMs)` Returns whether all playlist URLs in the `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup` are `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker#isExcluded(android.net.Uri,long)` at the given `nowMs` time. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#isLive()()` Returns whether the tracked playlists describe a live stream. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#isSnapshotValid(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html url)` Returns whether the snapshot of the playlist referenced by the provided `https://developer.android.com/reference/android/net/Uri.html` is valid, meaning all the segments referenced by the playlist are expected to be available. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#maybeThrowPlaylistRefreshError(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html url)` If the playlist is having trouble refreshing the playlist referenced by the given `https://developer.android.com/reference/android/net/Uri.html`, this method throws the underlying error. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#maybeThrowPrimaryPlaylistRefreshError()()` If the tracker is having trouble refreshing the multivariant playlist or the primary playlist, this method throws the underlying error. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#onLoadCanceled(androidx.media3.exoplayer.upstream.ParsingLoadable<androidx.media3.exoplayer.hls.playlist.HlsPlaylist>,long,long,boolean)( https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released )` Called when a load has been canceled. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#onLoadCompleted(androidx.media3.exoplayer.upstream.ParsingLoadable<androidx.media3.exoplayer.hls.playlist.HlsPlaylist>,long,long)( https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs )` Called when a load has completed. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.LoadErrorAction` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#onLoadError(androidx.media3.exoplayer.upstream.ParsingLoadable<androidx.media3.exoplayer.hls.playlist.HlsPlaylist>,long,long,java.io.IOException,int)( https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs, https://developer.android.com/reference/java/io/IOException.html error, int errorCount )` Called when a load encounters an error. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#onLoadStarted(androidx.media3.exoplayer.upstream.ParsingLoadable<androidx.media3.exoplayer.hls.playlist.HlsPlaylist>,long,long,int)( https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs, int retryCount )` Called when a load has started for the first time or through a retry. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#refreshPlaylist(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html url)` Requests a playlist refresh and removes it from the exclusion list. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#removeListener(androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker.PlaylistEventListener)(https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker.PlaylistEventListener listener)` Unregisters a listener. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#start(android.net.Uri,androidx.media3.exoplayer.source.MediaSourceEventListener.EventDispatcher,androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker.PrimaryPlaylistListener,androidx.media3.exoplayer.upstream.BandwidthMeter)( https://developer.android.com/reference/android/net/Uri.html initialPlaylistUri, https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher eventDispatcher, https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker.PrimaryPlaylistListener primaryPlaylistListener, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter bandwidthMeter )` Starts the playlist tracker. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#stop()()` Stops the playlist tracker and releases any acquired resources. |

## Constants

### DEFAULT_PLAYLIST_STUCK_TARGET_DURATION_COEFFICIENT

```
public static final double DEFAULT_PLAYLIST_STUCK_TARGET_DURATION_COEFFICIENT = 3.5
```

Default coefficient applied on the target duration of a playlist to determine the amount of time after which an unchanging playlist is considered stuck.

### FACTORY

```
public static final HlsPlaylistTracker.Factory FACTORY
```

Factory for `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker` instances.

## Public fields

### contentSteeringTracker

```
public @Nullable HlsContentSteeringTracker contentSteeringTracker
```

### initialStartTimeUs

```
public long initialStartTimeUs
```

### isLive

```
public boolean isLive
```

### multivariantPlaylist

```
public @Nullable HlsMultivariantPlaylist multivariantPlaylist
```

## Public constructors

### DefaultHlsPlaylistTracker

```
public DefaultHlsPlaylistTracker(
    HlsDataSourceFactory dataSourceFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    HlsPlaylistParserFactory playlistParserFactory,
    @Nullable CmcdConfiguration cmcdConfiguration,
    @Nullable Supplier<ReleasableExecutor> downloadExecutorSupplier
)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsDataSourceFactory dataSourceFactory` | A factory for `https://developer.android.com/reference/androidx/media3/datasource/DataSource` instances. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy loadErrorHandlingPolicy` | The `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistParserFactory playlistParserFactory` | An `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistParserFactory`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration cmcdConfiguration` | The `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<https://developer.android.com/reference/androidx/media3/exoplayer/util/ReleasableExecutor> downloadExecutorSupplier` | A supplier for a `https://developer.android.com/reference/androidx/media3/exoplayer/util/ReleasableExecutor` that is used for loading the playlist. |

### DefaultHlsPlaylistTracker

```
public DefaultHlsPlaylistTracker(
    HlsDataSourceFactory dataSourceFactory,
    LoadErrorHandlingPolicy loadErrorHandlingPolicy,
    HlsPlaylistParserFactory playlistParserFactory,
    @Nullable CmcdConfiguration cmcdConfiguration,
    double playlistStuckTargetDurationCoefficient,
    @Nullable Supplier<ReleasableExecutor> downloadExecutorSupplier
)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsDataSourceFactory dataSourceFactory` | A factory for `https://developer.android.com/reference/androidx/media3/datasource/DataSource` instances. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy loadErrorHandlingPolicy` | The `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/LoadErrorHandlingPolicy`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistParserFactory playlistParserFactory` | An `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistParserFactory`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration cmcdConfiguration` | The `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/CmcdConfiguration`. |
| `double playlistStuckTargetDurationCoefficient` | A coefficient to apply to the target duration of media playlists in order to determine that a non-changing playlist is stuck. Once a playlist is deemed stuck, a `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker.PlaylistStuckException` is thrown via `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/DefaultHlsPlaylistTracker#maybeThrowPlaylistRefreshError(android.net.Uri)`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<https://developer.android.com/reference/androidx/media3/exoplayer/util/ReleasableExecutor> downloadExecutorSupplier` | A supplier for a `https://developer.android.com/reference/androidx/media3/exoplayer/util/ReleasableExecutor` that is used for loading the playlist. |

## Public methods

### addListener

```
public void addListener(HlsPlaylistTracker.PlaylistEventListener listener)
```

Registers a listener to receive events from the playlist tracker.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker.PlaylistEventListener listener` | The listener. |

### deactivatePlaylistForPlayback

```
public void deactivatePlaylistForPlayback(Uri url)
```

Deactivate the playlist for playback.

The default implementation is a no-op.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html url` | The `https://developer.android.com/reference/android/net/Uri.html` of the playlist to deactivate for playback. |

### excludeMediaPlaylist

```
public boolean excludeMediaPlaylist(Uri playlistUrl, long exclusionDurationMs)
```

Excludes the given media playlist for the given duration, in milliseconds.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html playlistUrl` | The URL of the media playlist. |
| `long exclusionDurationMs` | The duration for which to exclude the playlist. |

| Returns |
|---|---|
| `boolean` | Whether exclusion was successful. |

### getContentSteeringTracker

```
public @Nullable HlsContentSteeringTracker getContentSteeringTracker()
```

Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsContentSteeringTracker`.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsContentSteeringTracker` | The `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsContentSteeringTracker`. Null if the initial playlist has yet to be loaded, or no information for content steering is declared in the initial playlist. |

### getInitialStartTimeUs

```
public long getInitialStartTimeUs()
```

Returns the start time of the first loaded primary playlist, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if no media playlist has been loaded.

### getMultivariantPlaylist

```
public @Nullable HlsMultivariantPlaylist getMultivariantPlaylist()
```

Returns the multivariant playlist.

If the uri passed to `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker#start(android.net.Uri,androidx.media3.exoplayer.source.MediaSourceEventListener.EventDispatcher,androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker.PrimaryPlaylistListener,androidx.media3.exoplayer.upstream.BandwidthMeter)` points to a media playlist, an `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMultivariantPlaylist` with a single variant for said media playlist is returned.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMultivariantPlaylist` | The multivariant playlist. Null if the initial playlist has yet to be loaded. |

### getPlaylistSnapshot

```
public @Nullable HlsMediaPlaylist getPlaylistSnapshot(Uri url, boolean isForPlayback)
```

Returns the most recent snapshot available of the playlist referenced by the provided `https://developer.android.com/reference/android/net/Uri.html`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html url` | The `https://developer.android.com/reference/android/net/Uri.html` corresponding to the requested media playlist. |
| `boolean isForPlayback` | Whether the caller might use the snapshot to request media segments for playback. If true, the primary playlist may be updated to the one requested. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist` | The most recent snapshot of the playlist referenced by the provided `https://developer.android.com/reference/android/net/Uri.html`. May be null if no snapshot has been loaded yet. |

### getRedundantGroup

```
public @Nullable HlsRedundantGroup getRedundantGroup(Uri playlistUrl)
```

Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup` where the `playlistUrl` belongs.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html playlistUrl` | The URL of the media playlist. |

### getRedundantGroups

```
public @Nullable ImmutableList<HlsRedundantGroup> getRedundantGroups(@HlsRedundantGroup.Type int type)
```

Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup` list corresponding to the `type`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup.Type int type` | The type of the requested `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup>` | The list of requested `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup`. Null if the initial playlist has yet to be loaded. |

### isExcluded

```
public boolean isExcluded(Uri playlistUrl, long nowMs)
```

Returns whether the `playlistUrl` is excluded at the given `nowMs` time.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html playlistUrl` | The URL of the media playlist. |
| `long nowMs` | The current value of `https://developer.android.com/reference/androidx/media3/common/util/SystemClock#elapsedRealtime()`. |

### isExcluded

```
public boolean isExcluded(HlsRedundantGroup redundantGroup, long nowMs)
```

Returns whether all playlist URLs in the `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup` are `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker#isExcluded(android.net.Uri,long)` at the given `nowMs` time.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup redundantGroup` | The `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsRedundantGroup`. |
| `long nowMs` | The current value of `https://developer.android.com/reference/androidx/media3/common/util/SystemClock#elapsedRealtime()`. |

### isLive

```
public boolean isLive()
```

Returns whether the tracked playlists describe a live stream.

| Returns |
|---|---|
| `boolean` | True if the content is live. False otherwise. |

### isSnapshotValid

```
public boolean isSnapshotValid(Uri url)
```

Returns whether the snapshot of the playlist referenced by the provided `https://developer.android.com/reference/android/net/Uri.html` is valid, meaning all the segments referenced by the playlist are expected to be available. If the playlist is not valid then some of the segments may no longer be available.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html url` | The `https://developer.android.com/reference/android/net/Uri.html`. |

| Returns |
|---|---|
| `boolean` | Whether the snapshot of the playlist referenced by the provided `https://developer.android.com/reference/android/net/Uri.html` is valid. |

### maybeThrowPlaylistRefreshError

```
public void maybeThrowPlaylistRefreshError(Uri url)
```

If the playlist is having trouble refreshing the playlist referenced by the given `https://developer.android.com/reference/android/net/Uri.html`, this method throws the underlying error.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html url` | The `https://developer.android.com/reference/android/net/Uri.html`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | The underlying error. |

### maybeThrowPrimaryPlaylistRefreshError

```
public void maybeThrowPrimaryPlaylistRefreshError()
```

If the tracker is having trouble refreshing the multivariant playlist or the primary playlist, this method throws the underlying error. Otherwise, does nothing.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | The underlying error. |

### onLoadCanceled

```
public void onLoadCanceled(
    ParsingLoadable<HlsPlaylist> loadable,
    long elapsedRealtimeMs,
    long loadDurationMs,
    boolean released
)
```

Called when a load has been canceled.

Note: If the `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader` has not been released then there is guaranteed to be a memory barrier between `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` exiting and this callback being called. If the `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader` has been released then this callback may be called before `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` exits.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylist> loadable` | The loadable whose load has been canceled. |
| `long elapsedRealtimeMs` | `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` when the load was canceled. |
| `long loadDurationMs` | The duration in milliseconds of the load since `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#startLoading(T,androidx.media3.exoplayer.upstream.Loader.Callback<T>,int)` was called up to the point at which it was canceled. |
| `boolean released` | True if the load was canceled because the `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader` was released. False otherwise. |

### onLoadCompleted

```
public void onLoadCompleted(
    ParsingLoadable<HlsPlaylist> loadable,
    long elapsedRealtimeMs,
    long loadDurationMs
)
```

Called when a load has completed.

Note: There is guaranteed to be a memory barrier between `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` exiting and this callback being called.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylist> loadable` | The loadable whose load has completed. |
| `long elapsedRealtimeMs` | `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` when the load ended. |
| `long loadDurationMs` | The duration in milliseconds of the load since `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#startLoading(T,androidx.media3.exoplayer.upstream.Loader.Callback<T>,int)` was called. |

### onLoadError

```
public Loader.LoadErrorAction onLoadError(
    ParsingLoadable<HlsPlaylist> loadable,
    long elapsedRealtimeMs,
    long loadDurationMs,
    IOException error,
    int errorCount
)
```

Called when a load encounters an error.

Note: There is guaranteed to be a memory barrier between `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.Loadable#load()` exiting and this callback being called.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylist> loadable` | The loadable whose load has encountered an error. |
| `long elapsedRealtimeMs` | `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` when the error occurred. |
| `long loadDurationMs` | The duration in milliseconds of the load since `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#startLoading(T,androidx.media3.exoplayer.upstream.Loader.Callback<T>,int)` was called up to the point at which the error occurred. |
| `https://developer.android.com/reference/java/io/IOException.html error` | The load error. |
| `int errorCount` | The number of errors this load has encountered, including this one. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader.LoadErrorAction` | The desired error handling action. One of `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#RETRY()`, `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#RETRY_RESET_ERROR_COUNT()`, `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#DONT_RETRY()`, `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#DONT_RETRY_FATAL()` or a retry action created by `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#createRetryAction(boolean,long)`. |

### onLoadStarted

```
public void onLoadStarted(
    ParsingLoadable<HlsPlaylist> loadable,
    long elapsedRealtimeMs,
    long loadDurationMs,
    int retryCount
)
```

Called when a load has started for the first time or through a retry.

This is called for the first time with `retryCount == 0` just **before** the load is started.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylist> loadable` | The loadable whose load has started. |
| `long elapsedRealtimeMs` | `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` when the load attempts to start. |
| `long loadDurationMs` | The duration in milliseconds of the load since `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#startLoading(T,androidx.media3.exoplayer.upstream.Loader.Callback<T>,int)` was called. |
| `int retryCount` | The number of failed attempts since `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Loader#startLoading(T,androidx.media3.exoplayer.upstream.Loader.Callback<T>,int)` was called (this is zero for the first load attempt). |

### refreshPlaylist

```
public void refreshPlaylist(Uri url)
```

Requests a playlist refresh and removes it from the exclusion list.

The playlist tracker may choose to delay the playlist refresh. The request is discarded if a refresh was already pending.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html url` | The `https://developer.android.com/reference/android/net/Uri.html` of the playlist to be refreshed. |

### removeListener

```
public void removeListener(HlsPlaylistTracker.PlaylistEventListener listener)
```

Unregisters a listener.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker.PlaylistEventListener listener` | The listener to unregister. |

### start

```
public void start(
    Uri initialPlaylistUri,
    MediaSourceEventListener.EventDispatcher eventDispatcher,
    HlsPlaylistTracker.PrimaryPlaylistListener primaryPlaylistListener,
    BandwidthMeter bandwidthMeter
)
```

Starts the playlist tracker.

Must be called from the playback thread. A tracker may be restarted after a `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker#stop()` call.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html initialPlaylistUri` | Uri of the HLS stream. Can point to a media playlist or a multivariant playlist. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher eventDispatcher` | A dispatcher to notify of events. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker.PrimaryPlaylistListener primaryPlaylistListener` | A callback for the primary playlist change events. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter bandwidthMeter` | A `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter`. |

### stop

```
public void stop()
```

Stops the playlist tracker and releases any acquired resources.

Must be called once per `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsPlaylistTracker#start(android.net.Uri,androidx.media3.exoplayer.source.MediaSourceEventListener.EventDispatcher,androidx.media3.exoplayer.hls.playlist.HlsPlaylistTracker.PrimaryPlaylistListener,androidx.media3.exoplayer.upstream.BandwidthMeter)` call.