Prevent song resuming from outside of valid positions.

This commit is contained in:
Brendan Robert 2023-11-07 09:41:23 -06:00
parent 637d713883
commit 663758bb8a
1 changed files with 1 additions and 0 deletions

View File

@ -101,6 +101,7 @@ public class Media {
public void seekToTime(Duration millis) {
int sampleNumber = (int) (millis.toMillis() * sampleRate / 1000);
sampleNumber = Math.max(0, Math.min(sampleNumber, totalSamples));
sampleBuffer.position(sampleNumber * (isStereo ? 2 : 1));
}