有没有什么办法,使我们可以有任何的音乐文件的专辑封面,我能够提取文件的细节就像专辑名称,长度,作者,流派,曲目信息。 但我intresred中显示专辑封面图片。 请帮忙
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
显然有人在的此页面设法写一些code提取图像的数据作为一个字节数组,然后最后通过一个Loader对象加载它。下面是他们想出了code:
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);
}
当然,这是在谈论具体的MP3,虽然你也许可以修改它以适应其他格式。
Of course this is talking about MP3s specifically, although you might be able to adapt it for other formats.
上一篇:我怎么能使用fdt.launch.Application对于AIR项目和放大器; FDT 5.5放大器、项目、我怎么能、launch
下一篇:AS3 Facebook的API 1.8 FacebookMobile.loginAPI、Facebook、login、FacebookMobile