本文整理了Java中javax.sound.sampled.Clip.isActive()
方法的一些代码示例,展示了Clip.isActive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Clip.isActive()
方法的具体详情如下:
包路径:javax.sound.sampled.Clip
类名称:Clip
方法名:isActive
暂无
代码示例来源:origin: marytts/marytts
public void run() {
System.err.println("Timer task running");
if (!clip.isActive() // already stopped?
|| clip.getFramePosition() >= endFrame) {
System.err.println("Timer task stopping clip.");
clip.stop();
this.cancel();
}
}
}
代码示例来源:origin: marytts/marytts
public void run() {
System.err.println("Timer task running");
if (!clip.isActive() // already stopped?
|| clip.getFramePosition() >= endFrame) {
System.err.println("Timer task stopping clip.");
clip.stop();
this.cancel();
}
}
}
代码示例来源:origin: marytts/marytts
public void actionPerformed(ActionEvent e) {
synchronized (clip) {
if (clip.isActive()) {
System.err.println("Stopping clip.");
clip.stop();
} else {
System.err.println("Rewinding clip.");
if (Double.isNaN(positionCursor.x)) { // no cursor, play from start
clip.setFramePosition(0);
} else { // play from cursor position
clip.setFramePosition(X2indexX(positionCursor.x));
}
if (!Double.isNaN(rangeCursor.x)) { // range set?
System.err.println("Setting timer task");
int endFrame = X2indexX(rangeCursor.x);
timer.schedule(new ClipObserver(clip, endFrame), 50, 50);
}
System.err.println("Starting clip.");
clip.start();
}
}
}
});
代码示例来源:origin: marytts/marytts
public void actionPerformed(ActionEvent e) {
synchronized (clip) {
if (clip.isActive()) {
System.err.println("Stopping clip.");
clip.stop();
} else {
System.err.println("Rewinding clip.");
if (Double.isNaN(positionCursor.x)) { // no cursor, play from start
clip.setFramePosition(0);
} else { // play from cursor position
clip.setFramePosition(X2indexX(positionCursor.x));
}
if (!Double.isNaN(rangeCursor.x)) { // range set?
System.err.println("Setting timer task");
int endFrame = X2indexX(rangeCursor.x);
timer.schedule(new ClipObserver(clip, endFrame), 50, 50);
}
System.err.println("Starting clip.");
clip.start();
}
}
}
});
代码示例来源:origin: com.googlecode.playn/playn-java
@Override
protected boolean playingImpl() {
return impl.isActive();
}
代码示例来源:origin: io.playn/playn-java-base
@Override
protected boolean playingImpl() {
return impl.isActive();
}
代码示例来源:origin: threerings/playn
@Override
protected boolean playingImpl() {
return impl.isActive();
}
代码示例来源:origin: playn/playn
@Override
protected boolean playingImpl() {
return impl.isActive();
}
代码示例来源:origin: com.github.bloodshura/shurax-assets
@Override
// TODO Gambiarra...
public boolean isPlaying() {
/* Workaround, since after clip.start() the sound have a small delay before starting to act. Used on Sound.waitUntilDone(). */
if (justPlayed != 0L) {
if (XSystem.millis() - justPlayed <= 150L) {
return true;
}
this.justPlayed = 0L;
}
return clip != null && clip.isActive();
}
代码示例来源:origin: nroduit/Weasis
void tick() {
if (clip.isActive()) {
audioPosition = (int) (clip.getMicrosecondPosition() / 1000);
progress.setValue(audioPosition);
} else {
reset();
}
}
代码示例来源:origin: com.github.nifty-gui/nifty-pauls-soundsystem
/**
* Used to determine if a channel is actively playing a source. This method
* will return false if the channel is paused or stopped and when no data is
* queued to be streamed.
* @return True if this channel is playing a source.
*/
@Override
public boolean playing()
{
switch( channelType )
{
case SoundSystemConfig.TYPE_NORMAL:
if( clip == null )
return false;
return clip.isActive();
case SoundSystemConfig.TYPE_STREAMING:
if( sourceDataLine == null )
return false;
return sourceDataLine.isActive();
default:
return false;
}
}
}
代码示例来源:origin: stackoverflow.com
if (clip.isActive()) {
代码示例来源:origin: stackoverflow.com
public static synchronized void playSound(final String folder, final String name) {
new Thread(new Runnable() { // the wrapper thread is unnecessary, unless it blocks on the Clip finishing, see comments
@Override
public void run() {
Clip clip = null;
AudioInputStream inputStream = null;
try{
do{
if(clip == null || inputStream == null){
clip = AudioSystem.getClip();
}
inputStream = AudioSystem.getAudioInputStream(SoundP.class.getResource(folder + "/" + name));
if(clip != null && !clip.isActive()){
inputStream = AudioSystem.getAudioInputStream(SoundP.class.getResource(folder + "/" + name));
}
clip.open(inputStream);
clip.start();
}while(clip.isActive());
inputStream.close();
} catch (LineUnavailableException e) {
e.printStackTrace();
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
代码示例来源:origin: blurpy/kouchat
/**
* Plays the loaded audio file if sound is enabled, and
* it's not already playing. If nothing has been played for
* 5 seconds the sound resource is released.
*/
public synchronized void beep() {
if (settings.isSound()) {
if (audioClip == null || !audioClip.isActive()) {
if (audioClip == null) {
open();
} else {
audioClip.setFramePosition(0);
}
if (audioClip != null) {
audioClip.start();
closeTime = System.currentTimeMillis() + WAIT_PERIOD;
if (closeTimer == null) {
closeTimer = new Thread(new CloseTimer(), "SoundBeeperCloseTimer");
closeTimer.start();
}
}
else {
LOG.log(Level.SEVERE, "Audio clip missing.");
}
}
}
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.server.ui
public void run() {
// set gain
FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
double value = volume / 20.0;
float dB = (float) (Math.log(value==0.0?0.0001:value)/Math.log(10.0)*20.0);
gainControl.setValue(dB);
Trace.trace(Trace.FINEST, "start");
clip.start();
try {
sleep(99);
} catch (Exception e) {
// ignore
}
while (clip.isActive()) {
try {
sleep(99);
} catch (Exception e) {
break;
}
}
clip.stop();
clip.close();
Trace.trace(Trace.FINEST, "stop");
}
};
内容来源于网络,如有侵权,请联系作者删除!