所以..我有一个 MP3 数据缓冲区 (如果我保存这个缓冲区并将其命名为 buffer.mp3 它将播放,但在这种情况下我不应该将它保存到文件系统)。 我必须玩它,但我不能,我该怎么办?
我尝试了下一个代码来播放该缓冲区(ByteArray\Stream)(我从服务器获取 MP3 数据获取数据的方法工作正常(在文本 int 等上测试)我调用返回的 ByteArray readResponse 因为我有一些排序方法,它是这是回应)。
protected function Play(event:MouseEvent):void
{
var mySound:Sound = new Sound();
mySound.addEventListener(SampleDataEvent.SAMPLE_DATA, soundFill);
mySound.play();
}
public function soundFill(event:SampleDataEvent):void
{
event.data.writeBytes(readResponse.buffer, 0, readResponse.buffer.length);
}
最佳答案
这个不起作用,因为 SampleDataEvent.data 需要未压缩的原始样本数据,而不是 MP3。使用 https://github.com/claus/as3swf/wiki/play-mp3-directly-from-bytearray相反。
关于actionscript-3 - 如何从 ActionScript 3 中的缓冲区 (ByteArray/Stream) 播放 MP3 声音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1619773/