I'm developing a programm that streams music from the internet. When i stream a song, i don't have access to it's URL. I only get an input stream and some information like length in bytes and so forth. I want to implement a seekbar similar to those on youtube etc. Until now i've managed to display the seekbar as a JSlider with maximum being the length of the stream in bytes and the value changing according to the current position in bytes in the song.
Now BasicPlayer has a function called seek(long bytesToSkip) and i tried calling that, when the slider gets moved and released by user input. However seek() won't do anything. No log message, nothing. So i downloaded the source of BasicPlayer and found out, that seek(long bytesToSkip) calls skipBytes(long bytesToSkip) which checks if the data to be played is a file. If it's not, it'll do nothing.
So i removed that if clause to see where that would take me. Now I'm getting an exception at the line
initAudioInputStream();
This checks what kind of data it's dealing with and calls an appropriate method for that type of data. In my case
initAudioInputStream(InputStream inputStream) {
m_audioInputStream = AudioSystem.getAudioInputStream(inputStream);
m_audioFileFormat = AudioSystem.getAudioFileFormat(inputStream);
}
and there in the first of those two lines i get my exception. It's an EOFException, so i take it the stream hasn't "buffered" enough to get the audioInputStream. If that method requires the whole file, i guess i'm out of luck.
I really hope someone could help me make this work. I've been working on this for so long..