对于我正在进行的项目,我必须能够反向播放声音对象。我怎样才能在AS3中做到这一点?
答案 0 :(得分:1)
这在播放器10中是可行的,但它不是快速/简单的实现。您必须构建自己的自定义支持。让我们来看看:
var soundSource:Sound; //assuming this actually references a real sound file such as a MP3
var position:int = soundSource.bytesTotal;
var numBytesToReadEachSample:int = 8192;
var snd:Sound = new Sound();
snd.addEventListener(SampleDataEvent.SAMPLE_DATA, sampleData);
snd.play();
function sampleData(e:SampleDataEvent):void {
position -= numBytesToReadEachSample;
//here we read data from our source, and write it to the playing sound
e.data.writeBytes(soundSource.extract(position, numBytesToReadEachSample))
}
未经测试且未完成,但是您想要做的一般概念。希望它指出你正确的方向!
此处提供更多信息:http://www.adobe.com/livedocs/flex/3/langref/flash/events/SampleDataEvent.html#SampleDataEvent%28%29
祝你好运!