Use the content URI as well as mediaId for the auto-generated ad ID
MediaItem.mediaId used to default to the content URI, but this changed:
cc26a92e07
Before the mediaId change linked above, a playlist of different content
all with the same ad URI would play the ads for every item. After the
change the ad would only play once (because mediaId == "" for every
item, so they're all the same). This change restores roughly the
original behaviour by always considering both mediaId and the content
URI.
Issue: #9106
PiperOrigin-RevId: 382763618
This commit is contained in:
parent
306b2e6d2e
commit
278593f0c8
@ -35,6 +35,10 @@
|
|||||||
([#9004](https://github.com/google/ExoPlayer/issues/9004)).
|
([#9004](https://github.com/google/ExoPlayer/issues/9004)).
|
||||||
* Forward the FRAME-RATE value from the master playlist to renditions.
|
* Forward the FRAME-RATE value from the master playlist to renditions.
|
||||||
([#8960](https://github.com/google/ExoPlayer/issues/8960)).
|
([#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:
|
* DRM:
|
||||||
* Allow repeated provisioning in `DefaultDrmSession(Manager)`.
|
* Allow repeated provisioning in `DefaultDrmSession(Manager)`.
|
||||||
* Metadata:
|
* Metadata:
|
||||||
|
@ -67,12 +67,12 @@ described below.
|
|||||||
### Playlists with ads ###
|
### Playlists with ads ###
|
||||||
|
|
||||||
When playing a [playlist][] with multiple media items, the default behavior is
|
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
|
to request the ad tag and store ad playback state once for each media ID,
|
||||||
tag URI combination. This means that users will see ads for every media item
|
content URI and ad tag URI combination. This means that users will see ads for
|
||||||
with ads that has a distinct media ID, even if the ad tag URIs match. If a
|
every media item with ads that has a distinct media ID or content URI, even if
|
||||||
media item is repeated, the user will see the corresponding ads only once (the
|
the ad tag URIs match. If a media item is repeated, the user will see the
|
||||||
ad playback state stores whether ads have been played, so they are skipped
|
corresponding ads only once (the ad playback state stores whether ads have been
|
||||||
after their first occurrence).
|
played, so they are skipped after their first occurrence).
|
||||||
|
|
||||||
It's possible to customize this behavior by passing an opaque ads identifier
|
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
|
with which ad playback state for a given media item is linked, based on object
|
||||||
|
@ -18,7 +18,6 @@ package com.google.android.exoplayer2.source;
|
|||||||
import static com.google.android.exoplayer2.util.Util.castNonNull;
|
import static com.google.android.exoplayer2.util.Util.castNonNull;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Pair;
|
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.C;
|
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.Log;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -427,7 +427,8 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||||||
new DataSpec(adsConfiguration.adTagUri),
|
new DataSpec(adsConfiguration.adTagUri),
|
||||||
/* adsId= */ adsConfiguration.adsId != null
|
/* adsId= */ adsConfiguration.adsId != null
|
||||||
? adsConfiguration.adsId
|
? adsConfiguration.adsId
|
||||||
: Pair.create(mediaItem.mediaId, adsConfiguration.adTagUri),
|
: ImmutableList.of(
|
||||||
|
mediaItem.mediaId, mediaItem.playbackProperties.uri, adsConfiguration.adTagUri),
|
||||||
/* adMediaSourceFactory= */ this,
|
/* adMediaSourceFactory= */ this,
|
||||||
adsLoader,
|
adsLoader,
|
||||||
adViewProvider);
|
adViewProvider);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user