docs/doc/reference/com/google/android/exoplayer2/source/ads/ServerSideAdInsertionUtil.html
Package com.google.android.exoplayer2.source.ads
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classServerSideAdInsertionUtilextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
A static utility class with methods to work with server-side inserted ads.
All Methods Static Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| static AdPlaybackState | addAdGroupToAdPlaybackState(AdPlaybackState adPlaybackState, long fromPositionUs, long contentResumeOffsetUs, long... adDurationsUs) |
Deprecated.
Adds a new server-side inserted ad group to an AdPlaybackState.
|
| static int | getAdCountInGroup(AdPlaybackState adPlaybackState, int adGroupIndex) |
Deprecated.
Returns the number of ads in an ad group, treating an unknown number as zero ads.
|
| static long | getMediaPeriodPositionUs(long positionUs, MediaPeriodId mediaPeriodId, AdPlaybackState adPlaybackState) |
Deprecated.
Returns the position in a MediaPeriod for a position in the underlying server-side inserted ads stream.
|
| static long | getMediaPeriodPositionUsForAd(long positionUs, int adGroupIndex, int adIndexInAdGroup, AdPlaybackState adPlaybackState) |
Deprecated.
Returns the position in an ad MediaPeriod for a position in the underlying server-side inserted ads stream.
|
| static long | getMediaPeriodPositionUsForContent(long positionUs, int nextAdGroupIndex, AdPlaybackState adPlaybackState) |
Deprecated.
Returns the position in a content MediaPeriod for a position in the underlying server-side inserted ads stream.
|
| static long | getStreamPositionUs(long positionUs, MediaPeriodId mediaPeriodId, AdPlaybackState adPlaybackState) |
Deprecated.
Returns the position in the underlying server-side inserted ads stream for a position in a MediaPeriod.
|
| static long | getStreamPositionUs(Player player, AdPlaybackState adPlaybackState) |
Deprecated.
Returns the position in the underlying server-side inserted ads stream for the current playback position in the Player.
|
| static long | getStreamPositionUsForAd(long positionUs, int adGroupIndex, int adIndexInAdGroup, AdPlaybackState adPlaybackState) |
Deprecated.
Returns the position in the underlying server-side inserted ads stream for a position in an ad MediaPeriod.
|
| static long | getStreamPositionUsForContent(long positionUs, int nextAdGroupIndex, AdPlaybackState adPlaybackState) |
Deprecated.
Returns the position in the underlying server-side inserted ads stream for a position in a content MediaPeriod.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
@CheckResult
public static[AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")addAdGroupToAdPlaybackState([AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")adPlaybackState,
long fromPositionUs,
long contentResumeOffsetUs,
long... adDurationsUs)
Deprecated.
Adds a new server-side inserted ad group to an AdPlaybackState.
If the first ad with a non-zero duration is not the first ad in the group, all ads before that ad are marked as skipped.
Parameters:adPlaybackState - The existing AdPlaybackState.fromPositionUs - The position in the underlying server-side inserted ads stream at which the ad group starts, in microseconds.contentResumeOffsetUs - The timestamp offset which should be added to the content stream when resuming playback after the ad group. An offset of 0 collapses the ad group to a single insertion point, an offset of toPositionUs-fromPositionUs keeps the original stream timestamps after the ad group.adDurationsUs - The durations of the ads to be added to the group, in microseconds.Returns:The updated AdPlaybackState.
-
public static long getStreamPositionUs([Player](../../Player.html "interface in com.google.android.exoplayer2")player,[AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")adPlaybackState)
Deprecated.
Returns the position in the underlying server-side inserted ads stream for the current playback position in the Player.
Parameters:player - The Player.adPlaybackState - The AdPlaybackState defining the ad groups.Returns:The position in the underlying server-side inserted ads stream, in microseconds, or C.TIME_UNSET if it can't be determined.
-
public static long getStreamPositionUs(long positionUs,[MediaPeriodId](../MediaPeriodId.html "class in com.google.android.exoplayer2.source")mediaPeriodId,[AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")adPlaybackState)
Deprecated.
Returns the position in the underlying server-side inserted ads stream for a position in a MediaPeriod.
Parameters:positionUs - The position in the MediaPeriod, in microseconds.mediaPeriodId - The MediaPeriodId of the MediaPeriod.adPlaybackState - The AdPlaybackState defining the ad groups.Returns:The position in the underlying server-side inserted ads stream, in microseconds.
-
public static long getMediaPeriodPositionUs(long positionUs,[MediaPeriodId](../MediaPeriodId.html "class in com.google.android.exoplayer2.source")mediaPeriodId,[AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")adPlaybackState)
Deprecated.
Returns the position in a MediaPeriod for a position in the underlying server-side inserted ads stream.
Parameters:positionUs - The position in the underlying server-side inserted ads stream, in microseconds.mediaPeriodId - The MediaPeriodId of the MediaPeriod.adPlaybackState - The AdPlaybackState defining the ad groups.Returns:The position in the MediaPeriod, in microseconds.
-
public static long getStreamPositionUsForAd(long positionUs,
int adGroupIndex,
int adIndexInAdGroup,[AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")adPlaybackState)
Deprecated.
Returns the position in the underlying server-side inserted ads stream for a position in an ad MediaPeriod.
Parameters:positionUs - The position in the ad MediaPeriod, in microseconds.adGroupIndex - The ad group index of the ad.adIndexInAdGroup - The index of the ad in the ad group.adPlaybackState - The AdPlaybackState defining the ad groups.Returns:The position in the underlying server-side inserted ads stream, in microseconds.
-
public static long getMediaPeriodPositionUsForAd(long positionUs,
int adGroupIndex,
int adIndexInAdGroup,[AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")adPlaybackState)
Deprecated.
Returns the position in an ad MediaPeriod for a position in the underlying server-side inserted ads stream.
Parameters:positionUs - The position in the underlying server-side inserted ads stream, in microseconds.adGroupIndex - The ad group index of the ad.adIndexInAdGroup - The index of the ad in the ad group.adPlaybackState - The AdPlaybackState defining the ad groups.Returns:The position in the ad MediaPeriod, in microseconds.
-
public static long getStreamPositionUsForContent(long positionUs,
int nextAdGroupIndex,[AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")adPlaybackState)
Deprecated.
Returns the position in the underlying server-side inserted ads stream for a position in a content MediaPeriod.
Parameters:positionUs - The position in the content MediaPeriod, in microseconds.nextAdGroupIndex - The next ad group index after the content, or C.INDEX_UNSET if there is no following ad group. Ad groups from this index are not used to adjust the position.adPlaybackState - The AdPlaybackState defining the ad groups.Returns:The position in the underlying server-side inserted ads stream, in microseconds.
-
public static long getMediaPeriodPositionUsForContent(long positionUs,
int nextAdGroupIndex,[AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")adPlaybackState)
Deprecated.
Returns the position in a content MediaPeriod for a position in the underlying server-side inserted ads stream.
Parameters:positionUs - The position in the underlying server-side inserted ads stream, in microseconds.nextAdGroupIndex - The next ad group index after the content, or C.INDEX_UNSET if there is no following ad group. Ad groups from this index are not used to adjust the position.adPlaybackState - The AdPlaybackState defining the ad groups.Returns:The position in the content MediaPeriod, in microseconds.
-
public static int getAdCountInGroup([AdPlaybackState](AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")adPlaybackState,
int adGroupIndex)
Deprecated.
Returns the number of ads in an ad group, treating an unknown number as zero ads.
Parameters:adPlaybackState - The AdPlaybackState.adGroupIndex - The index of the ad group.Returns:The number of ads in the ad group.