Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda