Skip to content

Commit

Permalink
Prevent automatic replay after returning from background
Browse files Browse the repository at this point in the history
  • Loading branch information
litetex committed Nov 8, 2021
1 parent b5ad24e commit 7d29897
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -860,9 +860,15 @@ public void setRecovery() {

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));
}
}

Expand Down

0 comments on commit 7d29897

Please sign in to comment.