Skip to content

Instantly share code, notes, and snippets.

@dy
Created January 26, 2023 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dy/7d1ab517d6d2f6e206c3d61fc11abf8e to your computer and use it in GitHub Desktop.
Save dy/7d1ab517d6d2f6e206c3d61fc11abf8e to your computer and use it in GitHub Desktop.
Web Codec API
// 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