我在哪里可以获得 BigClip?

发布于 2024-11-29 21:10:15 字数 2527 浏览 1 评论 0原文

好吧,我制作了这个与剪辑一起使用的声音类,我注意到大文件的问题。我看到人们一直在谈论一个叫BigClip的类 这与 Clip 相同,只是能够处理大文件...

我的问题是我在哪里可以获得该类..我注意到它没有附带普通的 java XD 我还如何将它应用到我的代码中..

这是我的代码:

package org.game.engine;

import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

//Declaring all the fields
public class SoundEngine {
private Clip clip;
private  AudioInputStream sound;
private boolean stoped = false;
private DataLine.Info info;
private File soundFile;

//Constructor for a sound
 public SoundEngine(String filename) throws Exception {

// specify the sound to play
soundFile = new File(filename);
sound = AudioSystem.getAudioInputStream(soundFile);

// load the sound into a clip
info = new DataLine.Info(Clip.class, sound.getFormat());
clip = (Clip) AudioSystem.getLine(info);
System.out.println( Integer.toString(clip.getBufferSize()));
clip.open(sound);
}


    //Method do start/play the sound once
    public void start() throws LineUnavailableException, IOException, UnsupportedAudioFileException{
        if (stoped) {
             sound = AudioSystem.getAudioInputStream(soundFile);
             info = new DataLine.Info(Clip.class, sound.getFormat());
             clip = (Clip) AudioSystem.getLine(info);
             clip.open(sound);
             stoped = false;
        }
        clip.start();
    }


    //Method do pause the sound
    public void pause() {
        clip.stop();
    }



    //Method to fully stop the sound
    public void stop() {
        //make sure sound reloads it self because of the full stop
        stoped = true;
        //closes and drains
        clip.close();
        clip.drain();  
    }



    //Methd for looping sounds
    public void loop() throws UnsupportedAudioFileException, LineUnavailableException, IOException {
          if (stoped) {
              //reloads the sound incase the sound is fully stoped
                     sound = AudioSystem.getAudioInputStream(soundFile);
                     info = new DataLine.Info(Clip.class, sound.getFormat());
                     clip = (Clip) AudioSystem.getLine(info);
                     clip.open(sound);
                     stoped = false;
          }
          //starts the looping
        clip.loop(Clip.LOOP_CONTINUOUSLY);
    }


   }        

Well I made this sound class that works with clips and i noticed the problem with large files. I saw that people have been talking about a class called BigClip
which is the same as Clip just capable of handling big files...

My question is where can i get that class.. I noticed it doesnt come with normal java XD
also how to i implent it into my code..

here is my code:

package org.game.engine;

import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

//Declaring all the fields
public class SoundEngine {
private Clip clip;
private  AudioInputStream sound;
private boolean stoped = false;
private DataLine.Info info;
private File soundFile;

//Constructor for a sound
 public SoundEngine(String filename) throws Exception {

// specify the sound to play
soundFile = new File(filename);
sound = AudioSystem.getAudioInputStream(soundFile);

// load the sound into a clip
info = new DataLine.Info(Clip.class, sound.getFormat());
clip = (Clip) AudioSystem.getLine(info);
System.out.println( Integer.toString(clip.getBufferSize()));
clip.open(sound);
}


    //Method do start/play the sound once
    public void start() throws LineUnavailableException, IOException, UnsupportedAudioFileException{
        if (stoped) {
             sound = AudioSystem.getAudioInputStream(soundFile);
             info = new DataLine.Info(Clip.class, sound.getFormat());
             clip = (Clip) AudioSystem.getLine(info);
             clip.open(sound);
             stoped = false;
        }
        clip.start();
    }


    //Method do pause the sound
    public void pause() {
        clip.stop();
    }



    //Method to fully stop the sound
    public void stop() {
        //make sure sound reloads it self because of the full stop
        stoped = true;
        //closes and drains
        clip.close();
        clip.drain();  
    }



    //Methd for looping sounds
    public void loop() throws UnsupportedAudioFileException, LineUnavailableException, IOException {
          if (stoped) {
              //reloads the sound incase the sound is fully stoped
                     sound = AudioSystem.getAudioInputStream(soundFile);
                     info = new DataLine.Info(Clip.class, sound.getFormat());
                     clip = (Clip) AudioSystem.getLine(info);
                     clip.open(sound);
                     stoped = false;
          }
          //starts the looping
        clip.loop(Clip.LOOP_CONTINUOUSLY);
    }


   }        

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红玫瑰 2024-12-06 21:10:15

BigClip 的代码显示在我的答案中对于这个问题

有必要编译它供您自己使用。没有可以添加到类路径中的预构建 Jar。 (好吧,有一个预先构建的 Jar,但不是我提供给其他人使用的 - 自己酿造)。

The code of BigClip is shown on my answer to this question.

It is necessary to compile it for your own use. There is no pre-built Jar you can add to the class-path. (OK, there is a pre-built Jar, but not that I am offering for others to use - brew your own).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文