4

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

Ernesto Campohermoso
  • 7,213
  • 1
  • 40
  • 51
Alec French
  • 61
  • 1
  • 6

1 Answers1

3

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));
alijandro
  • 11,627
  • 2
  • 58
  • 74