API

read(path, callback)

The function you will most likely want to use. callback should have signature
callback(err, tag, audioProperties) where tag and audioProperties are
plain-old JavaScript objects. For the distinction between these and Tag, see
Tag below.

If there was an error reading the file, err will be non-null and tag and
audioProperties will be null.

If no tag was found, tag will be an empty object (falsy). tag can have the
following fields. node-taglib currently supports only the fields common to all
formats:

title (string)

album (string)

comment (string)

artist (string)

track (string)

year (integer)

genre (string)

If no audio properties could be read, audioProperties will be an empty object
(falsy). The following fields are available in audioProperties, all are
integers:

length

bitrate

sampleRate

channels

Writing audio properties is not supported.

tag(path, callback)

Read the tag from the file at pathasynchronously. The callback should have
signature (err, tag). On success, err will be null and tag will be
a Tag. If errors occurred, err will contain the error and
tag will be null. err will be an object with field code having the
integer error code (errno.h) and field message will have a string
representation.

tagSync(path)

Read the tag from the file at pathsynchronously. Returns a Tag. If
errors occurred, throws an exception.

Tag

NOTE: A Tag object should NOT be created using new. Instead use tag()
or tagSync()

A Tag object allows read-write access to all the meta-data fields. For valid
field names see read() above.

To get a value, simply access the field -- tag.artist.

To set a value, assign a value to the field -- tag.year = 2012. You will
have to call saveSync() to actually save the changes to the file on disc.

Large number of files

Due to TagLib's design, every Tag object in memory has to keep its backing
file descriptor open. If you are dealing with a large number of files, you will
soon run into problems because operating systems impose limits on how many
files a process can have open simultaneously. If you want to only read tags,
use read() instead as it will immediately close the file after the tag is
read.

Tag.save(callback)

Save any changes in the Tag meta-data to disk asynchronously. callback will
be invoked once the save is done, and should have a signature (err). err
will be null if the save was successful, otherwise it will be an object with
message having the error string and path having the file path.