'How to Skip Back and Forward 10 Seconds
I am writing an audio player. I need to add a rewind function for 10 seconds forward and backward. How to do it?
Here is example:
public static void main(String[] args) {
try {
AudioInputStream ais = AudioSystem.getAudioInputStream("file.wav");
} catch (UnsupportedAudioFileException | IOException e1) {
e1.printStackTrace();
}
try {
Clip clip = clip = AudioSystem.getClip();
} catch (LineUnavailableException e2) {
e2.printStackTrace();
}
try {
clip.open(ais);
} catch (LineUnavailableException | IOException e1) {
e1.printStackTrace();
}
}
private static forward(){
//code here
}
private static backwards(){
//code here
}
Sorry for bad code :p
Solution 1:[1]
Have you tried the setFramePosition or setMicrosecondPosition method of the clip?
https://docs.oracle.com/javase/8/docs/api/javax/sound/sampled/Clip.html#setFramePosition-int-
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Zeke Rogers |
