setRecovery: Remove checks and use Math.min/max
This commit is contained in:
parent
010c607e40
commit
316db0e4c6
|
@ -859,14 +859,8 @@ public final class Player implements
|
||||||
final long windowPos = simpleExoPlayer.getCurrentPosition();
|
final long windowPos = simpleExoPlayer.getCurrentPosition();
|
||||||
final long duration = simpleExoPlayer.getDuration();
|
final long duration = simpleExoPlayer.getDuration();
|
||||||
|
|
||||||
if (windowPos > 0
|
// No checks due to https://github.com/TeamNewPipe/NewPipe/pull/7195#issuecomment-962624380
|
||||||
// Sometimes (e.g. when the playback ended) the windowPos is a few milliseconds
|
setRecovery(queuePos, Math.max(0, Math.min(windowPos, duration)));
|
||||||
// higher than the duration. Due to this a little buffer (100ms) was introduced.
|
|
||||||
// See also https://github.com/TeamNewPipe/NewPipe/pull/7195#issuecomment-962624380
|
|
||||||
&& windowPos <= duration + 100
|
|
||||||
) {
|
|
||||||
setRecovery(queuePos, Math.min(windowPos, duration));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRecovery(final int queuePos, final long windowPos) {
|
private void setRecovery(final int queuePos, final long windowPos) {
|
||||||
|
|
Loading…
Reference in New Issue