fix: confirm before generating audio peaks in browser, avoid lock-ups in Chrome
parent
a6c07c7810
commit
40381cf46d
|
@ -208,10 +208,21 @@
|
||||||
const peaks = await peaksReq.json();
|
const peaks = await peaksReq.json();
|
||||||
wavesurfer.load(`${API_URL}/raw/${address}`, peaks.data);
|
wavesurfer.load(`${API_URL}/raw/${address}`, peaks.data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(
|
console.warn(`Failed to load peaks: ${e}`);
|
||||||
`Failed to load peaks from server (${e}), falling back to client-side render...`
|
const entity = await fetchEntity(address);
|
||||||
);
|
console.log(entity.get("FILE_SIZE"));
|
||||||
wavesurfer.load(`${API_URL}/raw/${address}`);
|
if (
|
||||||
|
(entity.get("FILE_SIZE") || 0) < 20_000_000 ||
|
||||||
|
confirm(
|
||||||
|
"File is large (>20 MiB) and UpEnd failed to load waveform from server. Generating the waveform locally may slow down your browser. Do you wish to proceed anyway?"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
console.warn(
|
||||||
|
`Failed to load peaks, falling back to client-side render...`
|
||||||
|
);
|
||||||
|
|
||||||
|
wavesurfer.load(`${API_URL}/raw/${address}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue