diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index b2708e075..4310ccad7 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -857,9 +857,15 @@ public final class Player implements final int queuePos = playQueue.getIndex(); final long windowPos = simpleExoPlayer.getCurrentPosition(); + final long duration = simpleExoPlayer.getDuration(); - if (windowPos > 0 && windowPos <= simpleExoPlayer.getDuration()) { - setRecovery(queuePos, windowPos); + if (windowPos > 0 + // Sometimes (e.g. when the playback ended) the windowPos is a few milliseconds + // 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)); } }