mp3tag.js Logo mp3tag.js
Home
Documentations
Downloads
Download v3.9.1
Properties
Property: error
Type: string

If an error was thrown from the last operation such as read or save, this returns the error message. It is recommended to check this property every operation.

Property: buffer
Type: ArrayBuffer | Buffer

The current buffer saved on the class.

Property: tags
Type: object

Tags object decoded from the Buffer. Please see Tags and Frames for the tags definitions.

Methods
Method: constructor(buffer[, verbose = false])
Method: read(options = {})
Return type: object

Reads the tags from the buffer. If the decoding was successful, this sets the tags with the decoded tags otherwise this sets the error property with error. This always returns the tags.

  // Default Options
  {
    id3v1: true, // include ID3v1
    id3v2: true // include ID3v2
  }
Static Method: readBuffer(buffer, options = {}, verbose = false)
Return type: object

This function is the same as the read except that this is a static function. If the decoding was unsuccessful, this throws an error.

Method: save(options = {})
Return type: ArrayBuffer | Buffer

Writes the tags to the buffer. If the encoding was successful, this writes the tags to the buffer then returns it otherwise this sets the error property with error. This always returns the buffer.

  // Default Options
  {
    strict: false, // Use strict mode when validating
    id3v1: { include: false }, // Add ID3v1 tags to buffer
    id3v2: {
      include: true, // Add ID3v2 tags to buffer
      unsynch: false, // Use unsynchronisation scheme
      version: defaultVersion, // ID3v2 major version
      padding: 2048 // Number of null bytes added after ID3v2 tag
    }
  }
Static Method: writeBuffer(buffer, tags, options = {}, verbose = false)
Return type: ArrayBuffer | Buffer

This function is the same as the save except that this is a static function. If the encoding was unsuccessful, this throws an error.

Method: remove()
Return type: boolean

Removes all the tags from the buffer. This always return true.

Method: getAudio()
Return type: ArrayBuffer | Buffer

Gets the audio buffer from the buffer.

Static Method: getAudioBuffer(buffer)
Return type: ArrayBuffer | Buffer

This function is the same as the getAudio except that this is a static function.