aadsm / JavaScript-ID3-Reader

ID3 tags reader in JavaScript (ID3v1, ID3v2 and AAC)
http://www.aadsm.net/libraries/id3/
Other
555 stars 145 forks source link

Error reading image for certain MP3s #59

Closed dellagustin closed 8 years ago

dellagustin commented 8 years ago

I'm using this tool in a podcast subscription extension for chrome (https://chrome.google.com/webstore/detail/podstation/bpcagekijmfcocgjlnnhpdogbplajjfn).

I don't know if the issue is in the way I'm using it or in the tool itself, but for some MP3s the image is not being read properly.

One example is: http://200.147.22.65/meialua/podcast/meialuacast_078_donkey_kong.mp3 The image looks like: image

and should be: image

Here is the code I'm using

    ID3.loadTags(audioPlayer.src, function() {
        var tags = ID3.getAllTags(audioPlayer.src);

        if( "picture" in tags ) {
            var image = tags.picture;
            var base64String = "";
            for (var i = 0; i < image.data.length; i++) {
                    base64String += String.fromCharCode(image.data[i]);
            }

            tags.imageDataUrl = "data:" + image.format + ";base64," + window.btoa(base64String);

            callback(tags);
        }
    }, {
        tags: ["artist", "title", "album", "year", "picture"]
    });

where audioPlayer.src is the MP3 URL.

dellagustin commented 8 years ago

I just saw the information about jsmediatags. I'll retry with this other project.

dellagustin commented 8 years ago

Solved when migrating to jsmediatags.

aadsm commented 8 years ago

Good to hear!

gfmoore commented 1 year ago

For anyone else: I've found that it seems to struggle with multiple covers, throws an error: id3-reader Uncaught TypeError: Cannot read properties of undefined (reading 'data')

I used mp3tag to remove all but one image from files and all good. Looks like loads of editing ahead...:sigh

I like this code, it is the only code I've found that doesn't need Node or for the user to use a html file reader - it can read a file on the server directly - yay. It's taken me ages to get my head around, but it now does the job.

Zenaro commented 1 year ago

我已收到您的邮件 :)

gfmoore commented 1 year ago

Translates as: I have received your email ??? :)