如何提取id3标签从本地上传的mp3通过filerreference ?(AS3)



在AS3(对于flash)中,我们可以使用filerreference类来浏览本地mp3文件并将数据传递给ByteArray。但是,我们如何以这种方式提取id3标签呢?

(有一个外部库http://www.emanuelz.com.mx/blog/parsing-local-mp3-with-filereference-and-audiofx-library-106可以将字节数组解析为声音对象,但是缺少id3标记)。当你调用sound。id3。

你应该加载ByteArray,然后创建一个新的Sound对象,创建一个ID3事件监听器,并调用loadCompressedDataFromByteArray(),这将使Flash解析加载的文件为MP3,如果它有ID3标签,事件将被调度,允许你读取ID3数据。

var themp3:Sound=new Sound();
themp3.addEventListener(Event.ID3,getid3);
themp3.loadCompressedDataFromByteArray(thefile,thefile.length);
// thefile is the ByteArray in question
function getid3(e:Event):void {
    if (e.target is Sound) {
        var s:Sound=e.target as Sound;
        trace(s.id3.songName);
    }
}

最新更新