flac-tag
v1.0.1
Published
FLAC metadata tagging library written in pure JavaScript
Downloads
6
Readme
flac-tag is an open sourced JavaScript library used to view and edit the metadata of FLAC audio files.
You can explore the examples directory to show how to use the library.
Features
- Read and write FLAC metadata
- Easy to use
Installation
You can download the ready-to-use script at
GitHub releases or you can
build your own by cloning this repository using git
then build it.
git clone https://github.com/eidoriantan/flac-tag
cd ./flac-tag
npm install
npm run build
You can also install this package by using npm
:
npm install --save flac-tag@latest
If you are using browser, you can just install the library through a CDN:
<script src="https://cdn.jsdelivr.net/npm/flac-tag@latest/dist/flac-tag.min.js">
Usage
For browsers:
<input type="file" id="input-file" accept="audio/x-flac">
<script>
const inputFile = document.getElementById('input-file')
inputFile.onchange = function () {
const reader = new FileReader()
reader.onload = function () {
const buffer = this.result
const flactag = new FLACTag(buffer)
flactag.read()
// Handle error if there's any
if (flactag.error !== '') throw new Error(flactag.error)
else console.log(flactag.metadata)
}
if (this.files.length > 0) {
reader.readAsArrayBuffer(this.files[0])
}
}
</script>
For Node.js:
const FLACTag = require('flac-tag')
const fs = require('fs')
const buffer = fs.readFileSync('/path/to/audio.flac')
const flactag = new FLACTag(buffer)
flactag.read()
// Handle error if there's any
if (flactag.error !== '') throw new Error(flactag.error)
else console.log(flactag.tags)
Support
If you had found a bug or any unexpected behavior, you can submit an issue through GitHub issues.