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

587
Views
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
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!