com.google.android.exoplayer.TimeRange

Here are the examples of the java api class com.google.android.exoplayer.TimeRange taken from open source projects.

1. DashChunkSourceTest#testGetAvailableRangeOnVod()

Project: ExoPlayer
Source File: DashChunkSourceTest.java
View license
public void testGetAvailableRangeOnVod() {
    DashChunkSource chunkSource = new DashChunkSource(buildVodMpd(), DefaultDashTrackSelector.newVideoInstance(null, false, false), null, null);
    chunkSource.prepare();
    chunkSource.enable(0);
    TimeRange availableRange = chunkSource.getAvailableRange();
    checkAvailableRange(availableRange, 0, VOD_DURATION_MS * 1000);
    long[] seekRangeValuesMs = availableRange.getCurrentBoundsMs(null);
    assertEquals(0, seekRangeValuesMs[0]);
    assertEquals(VOD_DURATION_MS, seekRangeValuesMs[1]);
}

2. DashChunkSourceTest#checkLiveEdgeConsistency()

Project: ExoPlayer
Source File: DashChunkSourceTest.java
View license
private static void checkLiveEdgeConsistency(DashChunkSource chunkSource, List<MediaChunk> queue, ChunkOperationHolder out, long seekPositionMs, long availableRangeStartMs, long availableRangeEndMs, long chunkStartTimeMs, long chunkEndTimeMs) {
    chunkSource.getChunkOperation(queue, seekPositionMs * 1000, out);
    TimeRange availableRange = chunkSource.getAvailableRange();
    checkAvailableRange(availableRange, availableRangeStartMs * 1000, availableRangeEndMs * 1000);
    if (chunkStartTimeMs < availableRangeEndMs) {
        assertNotNull(out.chunk);
        assertEquals(chunkStartTimeMs * 1000, ((MediaChunk) out.chunk).startTimeUs);
        assertEquals(chunkEndTimeMs * 1000, ((MediaChunk) out.chunk).endTimeUs);
    } else {
        assertNull(out.chunk);
    }
}

3. DashChunkSourceTest#testGetAvailableRangeOnLiveWithTimeline()

Project: ExoPlayer
Source File: DashChunkSourceTest.java
View license
public void testGetAvailableRangeOnLiveWithTimeline() {
    MediaPresentationDescription mpd = buildLiveMpdWithTimeline(LIVE_DURATION_MS, 0);
    DashChunkSource chunkSource = buildDashChunkSource(mpd);
    TimeRange availableRange = chunkSource.getAvailableRange();
    checkAvailableRange(availableRange, 0, LIVE_DURATION_MS * 1000);
}

4. DashChunkSourceTest#testGetAvailableRangeOnMultiPeriodVod()

Project: ExoPlayer
Source File: DashChunkSourceTest.java
View license
public void testGetAvailableRangeOnMultiPeriodVod() {
    DashChunkSource chunkSource = new DashChunkSource(buildMultiPeriodVodMpd(), DefaultDashTrackSelector.newVideoInstance(null, false, false), null, null);
    chunkSource.prepare();
    chunkSource.enable(0);
    TimeRange availableRange = chunkSource.getAvailableRange();
    checkAvailableRange(availableRange, 0, MULTI_PERIOD_VOD_DURATION_MS * 1000);
}

5. DashChunkSourceTest#testGetSeekRangeOnMultiPeriodLiveWithTimeline()

Project: ExoPlayer
Source File: DashChunkSourceTest.java
View license
public void testGetSeekRangeOnMultiPeriodLiveWithTimeline() {
    MediaPresentationDescription mpd = buildMultiPeriodLiveMpdWithTimeline();
    DashChunkSource chunkSource = buildDashChunkSource(mpd);
    TimeRange availableRange = chunkSource.getAvailableRange();
    checkAvailableRange(availableRange, 0, MULTI_PERIOD_LIVE_DURATION_MS * 1000);
}

6. DashChunkSource#processManifest()

Project: ExoPlayer
Source File: DashChunkSource.java
View license
private void processManifest(MediaPresentationDescription manifest) {
    // Remove old periods.
    Period firstPeriod = manifest.getPeriod(0);
    while (periodHolders.size() > 0 && periodHolders.valueAt(0).startTimeUs < firstPeriod.startMs * 1000) {
        PeriodHolder periodHolder = periodHolders.valueAt(0);
        // TODO: Use periodHolders.removeAt(0) if the minimum API level is ever increased to 11.
        periodHolders.remove(periodHolder.localIndex);
    }
    // behind, discard this manifest, and try again later.
    if (periodHolders.size() > manifest.getPeriodCount()) {
        return;
    }
    // Update existing periods. Only the first and last periods can change.
    try {
        int periodHolderCount = periodHolders.size();
        if (periodHolderCount > 0) {
            periodHolders.valueAt(0).updatePeriod(manifest, 0, enabledTrack);
            if (periodHolderCount > 1) {
                int lastIndex = periodHolderCount - 1;
                periodHolders.valueAt(lastIndex).updatePeriod(manifest, lastIndex, enabledTrack);
            }
        }
    } catch (BehindLiveWindowException e) {
        fatalError = e;
        return;
    }
    // Add new periods.
    for (int i = periodHolders.size(); i < manifest.getPeriodCount(); i++) {
        PeriodHolder holder = new PeriodHolder(nextPeriodHolderIndex, manifest, i, enabledTrack);
        periodHolders.put(nextPeriodHolderIndex, holder);
        nextPeriodHolderIndex++;
    }
    // Update the available range.
    TimeRange newAvailableRange = getAvailableRange(getNowUnixTimeUs());
    if (availableRange == null || !availableRange.equals(newAvailableRange)) {
        availableRange = newAvailableRange;
        notifyAvailableRangeChanged(availableRange);
    }
    currentManifest = manifest;
}