M
M
mi1ord2019-12-02 17:02:37
JavaScript
mi1ord, 2019-12-02 17:02:37

How to get audio as chunks?

Good afternoon.
The problem is the following.
I am receiving audio from API as an arrayBuffer.

const response = await fetch(someUrl)
return response.arrayBuffer()

Next, this arrayBuffer is decoded using AudioContext.decodeAudioData and what came out (for example,
AudioBuffer {length: 5209312, duration: 118.12498866213151, sampleRate: 44100, numberOfChannels: 2}
) is given to the class that builds the wave (just like in the wavesurfer.js library, only simpler).
The problem is that audios that are longer than half an hour can crash the browser on mobile devices.
As far as I understand, the default tag loads the audio file in small pieces.
Can this be done for audio files that are loaded with fetch?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question