audio - How to play a sound in java from the millisecond X -
i have problem, wanna play sound (or music file) example second 10 12, possible make function soundobject.play(10000,12000); ? i'm testing sound classes can play, stop , loop
thank you!
i found answer, code used play 3-5 seconds
import java.io.ioexception; import java.net.url; import javax.sound.sampled.audioinputstream; import javax.sound.sampled.audiosystem; import javax.sound.sampled.clip; import javax.sound.sampled.lineunavailableexception; import javax.sound.sampled.unsupportedaudiofileexception; public class soundcliptest{ public static void main(string[] args) throws unsupportedaudiofileexception, ioexception, lineunavailableexception { url myurl= classloader.getsystemresource("abesti.wav"); audioinputstream audio = audiosystem.getaudioinputstream(myurl); clip clip = audiosystem.getclip(); clip.open(audio); clip.setmicrosecondposition(3000000); clip.start(); try { thread.sleep(2000); //in milliseconds } catch (interruptedexception e) { e.printstacktrace(); } clip.stop(); } }
Comments
Post a Comment