Skip to content

Function: nextIsoBox() ​

ts
function nextIsoBox(cursor): string | null;

Defined in: nextIsoBox.ts:23

Returns the type of the box at the position of a cursor, and moves the position to the first byte after that box.

The function parses no content of the box. The bytes from the old position to the new position are the complete box.

Parameters ​

cursor ​

IsoBoxReadCursor<IsoInt64>

The cursor at the first byte of a box.

Returns ​

string | null

The type of the box. The result is null at cursor.end. By default, the result is also null before a truncated box. With a null result, the position does not move.

Throws ​

RangeError if the cursor has the truncated option 'throw' and the box is truncated. The position does not move. The message has the position of the box and the cause.

Example ​

ts
const cursor = createIsoBoxReadCursor(load('mss_moof_tfdt.mp4'))
const types: string[] = []

for (let type = nextIsoBox(cursor); type; type = nextIsoBox(cursor)) {
	types.push(type) // moof, then mdat
}

A Streaming Video Technology Alliance project.