Reading bytes from audio url

156 Views Asked by At

I've mp3 file on a url. I would like to stream it and manipulate the file in real-time, without downloading the whole file first. How can I do it?

I would like to do something like this pseudo code:

String fileUrl = "https://..file.mp3";

int chunkIndex = 0;
while (readNext) {
    bytes[] toPlay_chunk_short  = readBytesChunk(fileUrl, CHUNK_SIZE_STEREO, chunkIndex);

    byte[] manipulatedChunk = manipulateChunk(toPlay_chunk_short);

    audioTrack.write(manipulatedChunk, 0, manipulatedChunk.length);

    chunkIndex++;
}

And I need to implement 'readBytesChunk' method. I can replace the mp3 to wav on the url if it helps.

0

There are 0 best solutions below