Prevent automatic replay after returning from background

See also https://github.com/TeamNewPipe/NewPipe/pull/7195#issuecomment-962624380
This commit is contained in:
litetex 2021-11-08 19:41:13 +01:00
parent 9e44053e22
commit 010c607e40
1 changed files with 8 additions and 2 deletions

View File

@ -857,9 +857,15 @@ public final class Player implements
final int queuePos = playQueue.getIndex(); final int queuePos = playQueue.getIndex();
final long windowPos = simpleExoPlayer.getCurrentPosition(); final long windowPos = simpleExoPlayer.getCurrentPosition();
final long duration = simpleExoPlayer.getDuration();
if (windowPos > 0 && windowPos <= simpleExoPlayer.getDuration()) { if (windowPos > 0
setRecovery(queuePos, windowPos); // 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));
} }
} }