Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

583
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda