t1st3 / is-opus

Check if a Buffer/Uint8Array is an OPUS audio file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is-opus

NPM version Build Status

Check if a Buffer/Uint8Array is an OPUS audio file.

Install

$ npm install --save is-opus

Usage

Node.js

var readChunk = require('read-chunk'); // npm install read-chunk
var isOpus = require('is-opus');
var buffer = readChunk.sync('unicorn.opus', 0, 36);

isOpus(buffer);
//=> true

Browser

var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.opus');
xhr.responseType = 'arraybuffer';

xhr.onload = function () {
	isOpus(new Uint8Array(this.response));
	//=> true
};

xhr.send();

API

isOpus(buffer)

Accepts a Buffer (Node.js) or Uint8Array.

It only needs the first 36 bytes.

License

MIT © t1st3

About

Check if a Buffer/Uint8Array is an OPUS audio file.

License:MIT License


Languages

Language:JavaScript 100.0%