Play recorded sounds: Difference between revisions

Content added Content deleted
(New post.)
m (Minor improvement to code.)
Line 529: Line 529:
case 2 -> resume();
case 2 -> resume();
case 3 -> restart();
case 3 -> restart();
case 4 -> jump();
case 4 -> { System.out.println("Select a time between 0 and " + clip.getMicrosecondLength());
final long request = scanner.nextLong();
jump(request);
}
case 5 -> stop();
case 5 -> stop();
case 6 -> quit();
case 6 -> quit();
Line 578: Line 575:
}
}
private void jump(long aRequest) {
private void jump() {
if ( aRequest > 0 && aRequest < clip.getMicrosecondLength() ) {
System.out.println("Select a time between 0 and " + clip.getMicrosecondLength());
final long request = scanner.nextLong();
if ( request > 0 && request < clip.getMicrosecondLength() ) {
clip.stop();
clip.stop();
clip.close();
clip.close();
resetAudioStream();
resetAudioStream();
currentClipPosition = aRequest;
currentClipPosition = request;
clip.setMicrosecondPosition(currentClipPosition);
clip.setMicrosecondPosition(currentClipPosition);
status = Status.PLAYING;
status = Status.PLAYING;