本文整理汇总了Java中javax.sound.sampled.LineEvent.getType方法的典型用法代码示例。如果您正苦于以下问题:Java LineEvent.getType方法的具体用法?Java LineEvent.getType怎么用?Java LineEvent.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.LineEvent
的用法示例。
在下文中一共展示了LineEvent.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: play
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
/**
* playback start method extended by some gui stuff
*/
@Override
public void play() {
try {
super.play();
} catch (LineUnavailableException | IOException e) {
e.printStackTrace();
}
panel[2].setText("\u25A0");
panel[2].setBackground(new Color(232, 232, 232));
// listen to the audioClip and when it is finished playing, trigger the stop() method to clean up and reset the button
LineListener listener = new LineListener() {
public void update(LineEvent event) {
if (event.getType() == LineEvent.Type.STOP) {
stop();
}
}
};
this.getAudioClip().addLineListener(listener);
}
示例2: update
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
public void update(LineEvent e) {
if (e.getType() == LineEvent.Type.STOP) {
stopOccured++;
out(" Test program: receives STOP event for clip="+clip.toString()+" no."+stopOccured);
out(" Test program: Calling close() in event dispatcher thread");
clip.close();
synchronized (lock) {
lock.notifyAll();
}
}
else if (e.getType() == LineEvent.Type.CLOSE) {
out(" Test program: receives CLOSE event for "+clip.toString());
synchronized (lock) {
lock.notifyAll();
}
}
else if (e.getType() == LineEvent.Type.START) {
out(" Test program: receives START event for "+clip.toString());
}
else if (e.getType() == LineEvent.Type.OPEN) {
out(" Test program: receives OPEN event for "+clip.toString());
}
}
示例3: update
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
public void update(LineEvent event) {
// ストップか最後まで再生された場合
if(event.getType() == LineEvent.Type.STOP) {
Clip clip = (Clip) event.getSource();
clip.stop();
clip.setFramePosition(0); // 再生位置を最初に戻す
}
}
示例4: playAudio
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
private void playAudio(AudioInputStream audio)
{
LineListener lineListener = new LineListener()
{
public void update(LineEvent event)
{
if (event.getType() == LineEvent.Type.START) { Log.print(Log.DEBUG,"Audio started playing."); }
else if (event.getType() == LineEvent.Type.STOP) { Log.print(Log.DEBUG,"Audio stopped playing."); }
else if (event.getType() == LineEvent.Type.OPEN) { Log.print(Log.DEBUG,"Audio line opened."); }
else if (event.getType() == LineEvent.Type.CLOSE) { Log.print(Log.DEBUG,"Audio line closed."); }
}
};
AudioPlayer ap = new AudioPlayer(audio, lineListener);
ap.start();
}
示例5: update
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
public void update(LineEvent event) {
if (event.getType() == LineEvent.Type.OPEN) {
// start the line, init the buffer
line.start();
int bytes = line.getBufferSize();
byteBuf = new byte [bytes];
doubleBuf = new double [bytes / af.getFrameSize()];
fs = af.getFrameSize();
lineOpened = true;
} else if (event.getType() == LineEvent.Type.START) {
// nothing to do here
} else if (event.getType() == LineEvent.Type.STOP) {
line.close();
} else if (event.getType() == LineEvent.Type.CLOSE) {
// only free the line now
lineOpened = false;
} else
System.err.println("Unknown LineEvent: " + event.getType());
}
示例6: update
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
@Override
public void update(LineEvent le) {
if (!le.getLine().equals(line))
return;
System.err.println(new Date() + ": RawCapturer.update: " + le);
if (le.getType() == LineEvent.Type.START){
System.err.println("RawCapturer.update: notifyStart()");
notifyStart();
}
else if (le.getType() == LineEvent.Type.STOP){
System.err.println("RawCapturer.update: notifyStop()");
stopped = true;
notifyStop();
}
}
示例7: VentanaInternaGrabador
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
public VentanaInternaGrabador(final File f) {
initComponents();
recorder = new SMSoundPlayerRecorder(f);
this.setTitle(f.getName());
LineListener lineListener = new LineListener() {
@Override
public void update(LineEvent event) {
if (event.getType() == Type.START) {
recorderButton.setEnabled(false);
stopButton.setEnabled(true);
}
if (event.getType() == Type.STOP) {
recorderButton.setEnabled(true);
stopButton.setEnabled(false);
VentanaInternaReproductor vir = new VentanaInternaReproductor(f);
VentanaPrincipal.getEscritorio().add(vir);
vir.setVisible(true);
}
}
};
((SMSoundPlayerRecorder) recorder).setLineListener(lineListener);
this.pack();
}
示例8: VentanaInternaReproductor
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
public VentanaInternaReproductor(File f) {
initComponents();
player = new SMSoundPlayerRecorder(f);
this.setTitle(f.getName());
LineListener lineListener = new LineListener() {
@Override
public void update(LineEvent event) {
if (event.getType() == Type.START) {
play.setEnabled(false);
stop.setEnabled(true);
}
if (event.getType() == Type.STOP) {
play.setEnabled(true);
play.setSelected(false);
stop.setEnabled(false);
}
}
};
((SMSoundPlayerRecorder)player).setLineListener(lineListener);
this.pack();
}
示例9: VentanaInternaGrabador
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
public VentanaInternaGrabador() {
initComponents();
exist=true;
recorder = new SMSoundPlayerRecorder(new File("nuevo"));
LineListener lineListener = new LineListener() {
@Override
public void update(LineEvent event) {
if (event.getType() == Type.START) {
recorderButton.setEnabled(false);
stopButton.setEnabled(true);
}
if (event.getType() == Type.STOP) {
recorderButton.setEnabled(true);
stopButton.setEnabled(false);
}
}
};
((SMSoundPlayerRecorder) recorder).setLineListener(lineListener);
this.pack();
}
示例10: VentanaInternaReproductor
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
public VentanaInternaReproductor(File f) {
initComponents();
if (f != null) {
player = new SMSoundPlayer(f);
this.setTitle(f.getName());
LineListener lineListener = new LineListener() {
@Override
public void update(LineEvent event) {
if (event.getType() == Type.START) {
play.setEnabled(false);
stop.setEnabled(true);
}
if (event.getType() == Type.STOP) {
play.setEnabled(true);
play.setSelected(false);
stop.setEnabled(false);
}
}
};
((SMSoundPlayer) player).setLineListener(lineListener);
this.pack();
}
}
示例11: update
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
public void update(LineEvent lineEvent)
/* Called when the clip's line detects open, close, start, or
stop events. The watcher (if one exists) is notified.
*/
{
// when clip is stopped / reaches its end
if (lineEvent.getType() == LineEvent.Type.STOP) {
// System.out.println("update() STOP for " + name);
clip.stop();
clip.setFramePosition(0); // NEW
if (!isLooping) { // it isn't looping
if (watcher != null)
watcher.atSequenceEnd(name, SoundsWatcher.STOPPED);
}
else { // else play it again
clip.start();
if (watcher != null)
watcher.atSequenceEnd(name, SoundsWatcher.REPLAYED);
}
}
}
示例12: update
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
@Override
public void update(LineEvent event) {
LineEvent.Type type = event.getType();
if (type == LineEvent.Type.STOP) {
clip.close();
}
}
示例13: update
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
/**
* Monitors the source data line playback state and broadcasts audio events
* to the registered listener as the state changes
*/
@Override
public void update(LineEvent event)
{
LineEvent.Type type = event.getType();
if(type == LineEvent.Type.START)
{
mAudioEventBroadcaster.broadcast(mAudioStartEvent);
}
else if(type == LineEvent.Type.STOP)
{
mAudioEventBroadcaster.broadcast(mAudioStopEvent);
}
}
示例14: update
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
@Override
public void update(LineEvent event) {
if (LineEvent.Type.STOP == event.getType()) {
dataSource.flush();
music.flush();
this.play();
}
}
示例15: update
import javax.sound.sampled.LineEvent; //导入方法依赖的package包/类
/**
* This method allows to be notified for each event while playing a
* sound
*/
@Override
public synchronized void update(final LineEvent event) {
final Type eventType = event.getType();
if (eventType == Type.STOP || eventType == Type.CLOSE) {
done = true;
notifyAll();
}
}