2011-08-16 122 views
0

那么我做了这个声音类与剪辑一起工作,我注意到大文件的问题。我看到人们一直在谈论一个称为BigClip 的类,它与Clip只是能够处理大文件相同...我在哪里可以得到BigClip?

我的问题是我在哪里可以得到那个类..我注意到它不符合正常java的XD 还怎么我implent到我的代码..

这里是我的代码:

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); 
    } 


    }   
+1

在枪支和弹药? –

+1

因为他开发了它,所以请问@ [Andrew Thompson](http://stackoverflow.com/users/418556/andrew-thompson) – MByD

+0

我怎么会让他失望? – Amit

回答

2

BigClip的代码显示在我的answer to this question

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