diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 75011909e0..9011ac21bd 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -35,6 +35,10 @@ ([#9004](https://github.com/google/ExoPlayer/issues/9004)). * Forward the FRAME-RATE value from the master playlist to renditions. ([#8960](https://github.com/google/ExoPlayer/issues/8960)). +* Ad playback: + * Use the content URI when auto-generating an ad ID (in addition to the + media ID and ad tag URI) + ([#9106](https://github.com/google/ExoPlayer/issues/9106). * DRM: * Allow repeated provisioning in `DefaultDrmSession(Manager)`. * Metadata: diff --git a/docs/ad-insertion.md b/docs/ad-insertion.md index 8ca6e00ba7..972f07a9c5 100644 --- a/docs/ad-insertion.md +++ b/docs/ad-insertion.md @@ -67,12 +67,12 @@ described below. ### Playlists with ads ### When playing a [playlist][] with multiple media items, the default behavior is -to request the ad tag and store ad playback state once for each media ID and ad -tag URI combination. This means that users will see ads for every media item -with ads that has a distinct media ID, even if the ad tag URIs match. If a -media item is repeated, the user will see the corresponding ads only once (the -ad playback state stores whether ads have been played, so they are skipped -after their first occurrence). +to request the ad tag and store ad playback state once for each media ID, +content URI and ad tag URI combination. This means that users will see ads for +every media item with ads that has a distinct media ID or content URI, even if +the ad tag URIs match. If a media item is repeated, the user will see the +corresponding ads only once (the ad playback state stores whether ads have been +played, so they are skipped after their first occurrence). It's possible to customize this behavior by passing an opaque ads identifier with which ad playback state for a given media item is linked, based on object diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java index a7bd656294..0f5554401a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java @@ -18,7 +18,6 @@ package com.google.android.exoplayer2.source; import static com.google.android.exoplayer2.util.Util.castNonNull; import android.content.Context; -import android.util.Pair; import android.util.SparseArray; import androidx.annotation.Nullable; import com.google.android.exoplayer2.C; @@ -40,6 +39,7 @@ import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.Util; +import com.google.common.collect.ImmutableList; import java.util.Arrays; import java.util.List; @@ -427,7 +427,8 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { new DataSpec(adsConfiguration.adTagUri), /* adsId= */ adsConfiguration.adsId != null ? adsConfiguration.adsId - : Pair.create(mediaItem.mediaId, adsConfiguration.adTagUri), + : ImmutableList.of( + mediaItem.mediaId, mediaItem.playbackProperties.uri, adsConfiguration.adTagUri), /* adMediaSourceFactory= */ this, adsLoader, adViewProvider);