Package Exports
- audio-type
- audio-type/audio-type.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (audio-type) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
audio-type

Detect the audio type of a ArrayBuffer/Uint8Array
Install
$ npm i audio-type
Usage
Node.js
import readChunk from 'read-chunk'; // npm install read-chunk
import audioType from 'audio-type';
var buffer = readChunk.sync('meow.wav', 0, 12);
audioType(buffer);
//=> wav
Browser
import audioType from './audio-type.js'
var xhr = new XMLHttpRequest();
xhr.open('GET', 'meow.flac');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
audioType(this.response);
//=> flac
};
xhr.send();
API
audioType(buffer)
Returns: 'mp3'
, 'oga'
, 'flac'
, 'wav'
, 'm4a'
, 'opus'
, 'qoa'
buffer
Type: buffer
(Node.js), arrayBuffer
, uint8array
It only needs the first 12 bytes.
License
MIT • ॐ