ApplicationMusicPlayer.java 文件源码

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

项目:Device-Mod-Apps 作者:
public void play() {
    if (clip != null) {
        if (progress != null) {
            progress.setMax((int) clip.getMicrosecondLength());

            if (progressUpdateThread == null) {
                progressUpdateThread = new Thread("Progressbar Update Thread") {
                    @Override
                    public void run() {
                        while (!Thread.interrupted()) {
                            progress.setProgress((int) clip.getMicrosecondPosition()); // /1000000
                        }
                    }
                };

                progressUpdateThread.start();
            }
        }

        float volume = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS);
        FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);        
        gainControl.setValue(20f * (float) Math.log10(volume));

        Minecraft.getMinecraft().getSoundHandler().stopSounds();
        if (isAlive()) {
            clip.start();
        } else {
            start();
        }
    } else {
        Minecraft mc = Minecraft.getMinecraft();

        mc.getSoundHandler().stopSounds();
        mc.getSoundHandler().playSound(listedSong.ps);

        start();
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号