Album art of music file

泄露秘密 提交于 2019-12-23 05:39:27

问题


Is There any way by which we can have album art of any music file , i am able to extract file detail like album name , length , author , genre , track info. But i am intresred in to showing album art image. Please help


回答1:


Apparently someone on this page managed to write some code to extract the image's data as a ByteArray, then finally load it through a Loader object. Here's the code they came up with:

var binaryData:ByteArray;
var file:URLLoader = new URLLoader(new URLRequest("test.mp3"));
var finalData:ByteArray = new ByteArray;
var byteCon:Loader = new Loader;
var offset:int; var rLength:int;
var found:Boolean = false;
var end:Boolean = false;
file.dataFormat = URLLoaderDataFormat.BINARY;
file.addEventListener(Event.COMPLETE, handleComplete);
function handleComplete(e:Event):void{
    binaryData = file.data as ByteArray;
    binaryData.position = 0;
    //get offset and length
    while(!found){
        var pos:int = binaryData.readUnsignedInt();
        if(pos == 0x41504943){
            offset = binaryData.position + 20;
        }
        if(pos == 0){
            if (!found){
                rLength = binaryData.position - 1 - offset;
                if(rLength > 5000){
                    found = true;
                }
            }    
        }
        binaryData.position = binaryData.position - 3;
    }
    finalData.writeBytes(binaryData, offset, rLength);
    finalData.position = 0;
    byteCon.loadBytes(finalData);
    addChild(byteCon);
}

Of course this is talking about MP3s specifically, although you might be able to adapt it for other formats.



来源:https://stackoverflow.com/questions/11718051/album-art-of-music-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!