# HlsInterstitialsAdsLoader.Listener

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/HlsInterstitialsAdsLoader.java+class:androidx.media3.exoplayer.hls.HlsInterstitialsAdsLoader.Listener)

*** ** * ** ***


```
public interface HlsInterstitialsAdsLoader.Listener
```

<br />

*** ** * ** ***

A listener to be notified of events emitted by the ads loader.

## Summary

| ### Public methods |
|---|---|
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onAdCompleted(androidx.media3.common.MediaItem,java.lang.Object,int,int)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, int adGroupIndex, int adIndexInAdGroup )` Called when an ad period has completed playback and transitioned to the following ad or the content period. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onAdSkipped(androidx.media3.common.MediaItem,java.lang.Object,int,int)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, int adGroupIndex, int adIndexInAdGroup )` Called when an ad period was skipped and transitioned to the following ad or the content period. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onAdStarted(androidx.media3.common.MediaItem,java.lang.Object,int,int)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, int adGroupIndex, int adIndexInAdGroup )` Called when playback of the given ad period has started. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onAssetListLoadCompleted(androidx.media3.common.MediaItem,java.lang.Object,int,int,androidx.media3.exoplayer.hls.HlsInterstitialsAdsLoader.AssetList,org.json.JSONObject)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, int adGroupIndex, int adIndexInAdGroup, https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AssetList assetList, https://developer.android.com/reference/org/json/JSONObject.html rawAssetListJson )` Called when an asset list has completed to load for the given ad. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onAssetListLoadFailed(androidx.media3.common.MediaItem,java.lang.Object,int,int,java.io.IOException,boolean)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, int adGroupIndex, int adIndexInAdGroup, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/io/IOException.html ioException, boolean cancelled )` Called when an asset list has failed to load for the given ad. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onAssetListLoadStarted(androidx.media3.common.MediaItem,java.lang.Object,int,int)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, int adGroupIndex, int adIndexInAdGroup )` Called when the asset list has been started to load for the given ad. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onContentTimelineChanged(androidx.media3.common.MediaItem,java.lang.Object,androidx.media3.common.Timeline)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, https://developer.android.com/reference/androidx/media3/common/Timeline hlsContentTimeline )` Called when the timeline of the content media source has changed. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onMetadata(androidx.media3.common.MediaItem,java.lang.Object,int,int,androidx.media3.common.Metadata)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, int adGroupIndex, int adIndexInAdGroup, https://developer.android.com/reference/androidx/media3/common/Metadata metadata )` Called when `https://developer.android.com/reference/androidx/media3/common/Metadata` is emitted by the player during an ad period of an active HLS media item. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onPrepareCompleted(androidx.media3.common.MediaItem,java.lang.Object,int,int)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, int adGroupIndex, int adIndexInAdGroup )` Called when preparation of an ad period has completed successfully. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onPrepareError(androidx.media3.common.MediaItem,java.lang.Object,int,int,java.io.IOException)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, int adGroupIndex, int adIndexInAdGroup, https://developer.android.com/reference/java/io/IOException.html exception )` Called when preparation of an ad period failed. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onStart(androidx.media3.common.MediaItem,java.lang.Object,androidx.media3.common.AdViewProvider)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, https://developer.android.com/reference/androidx/media3/common/AdViewProvider adViewProvider )` Called when the ads loader was started for the given HLS media item and ads ID. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.Listener#onStop(androidx.media3.common.MediaItem,java.lang.Object,androidx.media3.common.AdPlaybackState)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/java/lang/Object.html adsId, https://developer.android.com/reference/androidx/media3/common/AdPlaybackState adPlaybackState )` Called when the ads loader was stopped for the given HLS media item. |

## Public methods

### onAdCompleted

```
default void onAdCompleted(
    MediaItem mediaItem,
    Object adsId,
    int adGroupIndex,
    int adIndexInAdGroup
)
```

Called when an ad period has completed playback and transitioned to the following ad or the content period.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the content media source. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `int adGroupIndex` | The index of the ad group in the ad media source. |
| `int adIndexInAdGroup` | The index of the ad in the ad group. |

### onAdSkipped

```
default void onAdSkipped(
    MediaItem mediaItem,
    Object adsId,
    int adGroupIndex,
    int adIndexInAdGroup
)
```

Called when an ad period was skipped and transitioned to the following ad or the content period.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the content media source. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `int adGroupIndex` | The index of the ad group in the ad media source. |
| `int adIndexInAdGroup` | The index of the ad in the ad group. |

### onAdStarted

```
default void onAdStarted(
    MediaItem mediaItem,
    Object adsId,
    int adGroupIndex,
    int adIndexInAdGroup
)
```

Called when playback of the given ad period has started.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the content media source. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `int adGroupIndex` | The index of the ad group in the ad media source. |
| `int adIndexInAdGroup` | The index of the ad in the ad group. |

