aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
760 stars 127 forks source link

Support writing tags #183

Open BeeDice opened 5 months ago

BeeDice commented 5 months ago

My use case: I'm writing a PWA to manage a local library of music. I use jsmediatags to read tags client-side across multiple formats. As a user edits their library in the PWA, I'd like to offer the ability to write those changes back to the files on disk. Some client-side JS libraries like node-id3 support writing ID3 tags, but I would like to support as many tags as possible. Again, this is a PWA, so I can't use a server-side API to use taglib to get me updated bytes that I would then write back to local disk.

Proposal: rename the tag and file readers to indicate they support read/write. I suppose each reader would have their own way of "writing", each subclass implementing canWriteFile() and write(). Like, Xhr would send an OPTIONS request, Array/ArrayBuffer would update the in-memory arrays, Blob would create a new Blob with the updated tag data, and although I don't know Node or React files, I assume they have API's for opening the file in read-write mode. The tag readers probably remain unchanged, as they all can use the super class implementation of write(), which would create a byte array of UTF-16 or whatever the tag reader currently uses to read the tags.

aadsm commented 5 months ago

I'm still thinking about this. I need to get some time first to revisit some of the code and my own assumptions. It's not forgotten.