Search in sources :

Example 1 with MaskingMediaPeriod

use of com.google.android.exoplayer2.source.MaskingMediaPeriod in project ExoPlayer by google.

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(com.google.android.exoplayer2.source.MaskingMediaPeriod) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)

Example 2 with MaskingMediaPeriod

use of com.google.android.exoplayer2.source.MaskingMediaPeriod in project ExoPlayer by google.

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(com.google.android.exoplayer2.source.ConcatenatingMediaSource.MediaSourceHolder)

Example 3 with MaskingMediaPeriod

use of com.google.android.exoplayer2.source.MaskingMediaPeriod in project ExoPlayer by google.

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 : MaskingMediaPeriod(com.google.android.exoplayer2.source.MaskingMediaPeriod) Nullable(androidx.annotation.Nullable)

Aggregations

MaskingMediaPeriod (com.google.android.exoplayer2.source.MaskingMediaPeriod)2 Nullable (androidx.annotation.Nullable)1 MediaSourceHolder (com.google.android.exoplayer2.source.ConcatenatingMediaSource.MediaSourceHolder)1 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)1