### onAssetListLoadCompleted

```
default void onAssetListLoadCompleted(
    MediaItem mediaItem,
    Object adsId,
    int adGroupIndex,
    int adIndexInAdGroup,
    HlsInterstitialsAdsLoader.AssetList assetList,
    JSONObject rawAssetListJson
)
```

Called when an asset list has completed to load for the given ad.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` with which the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` was created. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `int adGroupIndex` | The index of the ad group of the ad period. |
| `int adIndexInAdGroup` | The index of the ad in the ad group of the ad period. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AssetList assetList` | The `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsInterstitialsAdsLoader.AssetList` for which loading has completed. |
| `https://developer.android.com/reference/org/json/JSONObject.html rawAssetListJson` | The raw JSON response received from the server. |

### onAssetListLoadFailed

```
default void onAssetListLoadFailed(
    MediaItem mediaItem,
    Object adsId,
    int adGroupIndex,
    int adIndexInAdGroup,
    @Nullable IOException ioException,
    boolean cancelled
)
```

Called when an asset list has failed to load for the given ad.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` with which the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` was created. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `int adGroupIndex` | The index of the ad group of the ad period. |
| `int adIndexInAdGroup` | The index of the ad in the ad group of the ad period. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/io/IOException.html ioException` | The exception, may be null if cancelled. |
| `boolean cancelled` | Whether the load was cancelled. |

### onAssetListLoadStarted

```
default void onAssetListLoadStarted(
    MediaItem mediaItem,
    Object adsId,
    int adGroupIndex,
    int adIndexInAdGroup
)
```

Called when the asset list has been started to load for the given ad.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` with which the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` was created. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `int adGroupIndex` | The index of the ad group of the ad period. |
| `int adIndexInAdGroup` | The index of the ad in the ad group of the ad period. |

### onContentTimelineChanged

```
default void onContentTimelineChanged(
    MediaItem mediaItem,
    Object adsId,
    Timeline hlsContentTimeline
)
```

Called when the timeline of the content media source has changed. The `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsManifest` of the content source can be accessed through `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#manifest()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the content media source. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `https://developer.android.com/reference/androidx/media3/common/Timeline hlsContentTimeline` | The latest `https://developer.android.com/reference/androidx/media3/common/Timeline`. |

### onMetadata

```
default void onMetadata(
    MediaItem mediaItem,
    Object adsId,
    int adGroupIndex,
    int adIndexInAdGroup,
    Metadata metadata
)
```

Called when `https://developer.android.com/reference/androidx/media3/common/Metadata` is emitted by the player during an ad period of an active HLS media item.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the content media source. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `int adGroupIndex` | The index of the ad group in the ad media source. |
| `int adIndexInAdGroup` | The index of the ad in the ad group. |
| `https://developer.android.com/reference/androidx/media3/common/Metadata metadata` | The emitted `https://developer.android.com/reference/androidx/media3/common/Metadata`. |

### onPrepareCompleted

```
default void onPrepareCompleted(
    MediaItem mediaItem,
    Object adsId,
    int adGroupIndex,
    int adIndexInAdGroup
)
```

Called when preparation of an ad period has completed successfully.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the content media source. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `int adGroupIndex` | The index of the ad group in the ad media source. |
| `int adIndexInAdGroup` | The index of the ad in the ad group. |

### onPrepareError

```
default void onPrepareError(
    MediaItem mediaItem,
    Object adsId,
    int adGroupIndex,
    int adIndexInAdGroup,
    IOException exception
)
```

Called when preparation of an ad period failed.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the content media source. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `int adGroupIndex` | The index of the ad group in the ad media source. |
| `int adIndexInAdGroup` | The index of the ad in the ad group. |
| `https://developer.android.com/reference/java/io/IOException.html exception` | The `https://developer.android.com/reference/java/io/IOException.html` thrown when preparing. |

### onStart

```
default void onStart(
    MediaItem mediaItem,
    Object adsId,
    AdViewProvider adViewProvider
)
```

Called when the ads loader was started for the given HLS media item and ads ID.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the content media source. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `https://developer.android.com/reference/androidx/media3/common/AdViewProvider adViewProvider` | `https://developer.android.com/reference/androidx/media3/common/AdViewProvider` of views for the ad UI. |

### onStop

```
default void onStop(
    MediaItem mediaItem,
    Object adsId,
    AdPlaybackState adPlaybackState
)
```

Called when the ads loader was stopped for the given HLS media item.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the content media source. |
| `https://developer.android.com/reference/java/lang/Object.html adsId` | The ads identifier (see `https://developer.android.com/reference/androidx/media3/common/MediaItem.AdsConfiguration#adsId()`). |
| `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState adPlaybackState` | The `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState` after the ad media source was released. |