JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1027
  • Score
    100M100P100Q108144F
  • License MIT

A modern ID3 parser written completely in JavaScript, making use of typed arrays and the HTML5 File API

Package Exports

  • id3js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (id3js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

id3.js - Javascript ID3 tag parser

id3.js is a JavaScript library for reading and parsing ID3 tags of MP3 files. id3.js can parse both ID3v1 and ID3v2 tags within a browser or Node environment. It also supports reading from local files (Node-only), same-origin URLs (AJAX) and File instances (HTML5 File API).

Example - AJAX

In your HTML:

<script src="id3.min.js"></script>

In your JavaScript:

id3('/audio/track.mp3', function(err, tags) {
    // tags now contains v1, v2 and merged tags
});

Example - NodeJS

var id3 = require('./id3');

id3({ file: './track.mp3', type: 'local' }, function(err, tags) {
    // tags now contains your ID3 tags
});

Note that here, the type is set to 'local' directly so that id3.js will attempt to read from the local file-system using fs.

Example - File API (HTML5)

In your HTML:

<script src="id3.min.js"></script>

In your JavaScript:

document.querySelector('input[type="file"]').onchange = function(e) {
    id3(this.files[0], function(err, tags) {
        // tags now contains your ID3 tags
    });
}

Tags format

Tags are passed as an object of the following format:

{
    "artist": "Song artist",
    "title": "Song name",
    "album": "Song album",
    "year": "2013",
    "v1": {
        "title": "ID3v1 title",
        "artist": "ID3v1 artist",
        "album": "ID3v1 album",
        "year": "ID3v1 year",
        "comment": "ID3v1 comment",
        "track": "ID3v1 track (e.g. 02)",
        "version": 1.0
    },
    "v2": {
        "artist": "ID3v2 artist",
        "album": "ID3v2 album",
        "version": [4, 0]
    }
}

The artist, title, album and year properties will always exist, though they will default to null. These particular fields are filled by both ID3v1 and ID3v2, the latter taking the priority.

The v2 object will contain a variable number of fields, depending on what is defined in the file, whereas the v1 object will always have the same fields (some of which may be null).

Images

On occasion, an MP3 may have an image embedded in the ID3v2 tag. If this is the case, it will be available through v2.image. This has a structure like so:

{
    "type": "cover-front",
    "mime": "image/jpeg",
    "description": null,
    "data": ArrayBuffer
}

As you can see, the data is provided as an ArrayBuffer. To access it, you may use a DataView or typed array such as Uint8Array.

License

MIT