Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ID3 tags reader in JavaScript (ID3v1 and ID3v2)
JavaScript
branch: master

This branch is 30 commits ahead, 36 commits behind aadsm:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
dist
src
README

README

JavaScript ID3 Reader
=====================

This library was originally made by Jacob Seidelin using ID3v1 for demo'ing his BinaryAjax library [http://www.nihilogic.dk/labs/id3/].
It was then extended by António Afonso to include the ID3v2 tag specification [http://www.id3.org/id3v2.4.0-structure], while I was working at Opera Software, in the context of the Unite Media Player application which was developed using server side JavaScript.
Then finally it was modified by James Hartig to reduce everything to a single file and supporting local files only.


Technical Information
---------------------

This library will only work on Chrome 7+, Firefox 3.6+, IE10, unless you send stringData instead of a file.
This library is not complete and there is still some features missing and/or going on:

* Unsynchronisation support
* Support for other types of charsets, at the moment only latin1, UTF-8 and UTF-16 are supported, these are the ones defined in the specification. However, the usage of local charsets has been common for a long time specially in Russia, Japan and China. This support can be achieved using [chardet](http://github.com/aadsm/jschardet) and a proper string reader function.
* Support for VBR (this requires loading a lot more of the file and checking lots of frames to compare)

How To Use It
-------------

In its simplest form:

var file = document.getElementById("upload").files[0];
if (file && file.type == "audio/mpeg" || file.type == "audio/mp3") {
    ID3.loadTags({file: file, success: function(tags) {
        alert(tags.artist + " - " + tags.title + ", " + tags.album);
    });
}

or by specifying shortcuts instead of cryptic tags:

ID3.loadTags({file: file, tags: {artist: 1, album: 1}, success: function(tags) {
    alert(tags.artist + " - " + tags.title + ", " + tags.album);
});


Documentation
-------------

`ID3.loadTags(options)`
    `options` - Parameters.
    `options.file` - The Blob(File) object of the file you wish to read.
    `options.tags` - The hashmap of tags and/or shortcuts to read from the ID3 block.
    `options.success` - The function that will be called on success.
    `options.error` - The function that will be called on error.
    `options.stringData` - Instead of sending file you can send a string.

Success will be sent an object like:
    {
        version: "1.1",
        title: string,
        artist: string,
        album: string,
        year: string,
        comment: string,
        track: string,
        genre: string,
        sampleRate: int(hz),
        bitRate: int(kbps)
    }

### Currently supported frames on ID3:

* APIC/PIC: Attached picture
* COMM/COM: Comments
* PCNT/CNT: Play counter
* T*: Text frames
* USLT/ULT: Unsychronized lyric/text transcription

### Shortcuts:

* title: TIT2/TT2
* artist: TPE1/TP1
* album: TALB/TAL
* year: TYER/TYE
* comment: COMM/COM
* track: TRCK/TRK
* genre: TCON/TCO
* picture: APIC/PIC
* lyrics: USLT/ULT

A comprehensive list of all tags defined in the specification can be found [here](http://www.id3.org/id3v2.3.0#head-e4b3c63f836c3eb26a39be082065c21fba4e0acc)

Authors
-------
* Jacob Seidelin
* António Afonso
* Joshua Kifer
* James Hartig
Something went wrong with that request. Please try again.