本文整理汇总了Java中com.google.android.exoplayer.TimeRange类的典型用法代码示例。如果您正苦于以下问题:Java TimeRange类的具体用法?Java TimeRange怎么用?Java TimeRange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeRange类属于com.google.android.exoplayer包,在下文中一共展示了TimeRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enable
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
@Override
public void enable() {
fatalError = null;
formatEvaluator.enable();
if (manifestFetcher != null) {
manifestFetcher.enable();
}
DashSegmentIndex segmentIndex =
representationHolders.get(formats[0].id).representation.getIndex();
if (segmentIndex == null) {
seekRange = new TimeRange(TimeRange.TYPE_SNAPSHOT, 0, currentManifest.duration * 1000);
notifySeekRangeChanged(seekRange);
} else {
long nowUs = getNowUs();
updateAvailableSegmentBounds(segmentIndex, nowUs);
updateSeekRange(segmentIndex, nowUs);
}
}
示例2: getAvailableRange
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
private TimeRange getAvailableRange(long nowUnixTimeUs) {
PeriodHolder firstPeriod = periodHolders.valueAt(0);
PeriodHolder lastPeriod = periodHolders.valueAt(periodHolders.size() - 1);
if (!currentManifest.dynamic || lastPeriod.isIndexExplicit()) {
return new StaticTimeRange(firstPeriod.getAvailableStartTimeUs(),
lastPeriod.getAvailableEndTimeUs());
}
long minStartPositionUs = firstPeriod.getAvailableStartTimeUs();
long maxEndPositionUs = lastPeriod.isIndexUnbounded() ? Long.MAX_VALUE
: lastPeriod.getAvailableEndTimeUs();
long elapsedRealtimeAtZeroUs = (systemClock.elapsedRealtime() * 1000)
- (nowUnixTimeUs - (currentManifest.availabilityStartTime * 1000));
long timeShiftBufferDepthUs = currentManifest.timeShiftBufferDepth == -1 ? -1
: currentManifest.timeShiftBufferDepth * 1000;
return new DynamicTimeRange(minStartPositionUs, maxEndPositionUs, elapsedRealtimeAtZeroUs,
timeShiftBufferDepthUs, systemClock);
}
示例3: updateSeekRange
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
private void updateSeekRange(DashSegmentIndex segmentIndex, long nowUs) {
long earliestSeekPosition = segmentIndex.getTimeUs(firstAvailableSegmentNum);
long latestSeekPosition = segmentIndex.getTimeUs(lastAvailableSegmentNum)
+ segmentIndex.getDurationUs(lastAvailableSegmentNum);
if (currentManifest.dynamic) {
long liveEdgeTimestampUs;
if (segmentIndex.getLastSegmentNum() == DashSegmentIndex.INDEX_UNBOUNDED) {
liveEdgeTimestampUs = nowUs - currentManifest.availabilityStartTime * 1000;
} else {
liveEdgeTimestampUs = segmentIndex.getTimeUs(segmentIndex.getLastSegmentNum())
+ segmentIndex.getDurationUs(segmentIndex.getLastSegmentNum());
if (!segmentIndex.isExplicit()) {
// Some segments defined by the index may not be available yet. Bound the calculated live
// edge based on the elapsed time since the manifest became available.
liveEdgeTimestampUs = Math.min(liveEdgeTimestampUs,
nowUs - currentManifest.availabilityStartTime * 1000);
}
}
// it's possible that the live edge latency actually puts our latest position before
// the earliest position in the case of a DVR-like stream that's just starting up, so
// in that case just return the earliest position instead
latestSeekPosition = Math.max(earliestSeekPosition, liveEdgeTimestampUs - liveEdgeLatencyUs);
}
TimeRange newSeekRange = new TimeRange(TimeRange.TYPE_SNAPSHOT, earliestSeekPosition,
latestSeekPosition);
if (seekRange == null || !seekRange.equals(newSeekRange)) {
seekRange = newSeekRange;
notifySeekRangeChanged(seekRange);
}
}
示例4: notifySeekRangeChanged
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
private void notifySeekRangeChanged(final TimeRange seekRange) {
if (eventHandler != null && eventListener != null) {
eventHandler.post(new Runnable() {
@Override
public void run() {
eventListener.onSeekRangeChanged(seekRange);
}
});
}
}
示例5: notifyAvailableRangeChanged
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
private void notifyAvailableRangeChanged(final TimeRange seekRange) {
if (eventHandler != null && eventListener != null) {
eventHandler.post(new Runnable() {
@Override
public void run() {
eventListener.onAvailableRangeChanged(eventSourceId, seekRange);
}
});
}
}
示例6: testGetAvailableRangeOnVod
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
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]);
}
示例7: testGetAvailableRangeOnMultiPeriodVod
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
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);
}
示例8: checkLiveEdgeConsistency
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
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);
}
}
示例9: onAvailableRangeChanged
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
/** DashChunkSource.EventListener */
@Override
public void onAvailableRangeChanged(int sourceId, TimeRange timeRange) {
if (infoListener != null) {
infoListener.onAvailableRangeChanged(timeRange);
}
}
示例10: testGetSeekRangeOnVod
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
public void testGetSeekRangeOnVod() {
DashChunkSource chunkSource = new DashChunkSource(generateVodMpd(), AdaptationSet.TYPE_VIDEO,
null, null, mock(FormatEvaluator.class));
chunkSource.enable();
TimeRange seekRange = chunkSource.getSeekRange();
checkSeekRange(seekRange, 0, VOD_DURATION_MS * 1000);
long[] seekRangeValuesMs = seekRange.getCurrentBoundsMs(null);
assertEquals(0, seekRangeValuesMs[0]);
assertEquals(VOD_DURATION_MS, seekRangeValuesMs[1]);
}
示例11: checkLiveEdgeLatency
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
private void checkLiveEdgeLatency(DashChunkSource chunkSource, List<MediaChunk> queue,
ChunkOperationHolder out, long seekPositionMs, long seekRangeStartMs, long seekRangeEndMs,
long chunkStartTimeMs, long chunkEndTimeMs) {
chunkSource.getChunkOperation(queue, seekPositionMs * 1000, 0, out);
TimeRange seekRange = chunkSource.getSeekRange();
assertNotNull(out.chunk);
checkSeekRange(seekRange, seekRangeStartMs * 1000, seekRangeEndMs * 1000);
assertEquals(chunkStartTimeMs * 1000, ((MediaChunk) out.chunk).startTimeUs);
assertEquals(chunkEndTimeMs * 1000, ((MediaChunk) out.chunk).endTimeUs);
}
示例12: onAvailableRangeChanged
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
@Override
public void onAvailableRangeChanged(int sourceId, TimeRange availableRange) {
if (infoListener != null) {
infoListener.onAvailableRangeChanged(sourceId, availableRange);
}
}
示例13: onAvailableRangeChanged
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
@Override
public void onAvailableRangeChanged(int sourceId, TimeRange availableRange) {
availableRangeValuesUs = availableRange.getCurrentBoundsUs(availableRangeValuesUs);
Log.d(TAG, "availableRange [" + availableRange.isStatic() + ", " + availableRangeValuesUs[0]
+ ", " + availableRangeValuesUs[1] + "]");
}
示例14: onAvailableRangeChanged
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
@Override
public void onAvailableRangeChanged(int sourceId, TimeRange availableRange) {
if (infoListener != null) {
infoListener.onAvailableRangeChanged(sourceId, availableRange);
}
}
示例15: onAvailableRangeChanged
import com.google.android.exoplayer.TimeRange; //导入依赖的package包/类
@Override
public void onAvailableRangeChanged(TimeRange availableRange) {
availableRangeValuesUs = availableRange.getCurrentBoundsUs(availableRangeValuesUs);
Log.d(TAG, "availableRange [" + availableRange.isStatic() + ", " + availableRangeValuesUs[0]
+ ", " + availableRangeValuesUs[1] + "]");
}