I am using vuejs and electron. I was trying to get a file, that was changed on the main thread, to be played on the vuejs thread. I had a problem where the caching didn't allow me to load the audio file. I added a hash (a timestamp really) to the filename. I pass it to the vuejs thread with this code that starts out 'window.api.receive...' The details of the IPC are not included here.
I have edited my code some. I am now trying to use a scheme like this. Now I get: "Uncaught (in promise) DOMException: Failed to load because no supported source was found."
const it = this;
window.api.receive("playaudio", (data) => {
if (it.audio !== false) {
data = data.split("/").slice(-1);
data = `./${data[0]}`;
console.log(data + " <<" );
it.audio_play = new Audio() ;
it.audio_play.crossOrigin = 'anonymous';
it.audio_play.src = data;
it.audio_play.type = "audio/mp3";
it.audio_play.load();
it.audio_play.addEventListener("ended", this.endPlay);
const promise = it.audio_play.play();
promise
.then(() => {
// Audio is playing.
console.log("playing");
})
.catch((error) => {
console.log(error);
});
}
});
Now I'm thinking that maybe I should be putting my audio file in the 'dist' folder. If so I wonder if electron or vuejs will even allow me to open a mp3 file if I want to open it. I can get a mp3 to play once if I load it at the time that the vue page loads, but I cannot change it's contents.