Class AdPlaybackState.AdGroup

  • All Implemented Interfaces:
    Bundleable
    Enclosing class:
    AdPlaybackState

    public static final class AdPlaybackState.AdGroup
    extends Object
    implements Bundleable
    Represents a group of ads, with information about their states.

    Instances are immutable. Call the with* methods to get new instances that have the required changes.

    • Field Detail

      • count

        public final int count
        The number of ads in the ad group, or C.LENGTH_UNSET if unknown.
      • uris

        public final @NullableType Uri[] uris
        The URI of each ad in the ad group.
      • states

        @AdState
        public final int[] states
        The state of each ad in the ad group.
      • durationsUs

        public final long[] durationsUs
        The durations of each ad in the ad group, in microseconds.
      • contentResumeOffsetUs

        public final long contentResumeOffsetUs
        The offset in microseconds which should be added to the content stream when resuming playback after the ad group.
      • isServerSideInserted

        public final boolean isServerSideInserted
        Whether this ad group is server-side inserted and part of the content stream.
    • Constructor Detail

      • AdGroup

        public AdGroup​(long timeUs)
        Creates a new ad group with an unspecified number of ads.
        Parameters:
        timeUs - The time of the ad group in the Timeline.Period, in microseconds, or C.TIME_END_OF_SOURCE to indicate a postroll ad.
    • Method Detail

      • getFirstAdIndexToPlay

        public int getFirstAdIndexToPlay()
        Returns the index of the first ad in the ad group that should be played, or count if no ads should be played.
      • getNextAdIndexToPlay

        public int getNextAdIndexToPlay​(int lastPlayedAdIndex)
        Returns the index of the next ad in the ad group that should be played after playing lastPlayedAdIndex, or count if no later ads should be played.
      • shouldPlayAdGroup

        public boolean shouldPlayAdGroup()
        Returns whether the ad group has at least one ad that should be played.
      • hasUnplayedAds

        public boolean hasUnplayedAds()
        Returns whether the ad group has at least one ad that is neither played, skipped, nor failed.
      • equals

        public boolean equals​(@Nullable
                              Object o)
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • withTimeUs

        @CheckResult
        public AdPlaybackState.AdGroup withTimeUs​(long timeUs)
        Returns a new instance with the timeUs set to the specified value.
      • withAdCount

        @CheckResult
        public AdPlaybackState.AdGroup withAdCount​(int count)
        Returns a new instance with the ad count set to count.
      • withAdDurationsUs

        @CheckResult
        public AdPlaybackState.AdGroup withAdDurationsUs​(long[] durationsUs)
        Returns a new instance with the specified ad durations, in microseconds.
      • withAllAdsSkipped

        @CheckResult
        public AdPlaybackState.AdGroup withAllAdsSkipped()
        Returns an instance with all unavailable and available ads marked as skipped. If the ad count hasn't been set, it will be set to zero.
      • toBundle

        public Bundle toBundle()
        Description copied from interface: Bundleable
        Returns a Bundle representing the information stored in this object.
        Specified by:
        toBundle in interface Bundleable