I play an audio file using jlGui BasicPlayer (it is based on Javasound). The file is in the Samba public folder, and I use Jcifs to access it. This gives me an InputStream
.
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication( ... ); SmbFile f = new SmbFile( ... ); SmbFileInputStream audioIn = new SmbFileInputStream(f); int bufSize = 8096;
I need to be able to position the pointer anywhere in the file, like any regular player. The only solution I thought of is to use a BufferedInputStream
and a combination of mark / reset / skip every time I need to move the pointer. As soon as I open the file and get Stream, I call the mark()
method, so that the subsequent reset()
will change at the beginning. Then with skip()
I can go wherever I want.
audioBIS.reset(); audioBIS.skip(newBytePosition);
My problem is that the skip () call works as desired only if I specify a buffer large enough to contain the entire file.
Is there a more efficient way to do this?
source share