Skip to content

Commit 010c607

Browse files
committed
Prevent automatic replay after returning from background
See also #7195 (comment)
1 parent 9e44053 commit 010c607

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,15 @@ public void setRecovery() {
857857

858858
final int queuePos = playQueue.getIndex();
859859
final long windowPos = simpleExoPlayer.getCurrentPosition();
860+
final long duration = simpleExoPlayer.getDuration();
860861

861-
if (windowPos > 0 && windowPos <= simpleExoPlayer.getDuration()) {
862-
setRecovery(queuePos, windowPos);
862+
if (windowPos > 0
863+
// Sometimes (e.g. when the playback ended) the windowPos is a few milliseconds
864+
// higher than the duration. Due to this a little buffer (100ms) was introduced.
865+
// See also https://github.com/TeamNewPipe/NewPipe/pull/7195#issuecomment-962624380
866+
&& windowPos <= duration + 100
867+
) {
868+
setRecovery(queuePos, Math.min(windowPos, duration));
863869
}
864870
}
865871

0 commit comments

Comments
 (0)