Stream

Class to work with IO streams.

new Stream(url)

Creates a new stream instance. A Stream is an IO interface that can perform operation like 'Stream.read' and 'Stream.getNextPacket'.

Arguments:
url (String)

A stream starts with a scheme ('file://', 'http://' etc.)

getNextPacket()

Continue reading on a stream.

Returns: Stream | null

Returns 'null' if there is nothing more to read; Returns an the read bytes upon success.

seek(pos=0)

Go to a position in the stream, counted from the beginning of the stream.

Arguments:
pos (Integer)

Position to move to

start(packetlen=4)

Start reading on a stream.

Arguments:
packetlen (Integer)

Read maximal 'packetlen' bytes on the buffer

fileSize

  • Type: Integer

The size of the stream in bytes.

Event: onProgress(buffered, total)

Function that will be called when there is action on the Stream.

Parameters:
buffered (Integer)

The number of bytes that were buffered

total (Integer)

The number of bytes that were read

Event: onavailabledata()

Function that will be called when new data is available on the Stream.


Caught a mistake or want to contribute to the documentation? Edit this page on GitHub!