Created
January 26, 2023 14:33
-
-
Save dy/7d1ab517d6d2f6e206c3d61fc11abf8e to your computer and use it in GitHub Desktop.
Web Codec API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// web codec API (one day, hopefully) | |
const codecConfig = { | |
codec: 'mp3', | |
sampleRate: 48000, | |
numberOfChannels: 2, | |
description: new ArrayBuffer | |
} | |
let chunk = new EncodedAudioChunk({ | |
type: 'key', | |
data: arrayBuffer, | |
timestamp: 0 | |
}); | |
const audioDecoder = new AudioDecoder({ | |
output: audioData => console.log(123, audioData), | |
error: (...args) => console.log(args), | |
}); | |
let {config} = await AudioDecoder.isConfigSupported(codecConfig) | |
config.description = codecConfig.description | |
audioDecoder.configure(config) | |
audioDecoder.decode(chunk) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment