mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix period durations for single period and concatenated timelines.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=129748865
This commit is contained in:
parent
88bf1d0739
commit
cdb706bac8
3 changed files with 9 additions and 8 deletions
|
|
@ -554,6 +554,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
stopRenderers();
|
stopRenderers();
|
||||||
rebuffering = false;
|
rebuffering = false;
|
||||||
|
setState(ExoPlayer.STATE_BUFFERING);
|
||||||
|
|
||||||
if (positionUs == C.UNSET_TIME_US) {
|
if (positionUs == C.UNSET_TIME_US) {
|
||||||
// We don't know where to seek to yet, so clear the whole timeline.
|
// We don't know where to seek to yet, so clear the whole timeline.
|
||||||
|
|
@ -606,7 +607,6 @@ import java.util.ArrayList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updatePlaybackPositions();
|
updatePlaybackPositions();
|
||||||
setState(ExoPlayer.STATE_BUFFERING);
|
|
||||||
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
|
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,8 @@ public final class ConcatenatingMediaSource implements MediaSource {
|
||||||
@Override
|
@Override
|
||||||
public long getPeriodDuration(int index) {
|
public long getPeriodDuration(int index) {
|
||||||
int sourceIndex = getSourceIndexForPeriod(index);
|
int sourceIndex = getSourceIndexForPeriod(index);
|
||||||
return timelines[sourceIndex].getPeriodDuration(sourceIndex);
|
int firstPeriodIndexInSource = getFirstPeriodIndexInSource(sourceIndex);
|
||||||
|
return timelines[sourceIndex].getPeriodDuration(index - firstPeriodIndexInSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public final class SinglePeriodTimeline implements Timeline {
|
||||||
* @return A new, unseekable, final timeline with one period.
|
* @return A new, unseekable, final timeline with one period.
|
||||||
*/
|
*/
|
||||||
public static Timeline createUnseekableFinalTimeline(Object id, long durationUs) {
|
public static Timeline createUnseekableFinalTimeline(Object id, long durationUs) {
|
||||||
return new SinglePeriodTimeline(id, true, durationUs, SeekWindow.UNSEEKABLE);
|
return new SinglePeriodTimeline(id, true, durationUs / 1000, SeekWindow.UNSEEKABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -53,19 +53,19 @@ public final class SinglePeriodTimeline implements Timeline {
|
||||||
* @return A new, seekable, final timeline with one period.
|
* @return A new, seekable, final timeline with one period.
|
||||||
*/
|
*/
|
||||||
public static Timeline createSeekableFinalTimeline(Object id, long durationUs) {
|
public static Timeline createSeekableFinalTimeline(Object id, long durationUs) {
|
||||||
return new SinglePeriodTimeline(id, true, durationUs, new SeekWindow(durationUs));
|
return new SinglePeriodTimeline(id, true, durationUs / 1000, new SeekWindow(durationUs));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Object id;
|
private final Object id;
|
||||||
private final boolean isFinal;
|
private final boolean isFinal;
|
||||||
private final long duration;
|
private final long durationMs;
|
||||||
private final SeekWindow[] seekWindows;
|
private final SeekWindow[] seekWindows;
|
||||||
|
|
||||||
private SinglePeriodTimeline(Object id, boolean isFinal, long duration,
|
private SinglePeriodTimeline(Object id, boolean isFinal, long durationMs,
|
||||||
SeekWindow... seekWindows) {
|
SeekWindow... seekWindows) {
|
||||||
this.id = Assertions.checkNotNull(id);
|
this.id = Assertions.checkNotNull(id);
|
||||||
this.isFinal = isFinal;
|
this.isFinal = isFinal;
|
||||||
this.duration = duration;
|
this.durationMs = durationMs;
|
||||||
this.seekWindows = seekWindows;
|
this.seekWindows = seekWindows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,7 +84,7 @@ public final class SinglePeriodTimeline implements Timeline {
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
throw new IndexOutOfBoundsException("Index " + index + " out of bounds");
|
throw new IndexOutOfBoundsException("Index " + index + " out of bounds");
|
||||||
}
|
}
|
||||||
return duration;
|
return durationMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue