Search in sources :

Example 1 with MaskingMediaPeriod

use of androidx.media3.exoplayer.source.MaskingMediaPeriod in project media by androidx.

the class AdsMediaSource method releasePeriod.

@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
    MaskingMediaPeriod maskingMediaPeriod = (MaskingMediaPeriod) mediaPeriod;
    MediaPeriodId id = maskingMediaPeriod.id;
    if (id.isAd()) {
        AdMediaSourceHolder adMediaSourceHolder = checkNotNull(adMediaSourceHolders[id.adGroupIndex][id.adIndexInAdGroup]);
        adMediaSourceHolder.releaseMediaPeriod(maskingMediaPeriod);
        if (adMediaSourceHolder.isInactive()) {
            adMediaSourceHolder.release();
            adMediaSourceHolders[id.adGroupIndex][id.adIndexInAdGroup] = null;
        }
    } else {
        maskingMediaPeriod.releasePeriod();
    }
}
Also used : MaskingMediaPeriod(androidx.media3.exoplayer.source.MaskingMediaPeriod) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)

Example 2 with MaskingMediaPeriod

use of androidx.media3.exoplayer.source.MaskingMediaPeriod in project media by androidx.

the class AdsMediaSource method createPeriod.

@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
    AdPlaybackState adPlaybackState = checkNotNull(this.adPlaybackState);
    if (adPlaybackState.adGroupCount > 0 && id.isAd()) {
        int adGroupIndex = id.adGroupIndex;
        int adIndexInAdGroup = id.adIndexInAdGroup;
        if (adMediaSourceHolders[adGroupIndex].length <= adIndexInAdGroup) {
            int adCount = adIndexInAdGroup + 1;
            adMediaSourceHolders[adGroupIndex] = Arrays.copyOf(adMediaSourceHolders[adGroupIndex], adCount);
        }
        @Nullable AdMediaSourceHolder adMediaSourceHolder = adMediaSourceHolders[adGroupIndex][adIndexInAdGroup];
        if (adMediaSourceHolder == null) {
            adMediaSourceHolder = new AdMediaSourceHolder(id);
            adMediaSourceHolders[adGroupIndex][adIndexInAdGroup] = adMediaSourceHolder;
            maybeUpdateAdMediaSources();
        }
        return adMediaSourceHolder.createMediaPeriod(id, allocator, startPositionUs);
    } else {
        MaskingMediaPeriod mediaPeriod = new MaskingMediaPeriod(id, allocator, startPositionUs);
        mediaPeriod.setMediaSource(contentMediaSource);
        mediaPeriod.createPeriod(id);
        return mediaPeriod;
    }
}
Also used : AdPlaybackState(androidx.media3.common.AdPlaybackState) MaskingMediaPeriod(androidx.media3.exoplayer.source.MaskingMediaPeriod) Nullable(androidx.annotation.Nullable)

Example 3 with MaskingMediaPeriod

use of androidx.media3.exoplayer.source.MaskingMediaPeriod in project media by androidx.

the class ConcatenatingMediaSource method releasePeriod.

@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
    MediaSourceHolder holder = Assertions.checkNotNull(mediaSourceByMediaPeriod.remove(mediaPeriod));
    holder.mediaSource.releasePeriod(mediaPeriod);
    holder.activeMediaPeriodIds.remove(((MaskingMediaPeriod) mediaPeriod).id);
    if (!mediaSourceByMediaPeriod.isEmpty()) {
        disableUnusedMediaSources();
    }
    maybeReleaseChildSource(holder);
}
Also used : MediaSourceHolder(androidx.media3.exoplayer.source.ConcatenatingMediaSource.MediaSourceHolder)

Aggregations

MaskingMediaPeriod (androidx.media3.exoplayer.source.MaskingMediaPeriod)2 Nullable (androidx.annotation.Nullable)1 AdPlaybackState (androidx.media3.common.AdPlaybackState)1 MediaSourceHolder (androidx.media3.exoplayer.source.ConcatenatingMediaSource.MediaSourceHolder)1 MediaPeriodId (androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)1