fix(player): load files sequentially (sinse the throughput is common)

This commit is contained in:
Alex Kaminskii 2023-01-27 17:07:45 +01:00 committed by Taha Yassine Kraiem
parent b0d0d47da2
commit c26706cba4

View file

@ -12,14 +12,10 @@ export async function loadFiles(
if (!urls.length) {
throw NO_URLS
}
const fileLoads = urls.map((url, index) =>
// loads can start simultaneously
window.fetch(url).then(r => processAPIStreamResponse(r, index === 0))
)
try {
for (let fileLoad of fileLoads) {
// binary data should be added sequentially
const data = await fileLoad
for (let url of urls) {
const response = await window.fetch(url)
const data = await processAPIStreamResponse(response, url !== url[0])
onData(data)
}
} catch(e) {