I am creating Audio at runtime and then setting the source.
let snd = new Audio();
snd.src = "file.mp3";
It works in Edge every time. Occasionally, it fails in Chrome, especially when I am debugging. It only really fails on the first time I start debugging in a session, almost always working every time after. Once it works, it repeatedly works for that session.
Note the error is MEDIA_ERR_SRC_NOT_SUPPORTED, which I know is not true, because it works, typically, the second time.
From what I have read here on Stackoverflow, there may be a known problem with this for large sound files (which this is in my case).
So my solution is, refresh the page when an onerror is fired:
snd.onerror = _ => window.location.refresh(true);
Note the true.
When you do this true means you are refreshing from the server. false means you are refreshing from the cache.
QUESTION: Considering my problem, which should I be doing, true or false?
Because of the low fail-rate, this is a real pain to debug, so any advice will be much appreciated.
I think it is true. That worked every time. false only worked a few of the times. But as I say, since this is an intermittant error, it is very difficult to debug.