I am attempting to convert an InputStream to a SeekableByteChannel in order to stream in Open AL with LWJGL.
The current code is as follows thanks to the help of a demo online:
InputStream source = Thread.currentThread().
getContextClassLoader().
getResourceAsStream(resource);
ReadableByteChannel rbc = Channels.newChannel(source);
But I'm not sure, if at all possible, how I can seek through the OGG file in order to stream without converting it to a SeekableByteChannel
I'd be glad to supply more code if needed and thanks for any help in advance
Take a look at apache commons compress library, you can construct a SeekableInMemoryByteChannel from byte array. And convert InputStream to byte array is very easy also.
InputStream inputStream; // input stream
SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel
(IOUtils.toByteArray(inputStream));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With