From 24bf2aa0e25041203a25b7172b88a3a01e591076 Mon Sep 17 00:00:00 2001 From: olly Date: Tue, 8 Aug 2017 04:07:13 -0700 Subject: [PATCH] Support clip end greater than the child's duration ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=164577001 --- .../exoplayer2/source/ClippingMediaSource.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java index 4caafa3110..2387b43d5e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java @@ -47,7 +47,9 @@ public final class ClippingMediaSource implements MediaSource, MediaSource.Liste * start providing samples, in microseconds. * @param endPositionUs The end position within {@code mediaSource}'s timeline at which to stop * providing samples, in microseconds. Specify {@link C#TIME_END_OF_SOURCE} to provide samples - * from the specified start point up to the end of the source. + * from the specified start point up to the end of the source. Specifying a position that + * exceeds the {@code mediaSource}'s duration will also result in the end of the source not + * being clipped. */ public ClippingMediaSource(MediaSource mediaSource, long startPositionUs, long endPositionUs) { this(mediaSource, startPositionUs, endPositionUs, true); @@ -65,7 +67,9 @@ public final class ClippingMediaSource implements MediaSource, MediaSource.Liste * start providing samples, in microseconds. * @param endPositionUs The end position within {@code mediaSource}'s timeline at which to stop * providing samples, in microseconds. Specify {@link C#TIME_END_OF_SOURCE} to provide samples - * from the specified start point up to the end of the source. + * from the specified start point up to the end of the source. Specifying a position that + * exceeds the {@code mediaSource}'s duration will also result in the end of the source not + * being clipped. * @param enableInitialDiscontinuity Whether the initial discontinuity should be enabled. */ public ClippingMediaSource(MediaSource mediaSource, long startPositionUs, long endPositionUs, @@ -148,8 +152,10 @@ public final class ClippingMediaSource implements MediaSource, MediaSource.Liste Assertions.checkArgument(!window.isDynamic); long resolvedEndUs = endUs == C.TIME_END_OF_SOURCE ? window.durationUs : endUs; if (window.durationUs != C.TIME_UNSET) { + if (resolvedEndUs > window.durationUs) { + resolvedEndUs = window.durationUs; + } Assertions.checkArgument(startUs == 0 || window.isSeekable); - Assertions.checkArgument(resolvedEndUs <= window.durationUs); Assertions.checkArgument(startUs <= resolvedEndUs); } Period period = timeline.getPeriod(0, new Period());