PreloadedPlayback.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:QwickSound 作者:
/**
 * Creates a new {@code PreloadedPlayback}. PreloadedPlayback objects will
 * always be created by their associated PreloadedAudio object.
 * <p>
 * IMPLEMENTATION NOTE: Originally, the fetching of a new {@code Line} was
 * done in the {@code run} method, however testing revealed that latency is
 * decreased if a {@code Line} is acquired ahead of time, here in the
 * constructor.
 * 
 * @param audio
 *            The {@code Audio} that created this {@code PreloadedPlayback}.
 * @param audioFormat
 *            Specifies the particular arrangement of audio data.
 * @param audioBytes
 *            Holds the audio data from which a {@code Clip} will be
 *            created.
 * @param instanceID
 *            The {@code instanceID} of this {@code PreloadedPlayback}.
 */
protected PreloadedPlayback(Audio audio, AudioFormat audioFormat,
        byte[] audioBytes, long instanceID) {
    super(audio, instanceID);
    DataLine.Info info = new DataLine.Info(Clip.class, audioFormat);
    try {
        clip = (Clip) AudioSystem.getLine(info);
        clip.open(audioFormat, audioBytes, 0, audioBytes.length);
        if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
            volCtrl = (FloatControl) clip
                    .getControl(FloatControl.Type.MASTER_GAIN);
        } else {
            logger.warning("Master-Gain control is not supported."
                    + " Volume will be fixed at the default level.");
        }
    } catch (LineUnavailableException ex) {
        ex.printStackTrace();
    }
    clip.addLineListener(this);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号