mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-16 16:16:40 +03:00
Fix switching text on an edge case.
When switch() is called, it checks for what segment/period the media state will need to fetch next. As text is much smaller than audio/ video, it might be the case that text has all the segments in period i while audio and video are still in the process of fetching them. Thus, the next period needed for text will be i+1, while for other media states it will be i. Switch() assumes that if the period needed is not the same as current period, a perios transition is about to happen and there's no point in switching streams now since they're about to change on the next update anyway. However, the period transition only happenes if all the media states require it. In our edge case, only text is ready for the next period, so transition will not happen. This change corrects the assumption "if a media state is ready for the new period, don't switch" to assumption "if ALL media states are ready for the new period, don't switch." Issue #1774 Change-Id: I35f1b7ae10704922fb5692e02fc5f2edc6982575
This commit is contained in:
@@ -543,7 +543,12 @@ shaka.media.StreamingEngine = class {
|
||||
// handle a Period transition. Simply ignore the given stream, assuming that
|
||||
// Player will select the same track in onChooseStreams.
|
||||
const periodIndex = this.findPeriodContainingStream_(stream);
|
||||
if (clearBuffer && periodIndex != mediaState.needPeriodIndex) {
|
||||
const mediaStates = Array.from(this.mediaStates_.values());
|
||||
const needSamePeriod = mediaStates.every((ms) => {
|
||||
return ms.needPeriodIndex == mediaState.needPeriodIndex;
|
||||
});
|
||||
if (clearBuffer && periodIndex != mediaState.needPeriodIndex &&
|
||||
needSamePeriod) {
|
||||
shaka.log.debug('switch: switching to stream in another Period; ' +
|
||||
'clearing buffer and changing Periods');
|
||||
// handlePeriodTransition_ will be called on the next update because the
|
||||
|
||||
Reference in New Issue
Block a user