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

589
Visualizações
How to extract cover art from mp3 file path (javascript)

I'm making an audio player and I want to condense the amount of space that the assets are taking up (mp3s and pictures). One way I thought of was putting the images in the mp3's metadata and accessing it from there, as you can then delete the normal image files and it would still work. I figured that getting that metadata from a local file path (like "./Music/SONGNAME.mp3") would be almost the same as getting the metadata from an <input type="file">. I have tried many different codes for this, the main gist seeming to be something like this:

jsmediatags.read(("./Music/" + song.audio), {
    onSuccess: function(tag) {
      var tags = tag.tags;
      console.log(tags);

      var image = tags.picture;
      if (image) {
        var base64String = "";
        for (var i = 0; i < image.data.length; i++) {
            base64String += String.fromCharCode(image.data[i]);
        }
        var base64 = "data:image/jpeg;base64," + window.btoa(base64String);
        main.thumbnail.setAttribute('src', base64);
      } else {
        main.thumbnail.style.display = "none";
      }
    }
});

("main" is an array of controls and stuff in the player, and song.audio is part of an object in an array of songs. "./Music/" is the folder path to my music)

Anyways, jsmediatags either don't accept file paths or I'm doing something incredibly wrong, because this code pretty much breaks my whole audio player.

If anyone can help, please do!!! (I've been working on this for an unhealthy amount of time...)

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