mirror of
https://github.com/samsonjs/media.git
synced 2026-04-01 10:35:48 +00:00
Discard preparation chunk if track selection does not include it
This avoids breaking the player if the first variant is not supported by the device. Issue:#2353 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148025791
This commit is contained in:
parent
55a3fca6f9
commit
72e1eae6f5
1 changed files with 10 additions and 0 deletions
|
|
@ -182,6 +182,7 @@ import java.util.LinkedList;
|
|||
}
|
||||
}
|
||||
// Enable new tracks.
|
||||
TrackSelection primaryTrackSelection = null;
|
||||
boolean selectedNewTracks = false;
|
||||
for (int i = 0; i < selections.length; i++) {
|
||||
if (streams[i] == null && selections[i] != null) {
|
||||
|
|
@ -189,6 +190,7 @@ import java.util.LinkedList;
|
|||
int group = trackGroups.indexOf(selection.getTrackGroup());
|
||||
setTrackGroupEnabledState(group, true);
|
||||
if (group == primaryTrackGroupIndex) {
|
||||
primaryTrackSelection = selection;
|
||||
chunkSource.selectTracks(selection);
|
||||
}
|
||||
streams[i] = new HlsSampleStream(this, group);
|
||||
|
|
@ -205,6 +207,14 @@ import java.util.LinkedList;
|
|||
sampleQueues.valueAt(i).disable();
|
||||
}
|
||||
}
|
||||
if (primaryTrackSelection != null && !mediaChunks.isEmpty()) {
|
||||
primaryTrackSelection.updateSelectedTrack(0);
|
||||
int chunkIndex = chunkSource.getTrackGroup().indexOf(mediaChunks.getLast().trackFormat);
|
||||
if (primaryTrackSelection.getSelectedIndexInTrackGroup() != chunkIndex) {
|
||||
// The loaded preparation chunk does match the selection. We discard it.
|
||||
seekTo(lastSeekPositionUs);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Cancel requests if necessary.
|
||||
if (enabledTrackCount == 0) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue