List of usage examples for com.badlogic.gdx.audio.io VorbisDecoder VorbisDecoder
public VorbisDecoder(FileHandle file)
From source file:paulscode.sound.codecs.CodecVorbis.java
/** * Prepares an input stream to read from. If another stream is already opened, * it will be closed and a new input stream opened in its place. * * @param handle FileHandle to an ogg file to stream from. * @return False if an error occurred or if end of stream was reached. *///from w w w .j a va 2 s . com public boolean initialize(FileHandle handle) { initialized(SET, false); if (this.decoder != null) { this.decoder.dispose(); this.decoder = null; } samples = null; FileHandle base = Gdx.app.getType() == Application.ApplicationType.Android ? Gdx.files.local("") : Gdx.files.external(""); FileHandle tmpDir = base.child("tmp"); if (!tmpDir.exists()) { tmpDir.mkdirs(); } FileHandle f = tmpDir.child(handle.name()); if (!f.exists()) { handle.copyTo(f); } this.decoder = new VorbisDecoder(Gdx.files.absolute(f.file().getAbsolutePath())); endOfStream(SET, false); int channels = this.decoder.getChannels(); int rate = this.decoder.getRate(); pcmFormat = new PcmFormat(rate, channels); this.samples = new short[SoundSystemConfig.getStreamingBufferSize()]; initialized(SET, true); return true; }