public void setLoopPoints(int start, int end) { c.setLoopPoints( start, end ); }
private void playBackClip(String fileName) { try { AudioInputStream soundStream = null; if (fileName.startsWith("res:")) { soundStream = AudioSystem.getAudioInputStream( Object.class.getResourceAsStream(fileName.substring(4))); } else { File audioFile = resMap.get(fileName); soundStream = AudioSystem.getAudioInputStream(audioFile); } AudioFormat streamFormat = soundStream.getFormat(); DataLine.Info clipInfo = new DataLine.Info(Clip.class, streamFormat); Clip clip = (Clip) AudioSystem.getLine(clipInfo); soundClip = clip; clip.open(soundStream); clip.setLoopPoints(0, -1); clip.start(); } catch (UnsupportedAudioFileException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (LineUnavailableException e) { e.printStackTrace(); } }
... Clip clip = (Clip) AudioSystem.getLine(info); clip.open(af, audio, 0, size); clip.loop(3); //Added this line clip.setLoopPoints(0, -1); //Added this line clip.start(); ...
@Override boolean startSample(int loopCount, float gain, int delay) { /* if (debugFlag) { debugPrint("JSClip: startSample "); debugPrintln("start stream called with "); debugPrintln(" gain = " + gain + ", delay is zero"); } // Since only one sample is processed in startSample, just call // this more general method passing duplicate information // We don't really want to do this in the long term. return startSamples(loopCount, gain, gain, 0, 0); */ // TODO: The following is temporary until we have fully // functional startSample and startSamples methods if (debugFlag) debugPrintln("JSClip.startSample(): starting sound Clip"); line.setFramePosition(0); // Start playing from the beginning line.setLoopPoints(0, -1); // Loop the entire sound sample line.loop(loopCount); line.start(); return true; } // end of start (single) Sample
line.setLoopPoints(0, -1); // Loop the entire sound sample