Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
vuejs/electron play mp3 on the fly

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!