本文整理汇总了Java中javax.sound.sampled.Clip.loop方法的典型用法代码示例。如果您正苦于以下问题:Java Clip.loop方法的具体用法?Java Clip.loop怎么用?Java Clip.loop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.Clip
的用法示例。
在下文中一共展示了Clip.loop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
/**
* The sound is load and play in a thread no slow down the engine.
* */
@Override
public void run() {
try {
InputStream in = new BufferedInputStream(this.getClass().getResourceAsStream(this.filename + ".wav"));
Clip clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(in));
if (this.loop){
clip.loop(Clip.LOOP_CONTINUOUSLY);
}
clip.start();
}catch (Exception e){
System.err.println(e);
}
}
示例2: playMainMusic
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public void playMainMusic() {
try {
clip = (Clip)AudioSystem.getLine(new Line.Info(Clip.class));
clip.open(AudioSystem.getAudioInputStream(new File("sounds/main.wav")));
FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
gainControl.setValue(-20.0f); // Muziek moet niet boven soundeffects uitkomen, dus 20dB zachter
clip.start();
clip.loop(Clip.LOOP_CONTINUOUSLY);
}
catch (Exception exc) {
exc.printStackTrace(System.out);
}
}
示例3: enter_loop
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public synchronized void enter_loop(String eventName)
{
Clip clip = (Clip)this.clips.get(eventName);
if (clip.isActive()) {
clip.stop();
}
clip.setFramePosition(0);
clip.loop(-1);
}
示例4: loop
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public static void loop(final Type type) {
Clip[] cliparr = clips.get(type);
Clip clip = cliparr[type.current];
clip.setFramePosition(0);
clip.loop(Clip.LOOP_CONTINUOUSLY);
}
示例5: play
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public static void play(Mixer mixer) {
int res = 0;
try {
println("Getting clip from mixer...");
source = (Clip) mixer.getLine(info);
println("Opening clip...");
source.open(audioFormat, audioData, 0, audioData.length);
println("Starting clip...");
source.loop(Clip.LOOP_CONTINUOUSLY);
println("Now open your ears:");
println("- if you hear a sine wave playing,");
println(" listen carefully if you can hear clicks.");
println(" If no, the bug is fixed.");
println("- if you don't hear anything, it's possible");
println(" that this mixer is not connected to an ");
println(" amplifier, or that its volume is set to 0");
key();
} catch (IllegalArgumentException iae) {
println("IllegalArgumentException: "+iae.getMessage());
println("Sound device cannot handle this audio format.");
println("ERROR: Test environment not correctly set up.");
if (source!=null) {
source.close();
source = null;
}
return;
} catch (LineUnavailableException lue) {
println("LineUnavailableException: "+lue.getMessage());
println("This is normal for some mixers.");
} catch (Exception e) {
println("Unexpected Exception: "+e.toString());
}
if (source != null) {
println("Stopping...");
source.stop();
println("Closing...");
source.close();
println("Closed.");
source = null;
}
}
示例6: enter_loop
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public synchronized void enter_loop(String eventName) {
Clip clip = (Clip)clips.get(eventName);
if (clip.isActive()) clip.stop();
clip.setFramePosition(0);
clip.loop(Clip.LOOP_CONTINUOUSLY);
}
示例7: loop
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public void loop()
{
Clip myclip = getClip();
if (myclip != null)
myclip.loop(Clip.LOOP_CONTINUOUSLY);
}