当前位置: 首页>>代码示例>>Java>>正文


Java Clip.loop方法代码示例

本文整理汇总了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);
    }

}
 
开发者ID:Exia-Aix-A2,项目名称:Boulder-Dash,代码行数:20,代码来源:Sound.java

示例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);
   }
    }
 
开发者ID:niekBr,项目名称:Mario,代码行数:16,代码来源:Menu.java

示例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);
}
 
开发者ID:SEAL-UCLA,项目名称:Ref-Finder,代码行数:10,代码来源:Aurelizer.java

示例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);
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:7,代码来源:Sounds.java

示例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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:ClickInPlay.java

示例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);
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:7,代码来源:Aurelizer.java

示例7: loop

import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public void loop()
{
  Clip myclip = getClip();
  if (myclip != null)
    myclip.loop(Clip.LOOP_CONTINUOUSLY);
}
 
开发者ID:vilie,项目名称:javify,代码行数:7,代码来源:Applet.java


注:本文中的javax.sound.sampled.Clip.loop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。