aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
738 stars 128 forks source link

How to show multiple pictures! #166

Closed akagiharu closed 1 year ago

akagiharu commented 1 year ago

Hello, I am trying to show multiple pictures of the album, but I only get one, can you guys help me in how to make appearing multiple pictures?

const fileInput = document.getElementById("local_music");
const fileList = [];

for (var i = 0; i < fileInput.files.length; i++) {
jsmediatags.read(fileInput.files[i], {
    onSuccess: function(tag) {
        const data = tag.tags.picture.data;
        const format = tag.tags.picture.format;
        var base64String = "";

        for (var j = 0; j < data.length; j++) {
                       base64String += String.fromCharCode(data[j]);
        }

        $(".menu_content_body > .local_music_list").append('<tr><td class="song_thumbnail_item"><img src="data:' + format + ';base64,' + window.btoa(base64String) + '" width="50" height="50" /></td><td class="song_title_item">' + tag.tags.title + '</td><td class="song_artist_item">' + tag.tags.artist + '</td></tr>');
    },
    onError: function(error) {
        console.log(error);
    }
});