mse-audio-wrapper
Advanced tools
Comparing version 1.4.14 to 1.4.15
{ | ||
"name": "mse-audio-wrapper", | ||
"version": "1.4.14", | ||
"version": "1.4.15", | ||
"description": "Library to enable Media Source Extensions API playback for unsupported audio containers and raw codecs", | ||
@@ -47,7 +47,7 @@ "main": "src/MSEAudioWrapper.js", | ||
"dependencies": { | ||
"codec-parser": "2.4.3" | ||
"codec-parser": "2.5.0" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^3.0.1" | ||
"prettier": "^3.3.3" | ||
} | ||
} |
@@ -73,4 +73,8 @@ # MSE (Media Source Extensions) Audio Wrapper | ||
## Methods | ||
## API | ||
### `MSEAudioWrapper` | ||
_Default export_ | ||
`const wrapper = new MSEAudioWrapper("audio/mpeg", {minFramesPerSegment: 2, minBytesPerSegment: 576, preferredContainer: "webm"});` | ||
@@ -137,2 +141,16 @@ * `constructor` | ||
* Vorbis - `audio/webm;codecs="vorbis"` | ||
### `getWrappedMimeType(codec, container = WEBM)` | ||
_Named export_ | ||
Returns the mime-type that MSEAudioWrapper will produce given a passed in codec and container type. | ||
* `codec` *required* | ||
* Codec of the audio data to wrap | ||
* Accepts `aac`, `flac`, `mpeg`, `opus`, `vorbis` | ||
* `container` *optional* | ||
* Accepts `"webm"`, `"fmp4"` | ||
* Defaults to `"webm"` | ||
--- | ||
@@ -139,0 +157,0 @@ |
@@ -37,2 +37,19 @@ /* Copyright 2020-2021 Ethan Halsall | ||
export const getWrappedMimeType = (codec, container = WEBM) => { | ||
switch (codec) { | ||
case "mpeg": | ||
return `${AUDIO_MP4}"${MP3}"`; | ||
case "aac": | ||
return `${AUDIO_MP4}"${MP4A_40_2}"`; | ||
case "flac": | ||
return `${AUDIO_MP4}"${FLAC}"`; | ||
case "vorbis": | ||
return `${AUDIO_WEBM}"${VORBIS}"`; | ||
case "opus": | ||
return container === WEBM | ||
? `${AUDIO_WEBM}"${OPUS}"` | ||
: `${AUDIO_MP4}"${OPUS}"`; | ||
} | ||
}; | ||
export default class MSEAudioWrapper { | ||
@@ -170,15 +187,12 @@ /** | ||
_getContainer(codec) { | ||
this._mimeType = getWrappedMimeType(codec, this.PREFERRED_CONTAINER); | ||
switch (codec) { | ||
case "mpeg": | ||
this._mimeType = `${AUDIO_MP4}"${MP3}"`; | ||
return new ISOBMFFContainer(MP3); | ||
case "aac": | ||
this._mimeType = `${AUDIO_MP4}"${MP4A_40_2}"`; | ||
return new ISOBMFFContainer(MP4A_40_2); | ||
case "flac": | ||
this._mimeType = `${AUDIO_MP4}"${FLAC}"`; | ||
return new ISOBMFFContainer(FLAC); | ||
case "vorbis": | ||
this._mimeType = `${AUDIO_WEBM}"${VORBIS}"`; | ||
this.MAX_SAMPLES_PER_SEGMENT = 32767; | ||
@@ -188,8 +202,5 @@ return new WEBMContainer(VORBIS); | ||
if (this.PREFERRED_CONTAINER === WEBM) { | ||
this._mimeType = `${AUDIO_WEBM}"${OPUS}"`; | ||
this.MAX_SAMPLES_PER_SEGMENT = 32767; | ||
return new WEBMContainer(OPUS); | ||
} | ||
this._mimeType = `${AUDIO_MP4}"${OPUS}"`; | ||
return new ISOBMFFContainer(OPUS); | ||
@@ -196,0 +207,0 @@ } |
63617
1276
163
+ Addedcodec-parser@2.5.0(transitive)
- Removedcodec-parser@2.4.3(transitive)
Updatedcodec-parser@2.5.0