如何前后跳 10 秒
How to Skip Back and Forward 10 Seconds
我正在写一个音频播放器。我需要添加一个向前和向后 10 秒的倒带功能。怎么做?
示例如下:
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
}
抱歉代码错误:p
你试过剪辑的setFramePosition
或setMicrosecondPosition
方法了吗?
https://docs.oracle.com/javase/8/docs/api/javax/sound/sampled/Clip.html#setFramePosition-int-
我正在写一个音频播放器。我需要添加一个向前和向后 10 秒的倒带功能。怎么做?
示例如下:
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
}
抱歉代码错误:p
你试过剪辑的setFramePosition
或setMicrosecondPosition
方法了吗?
https://docs.oracle.com/javase/8/docs/api/javax/sound/sampled/Clip.html#setFramePosition-int-