/**
* Creates a new Sound instance by the specified file path. Loads the sound
* data into a byte array and also retrieves information about the format of
* the sound file.
*
* Note that the constructor is private. In order to load files use the static
* methods {@link #find(String)} or {@link #load(String)} methods depending on
* whether you already loaded the sound or not.
*
* @param is
* The input stream to load the sound from.
*/
private Sound(InputStream is, String name) {
this.name = name;
try {
AudioInputStream in = AudioSystem.getAudioInputStream(is);
if (in != null) {
final AudioFormat baseFormat = in.getFormat();
final AudioFormat decodedFormat = this.getOutFormat(baseFormat);
// Get AudioInputStream that will be decoded by underlying VorbisSPI
in = AudioSystem.getAudioInputStream(decodedFormat, in);
this.stream = in;
this.streamData = StreamUtilities.getBytes(this.stream);
this.format = this.stream.getFormat();
}
} catch (final UnsupportedAudioFileException | IOException e) {
log.log(Level.SEVERE, e.getMessage(), e);
}
}
Sound.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:litiengine
作者:
评论列表
文章目录