I am using vue and electron for an app that, among other things, plays audio. The app uses the standard 'Audio' constructor to play the first clip. Then the app rewrites the audio and tries to play the new audio (with the old name) again. Right now the old audio plays even after the new track has been saved.
How do I force the Audio component to reload the track?
const audio = new Audio(require("../sample.mp3"));
audio.play();
Thanks. Any help would be appreciated. I actually use a 'ended' callback which is not shown in the code snippet.
Your script does not have control over how the browser manages the cache.
This can be regulated by using cache headers that are sent by the server to instruct the browser how to manage the cache.
That aside, a common way to solve caching (as often done by bundlers) is to generate a new filename with unique hash for every version of the file.
This way you don't have to worry about cached files.