- var AudioContext = window.AudioContext || window.webkitAudioContext;
- var ctx;
- export async function play(chunk) {
- if (!ctx) {
- ctx = new AudioContext();
- }
- const source = ctx.createBufferSource();
- source.buffer = await ctx.decodeAudioData(chunk.buffer);
- source.connect(ctx.destination);
- source.ended = () => { source.disconnect(ctx.destination); }
- source.start(0);
- }
|