How to get <audio> tag information?

后端 未结 2 1981
闹比i
闹比i 2020-12-31 23:28

like title, subtitle, singer, Album, Bit rate etc..

wiki - MP3 tag infomation

wiki - ID3(mp3 metadata format)

I search a lot.. but I can\'t get answ

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 23:50

    It looks like you can with the right libraries! Reading ID3 tags with Javascript and here is the demo

    Using the ID3.js library, your Javascript would be similar to:

    // URL of the mp3 file (must be on the same domain!)
    var file = "mymusicfile.mp3";
    // define your own callback function
    function mycallback() {
        // either call the ID3.getAllTags([file]) function which returns an object holding all the tags
        alert(
            "All tags in this file: " + ID3.getAllTags(file).toSource()
        );
        // or call ID3.getTag([file], [tag]) to get a specific tag
        alert(
            "Title: " + ID3.getTag(file, "title") + " by artist: " + ID3.getTag(file, "artist")
        );
    }
    ID3.loadTags(file, mycallback);
    

    Based on the post in the first link I provided, it does not work in Opera browsers and is limited to ID3v1 which by the words of the poster:

    "it's only capable of reading (the rather lacking) ID3v1 tags since these are very simple compared to the more fleshed out and robust ID3v2 tags"

提交回复
热议问题