aadsm / JavaScript-ID3-Reader

ID3 tags reader in JavaScript (ID3v1, ID3v2 and AAC)

Home Page:http://www.aadsm.net/libraries/id3/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error reading image for certain MP3s

dellagustin opened this issue · comments

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.

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

Solved when migrating to jsmediatags.

Good to hear!

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.

commented

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