Add replaceAdTagParameters() to ImaServerSideAdInsertion.AdsLoader.
PiperOrigin-RevId: 627114711
This commit is contained in:
parent
7aed9d40a0
commit
a43ffa8898
@ -35,6 +35,9 @@
|
||||
* Promote API that is required for apps to play
|
||||
[DAI ad streams](https://developers.google.com/ad-manager/dynamic-ad-insertion/full-service)
|
||||
to stable.
|
||||
* Add `replaceAdTagParameters(Map <String, String>)` to
|
||||
`ImaServerSideAdInsertionMediaSource.AdLoader` that allows replacing ad
|
||||
tag parameters at runtime.
|
||||
* Session:
|
||||
* Hide seekbar in the media notification for live streams by not setting
|
||||
the duration into the platform session metadata
|
||||
|
1
api.txt
1
api.txt
@ -1393,6 +1393,7 @@ package androidx.media3.exoplayer.ima {
|
||||
|
||||
public static final class ImaServerSideAdInsertionMediaSource.AdsLoader {
|
||||
method public androidx.media3.exoplayer.ima.ImaServerSideAdInsertionMediaSource.AdsLoader.State release();
|
||||
method public void replaceAdTagParameters(java.util.Map<java.lang.String,java.lang.String>);
|
||||
method public void setPlayer(androidx.media3.common.Player);
|
||||
}
|
||||
|
||||
|
@ -472,6 +472,36 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all the ad tag parameters used for the upcoming ad requests for a live stream.
|
||||
*
|
||||
* @see StreamManager#replaceAdTagParameters(Map<String, String>)
|
||||
*/
|
||||
public void replaceAdTagParameters(Map<String, String> adTagParameters) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
if (player.getPlaybackState() != Player.STATE_IDLE
|
||||
&& player.getPlaybackState() != Player.STATE_ENDED
|
||||
&& player.getMediaItemCount() > 0) {
|
||||
int currentPeriodIndex = player.getCurrentPeriodIndex();
|
||||
Object adsId =
|
||||
player
|
||||
.getCurrentTimeline()
|
||||
.getPeriod(currentPeriodIndex, new Timeline.Period())
|
||||
.getAdsId();
|
||||
if (adsId instanceof String) {
|
||||
MediaSourceResourceHolder mediaSourceResourceHolder = mediaSourceResources.get(adsId);
|
||||
if (mediaSourceResourceHolder != null
|
||||
&& mediaSourceResourceHolder.imaServerSideAdInsertionMediaSource.streamManager
|
||||
!= null) {
|
||||
mediaSourceResourceHolder.imaServerSideAdInsertionMediaSource.streamManager
|
||||
.replaceAdTagParameters(adTagParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the focus on the skip button, if a skip button is present and an ad is playing.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user