如何在 ActionScript 3 中从缓冲区(ByteArray/Stream)播放 MP3 声音?

2024-04-01

所以..我有一个MP3 数据缓冲区(如果我保存此缓冲区并将其命名为 buffer.mp3,它就会播放,但在这种情况下我不应该将其保存到文件系统)。我必须玩,但我不能,我该怎么办?


我尝试了下一个代码来播放该缓冲区(ByteArray \ Stream)(我从服务器获取MP3数据,获取数据的方法工作正常(在文本int等上进行测试)我调用返回的ByteArray readResponse,因为我有一些seading方法,它是这是回应)。

            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 https://github.com/claus/as3swf/wiki/play-mp3-directly-from-bytearray反而。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 ActionScript 3 中从缓冲区(ByteArray/Stream)播放 MP3 声音? 的相关文章

随机推荐