public static void playSoundFromStream(final Factory<InputStream> streamProducer) {
new Thread(new Runnable() {
// The wrapper thread is unnecessary, unless it blocks on the
// Clip finishing; see comments.
@Override
public void run() {
try {
Clip clip = AudioSystem.getClip();
InputStream stream = streamProducer.create();
if (!stream.markSupported()) stream = new BufferedInputStream(stream);
AudioInputStream inputStream = AudioSystem.getAudioInputStream(stream);
clip.open(inputStream);
clip.start();
} catch (Exception ignore) {
LOG.info(ignore);
}
}
},"play sound").start();
}
UIUtil.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:intellij-ce-playground
作者:
评论列表
文章目录