clip.stop(); clip.flush(); clip.setFramePosition(0); clip.start();
AudioInputStream audioStream = AudioSystem.getAudioInputStream(url); clip = AudioSystem.getClip(); clip.open(audioStream); audioStream.close();
private Clip newClip(int sampleRate, int numChannels, byte[] pcmBytes) throws IOException { int bitsPerSample = 16; boolean isSigned = true, isBigEndian = false; AudioFormat format = new AudioFormat((float)sampleRate, bitsPerSample, numChannels, isSigned, isBigEndian); Clip clip = null; try { clip = AudioSystem.getClip(); clip.open(format, pcmBytes, 0, pcmBytes.length); } catch ( Exception ex ) { throw new IOException("failure during creation of Clip (" + ex + ")"); } return clip; }
java -enableassertions -jar BunnyGolf.jar debug
Decoding Ogg Vorbis bitstream Bitstream is 1 channel, 44100Hz Encoded by: Xiph.Org libVorbis I 20020717 Constructing clip, 20096 bytes of PCM data
public class MainWindow extends JFrame { ... GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); if ( device.isFullScreenSupported() ) { device.setFullScreenWindow((Window)this); mIsFullScreen = true; } ... if ( mIsFullScreen ) { createBufferStrategy(2); mBufferStrategy = getBufferStrategy(); } else { mGameCanvas.createBufferStrategy(2); mBufferStrategy = mGameCanvas.getBufferStrategy(); } ...}
Default Sound Mixer: Primary Sound Driver, version Unknown Version, max lines unrestricted Sound Mixer 0: Primary Sound Driver, version Unknown Version, max lines unrestricted Sound Mixer 1: ESS Maestro, version Unknown Version, max lines unrestricted Sound Mixer 4: Java Sound Audio Engine, version 1.0, max lines 32 Using Sound Mixer: Primary Sound Driver, version Unknown Version, max lines unrestricted