本文整理汇总了Java中javax.sound.sampled.Clip.stop方法的典型用法代码示例。如果您正苦于以下问题:Java Clip.stop方法的具体用法?Java Clip.stop怎么用?Java Clip.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.Clip
的用法示例。
在下文中一共展示了Clip.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: destroy
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
/**
* Destroys the MultiClip and releases all resources.
*/
public void destroy() {
if (clips.size() > 0) {
for (Clip c : clips) {
c.stop();
c.flush();
c.close();
}
extraClips -= clips.size() - 1;
clips = new LinkedList<Clip>();
}
audioData = null;
if (audioIn != null) {
try {
audioIn.close();
} catch (IOException e) {
explode(String.format("Could not close AudioInputStream for MultiClip %s.", name), e,
DEFAULT_OPTIONS);
}
}
}
示例2: update
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public void update(LineEvent event) {
// ストップか最後まで再生された場合
if(event.getType() == LineEvent.Type.STOP) {
Clip clip = (Clip) event.getSource();
clip.stop();
clip.setFramePosition(0); // 再生位置を最初に戻す
}
}
示例3: play
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public static void play(Type type)
{
Clip[] cliparr = clips.get(type);
Clip clip = cliparr[type.current];
if(clip.isActive())
{
clip.flush();
clip.stop();
}
clip.setFramePosition(0);
clip.start();
}
示例4: play
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public static void play(String s, int i) {
if(mute) return;
Clip c = clips.get(s);
if(c == null) return;
if(c.isRunning()) c.stop();
c.setFramePosition(i);
while(!c.isRunning()) c.start();
}
示例5: main
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
boolean res = true;
try {
AudioInputStream ais = new AudioInputStream(
new ByteArrayInputStream(new byte[2000]),
new AudioFormat(8000.0f, 8, 1, false, false), 2000); //
AudioFormat format = ais.getFormat();
DataLine.Info info = new DataLine.Info(Clip.class, format,
((int) ais.getFrameLength()
* format
.getFrameSize()));
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open();
FloatControl rateControl = (FloatControl) clip.getControl(
FloatControl.Type.SAMPLE_RATE);
int c = 0;
while (c++ < 10) {
clip.stop();
clip.setFramePosition(0);
clip.start();
for (float frq = 22000; frq < 44100; frq = frq + 100) {
try {
Thread.currentThread().sleep(20);
} catch (Exception e) {
break;
}
rateControl.setValue(frq);
}
}
} catch (Exception ex) {
ex.printStackTrace();
res = ex.getMessage().indexOf(
"This method should not have been invoked!") < 0;
}
if (res) {
System.out.println("Test passed");
} else {
System.out.println("Test failed");
throw new Exception("Test failed");
}
}
示例6: doMixerClip
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
private static boolean doMixerClip(Mixer mixer, AudioFormat format) {
if (mixer==null) return false;
try {
System.out.println("Trying mixer "+mixer+":");
DataLine.Info info = new DataLine.Info(
Clip.class,
format,
(int) samplerate);
Clip clip = (Clip) mixer.getLine(info);
System.out.println(" - got clip: "+clip);
System.out.println(" - open with format "+format);
clip.open(format, buffer, 0, buffer.length);
System.out.println(" - playing...");
clip.start();
System.out.println(" - waiting while it's active...");
while (clip.isActive())
Thread.sleep(100);
System.out.println(" - waiting 100millis");
Thread.sleep(100);
System.out.println(" - drain1");
clip.drain();
System.out.println(" - drain2");
clip.drain();
System.out.println(" - stop");
clip.stop();
System.out.println(" - close");
clip.close();
System.out.println(" - closed");
} catch (Throwable t) {
System.out.println(" - Caught exception. Not failed.");
System.out.println(" - "+t.toString());
return false;
}
return true;
}
示例7: stop
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public void stop()
{
Clip myclip = getClip();
if (myclip != null)
{
myclip.stop();
myclip.setFramePosition(0);
}
}
示例8: enter
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public synchronized void enter(String eventName)
{
Clip clip = (Clip)this.clips.get(eventName);
if (clip.isActive()) {
clip.stop();
}
clip.setFramePosition(0);
clip.start();
}
示例9: 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);
}
示例10: playClip
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public void playClip(final Clip clip) {
if (clip == null) {
return;
}
clip.stop();
clip.flush();
clip.setFramePosition(0);
clip.start();
}
示例11: play
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
/**
* 再生
* @param name 登録名
*/
public void play(String name) {
Clip clip = clipMap.get(name);
if(clip != null) {
// 停止
clip.stop();
// 再生位置を最初に戻す
clip.setFramePosition(0);
// 再生
clip.start();
}
}
示例12: stop
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
/**
* 停止
* @param name 登録名
*/
public void stop(String name) {
Clip clip = clipMap.get(name);
if(clip != null) {
clip.stop();
}
}
示例13: stop
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public static void stop(final Type type) {
Clip[] cliparr = clips.get(type);
Clip clip = cliparr[type.current];
clip.stop();
}
示例14: 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;
}
}
示例15: enter
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public synchronized void enter(String eventName) {
Clip clip = (Clip)clips.get(eventName);
if (clip.isActive()) clip.stop();
clip.setFramePosition(0);
clip.start();
}