/** This method creates the streams from the URLs given in the constructor. */ private void init() { try { CachedUrlStream os = new CachedUrlStream(url[current]); loStream[current] = os.getLogicalStreams().iterator().next(); vStream[current] = new VorbisStream(loStream[current]); vStreamHdr = vStream[current].getIdentificationHeader(); audioFormat = new AudioFormat(vStreamHdr.getSampleRate(), 16, vStreamHdr.getChannels(), true, true); ais[current] = new AudioInputStream(new VorbisInputStream(vStream[current]), audioFormat, -1); initNext(); } catch (OggFormatException e) { e.printStackTrace(); } catch (VorbisFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
/** * This method gets the sample rate from the stream header. * * @return the sample rate of the current stream. */ public int getSampleRate() { return vStreamHdr.getSampleRate(); }