我使用以下从声音对象中提取声音数据并将其存储在字节数组中。AS3 - 声音提取到bytearray - 进度处理程序
我要求整个MP3加载到ByteArray前进之前和下面的工作正常但是为了这个目的闪烁暂时挂起,而它提取该数据(2.4MB MP3)
有没有办法可以阻止它挂起来,即使用eventlistener来检查提取过程的进度?
iniSound();
function iniSound()
{
playLoadedSound(mp3);
}
function playLoadedSound(s:Sound):void
{
var bytes:ByteArray = new ByteArray();
s.extract(bytes, int(s.length * 44.1));
playSound(bytes);
}
function playSound(bytes:ByteArray)
{
//stop();
dynamicSound = new Sound();
dynamicSound.addEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData);
loadedMP3Samples = bytes;
numSamples = bytes.length/8;
phase = 0;
}
感谢,所以我提取音轨的一小部分,并尝试使用while循环的处理进度然而闪光灯仍然只是挂起,然后我得到只有在满足条件后才会有一组跟踪输出。无论如何,我可以阻止它悬挂并显示负载消息,而这是发生?代码是:function playLoadedSound(s:Sound):void { \t var bytes:ByteArray = new ByteArray(); \t while(s.extract(bytes,4096)) \t { \t \t trace(“loading”); \t} \t playSound(bytes); } – digitalpencil 2011-03-17 15:56:58
不要使用while循环,请使用ENTER_FRAME或TIMER – NemoStein 2011-03-29 17:24:31