I'm probably just hoping for too much here, but does anyone know if there a universal method for rewinding/refreshing a URL instance? My problem is that various 3rd-party libraries acquire streams from URLs in many different ways. Some examples:
urlConnection = url.openConnection();
inputStream = urlConnection.getInputStream();
audioInputStream = AudioSystem.getAudioInputStream( new BufferedInputStream( url.openStream() ) );
cachedUrlStream = new CachedUrlStream( url );
logicalOggStream = (LogicalOggStream) cachedUrlStream.getLogicalStreams().iterator().next();
vorbisStream = new VorbisStream( logicalOggStream );
oggInputStream = new OggInputStream( vorbisStream );
Whenever the end of the stream is reached using any of the above methods, if I want to loop playback I must somehow rewind the streams to the beginning. Simply recreating the streams by rerunning any of the above examples does not work - the stream stays at its current position (i.e. the end of the stream). The only way I have found to "rewind" the stream is to discard the old URL instance and create a new one. This seems quite hackish to me, and it prevents the user from specifying their own URL instance to stream from (they must specify a filename or path instead).
I decided to post this question here, since anyone who has streamed audio from a URL may have some experience with this.