Read id3 v2.4 tags with native Chrome Javascript/FileReader/DataView

后端 未结 3 1034
长发绾君心
长发绾君心 2021-02-02 07:13

Based on the answer of ebidel, one can read id3v1 tags by using jDataView:

document.querySelector(\'input[type=\"file\"]\').onchange = function (e) {
    var rea         


        
3条回答
  •  心在旅途
    2021-02-02 07:55

    You can try using id3 parser on github.

    Here's your updated fiddle that logs the tags object in the console

    With the id3.js included, all you need to do in your code is this:

    function readFile(){
       id3(this.files[0], function(err, tags) {
           console.log(tags);
       })
    }
    document.getElementsByTagName('input')[0].addEventListener('change',readFile,false);
    

    And here is the tags object as created by id3:

    {
      "title": "Stairway To Heaven",
      "album": "Stairway To Heaven",
      "artist": "Led Zeppelin",
      "year": "1999",
      "v1": {
        "title": "Stairway To Heaven",
        "artist": "Led Zeppelin",
        "album": "Stairway To Heaven",
        "year": "1999",
        "comment": "Classic Rock",
        "track": 13,
        "version": 1.1,
        "genre": "Other"
      },
      "v2": {
        "version": [3, 0],
        "title": "Stairway To Heaven",
        "album": "Stairway To Heaven",
        "comments": "Classic Rock",
        "publisher": "Virgin Records"
      }
    }
    

    Hope this helps!

提交回复
热议问题