1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-10-24 11:57:38 +00:00

Prevent seeking out of video duration in player

This commit is contained in:
Stypox
2020-09-09 20:41:30 +02:00
parent 1605e50cef
commit 52e89c1d1c

View File

@@ -1242,7 +1242,15 @@ public abstract class BasePlayer implements
Log.d(TAG, "seekBy() called with: position = [" + positionMillis + "]");
}
if (simpleExoPlayer != null) {
simpleExoPlayer.seekTo(positionMillis);
// prevent invalid positions when fast-forwarding/-rewinding
long normalizedPositionMillis = positionMillis;
if (normalizedPositionMillis < 0) {
normalizedPositionMillis = 0;
} else if (normalizedPositionMillis > simpleExoPlayer.getDuration()) {
normalizedPositionMillis = simpleExoPlayer.getDuration();
}
simpleExoPlayer.seekTo(normalizedPositionMillis);
}
}