mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix concat media source premature listener invocation
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=128987095
This commit is contained in:
parent
c1729b640c
commit
17014e6264
1 changed files with 8 additions and 4 deletions
|
|
@ -45,6 +45,12 @@ public final class ConcatenatingMediaSource implements MediaSource {
|
||||||
@Override
|
@Override
|
||||||
public void onTimelineChanged(Timeline timeline) {
|
public void onTimelineChanged(Timeline timeline) {
|
||||||
timelines[index] = timeline;
|
timelines[index] = timeline;
|
||||||
|
for (int i = 0; i < timelines.length; i++) {
|
||||||
|
if (timelines[i] == null) {
|
||||||
|
// Don't invoke the listener until all sources have timelines.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
ConcatenatingMediaSource.this.timeline = new ConcatenatedTimeline(timelines.clone());
|
ConcatenatingMediaSource.this.timeline = new ConcatenatedTimeline(timelines.clone());
|
||||||
listener.onTimelineChanged(ConcatenatingMediaSource.this.timeline);
|
listener.onTimelineChanged(ConcatenatingMediaSource.this.timeline);
|
||||||
}
|
}
|
||||||
|
|
@ -105,10 +111,8 @@ public final class ConcatenatingMediaSource implements MediaSource {
|
||||||
int[] sourceOffsets = new int[timelines.length];
|
int[] sourceOffsets = new int[timelines.length];
|
||||||
int sourceIndexOffset = 0;
|
int sourceIndexOffset = 0;
|
||||||
for (int i = 0; i < timelines.length; i++) {
|
for (int i = 0; i < timelines.length; i++) {
|
||||||
Timeline manifest = timelines[i];
|
int periodCount = timelines[i].getPeriodCount();
|
||||||
int periodCount;
|
if (periodCount == Timeline.UNKNOWN_PERIOD_COUNT) {
|
||||||
if (manifest == null
|
|
||||||
|| (periodCount = manifest.getPeriodCount()) == Timeline.UNKNOWN_PERIOD_COUNT) {
|
|
||||||
sourceOffsets = Arrays.copyOf(sourceOffsets, i);
|
sourceOffsets = Arrays.copyOf(sourceOffsets, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue