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

Read BPM data

simar88 opened this issue · comments

It is possible to read also BPM data!?

Yes, for ID3v2 that will be the tag "TBPM". ID3v1, on the other hand, does not support storing this information.

You can find all the tags available in ID3v2 here: http://id3.org/id3v2.3.0#Declared_ID3v2_frames
At this point in time the ID3 Reader supports all that start with a T (they are text tags), APIC, COMM, PCNT and USLT.

@aadsm problem comes with a different domain. I will explain better my point. I'm building an app using node-webkit. One of the main purpouses of the app is to manage and play mp3's and their ID3 tags. As u can understand node-webkit is every time generating a temporary path and music files is stored locally on the hard drive. Using the method loadTags() nothing happens...it seems that the callback is not called. I don't know what happens with the filereader.js file you use to load the file, but probably is something related to the fact that the song is not in the same domain.

Is there any chance to read tags in this way?

Thanks in advance and compliments for the lib.

I see, I never used node-webkit but you probably need to create a data reader that uses the fs node functions (or whatever API node-webkit gives you to read files), the loadTags by default will XHR and like you said you're maybe coming across x-domain issues.

Take a look at the FileAPI data reader to see how to implement one: https://github.com/aadsm/JavaScript-ID3-Reader/blob/master/src/filereader.js#L9-L17

You need to create a function that receives a (url, callback, errback) and that will call callback with a BinaryFile instance (or same interface).

You can easily add node-webkit support by passing in a dataReader. The only issue is that "BinaryFile" is not exported and available globally. @aadsm, what do you think about exporting BinaryFile?

ID3.loadTags(path, function () {
    var tags = ID3.getAllTags(path);
    console.log(tags.artist + ' - ' + tags.title);
}, {
    tags: ['title', 'artist'],
    dataReader: function (url, fncCallback, fncError) {
        var fs = require('fs');

        fs.readFile(url, {
            encoding: 'utf8'
        }, function (err, data) {
            if (err) {
                fncError(err);
            } else {
                fncCallback(new BinaryFile(data));
            }
        });
    },
    onError: function (error) {
        console.log(error);
    }
});

The BinaryFile is available globally, it's just not available in its minimized form because google closure renames it.