Fix issue arising when using track APIs at the exact last possible position of a Period with no consecutive Period #1337
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We found out that an issue prevented from switching the track when the current position was exactly at the position indicated by a Period's
end
property if there was no immediately consecutive Period.For example if a content had, as a last Period, one starting at position
10
(seconds) and ending at30
, and if the player was currently paused at position30
asetAudioTrack
or any track switching call wouldn't have any effect.This is because the logic handling which Period should currently be handled decides that a Period finishes as soon as we reached the position indicated by its
end
property. Because under that logic we're not playing the last Period anymore when we reached it, API updating tracks of the current Period do not have any effect.It actually makes perfect sense for the frequent usecase of having consecutive Periods, where the
end
of one is equal to thestart
of the following one (in which case the following one has priority, so finishing the previous Period is wanted here), but it begins to show weird behaviors like the one described here when a Period'send
is not shared with a consecutive Period, in which case we could (and probably should) consider thatend
position as part of that Period instead as there's no such ambiguity.So this PR actually explicitely handles that case, which fixes the issue.