AS3 mp3 导入错误:参数的 AMF 编码不能超过 40K。

3
注意:我已经看到了在Error #2084-The AMF Encoding of the arguments cannot exceed 40K中的其他问题。我的问题不同。我的数组不是0,而且小于40960。
我的代码很简单。我从这个链接获取了这个MP3录音 fla:http://www.jordansthings.com/blog/?p=5 它使用shinemp3编码器。
我只是想播放录制的声音,而不是保存它。所以我在保存记录文件的按钮上添加了以下内容:
private function onWavClick(e:MouseEvent)
    {           
        // WRITE ID3 TAGS
        var sba:ByteArray = mp3Encoder.mp3Data;
        sba.position =  sba.length - 128
        sba.writeMultiByte("TAG", "iso-8859-1");
        sba.writeMultiByte("Microphone Test 1-2, 1-2      "+String.fromCharCode(0), "iso-8859-1");  // Title
        sba.writeMultiByte("jordansthings                 "+String.fromCharCode(0), "iso-8859-1");  // Artist           
        sba.writeMultiByte("Jordan's Thingz Bop Volume 1  "+String.fromCharCode(0), "iso-8859-1");  // Album        
        sba.writeMultiByte("2010" + String.fromCharCode(0), "iso-8859-1");                          // Year
        sba.writeMultiByte("www.jordansthings.com         " + String.fromCharCode(0), "iso-8859-1");// comments
        sba.writeByte(57);                                                                      

        //new FileReference().save(sba, "FlashMicrophoneTest.mp3") // this saves the file. I don't need it.
        // my addition
        var snd:Sound = new Sound();
        var channel:SoundChannel = new SoundChannel();
        trace(sba.length);
        snd.loadCompressedDataFromByteArray(sba,sba.length);

        channel = snd.play();
    }

此外:即使这样可行...我也无法加载大于40K的数组?
2个回答

3
在调用loadCompressedDataFromByteArray之前,您应该将ByteArray的位置设置为0。例如:
sba.position = 0;
snd.loadCompressedDataFromByteArray(sba,sba.length);

我注意到在我的应用程序中,ByteArray的bytesAvailable为0。这是因为ByteArray的位置位于ByteArray的末尾。错误消息很令人困惑,因为它说你超出了40K,但实际上并没有超出。其应该说明从ByteArray中没有加载任何内容。
此外,我可以确认我可以加载大于40K的ByteArray。我测试了大小为126KB的mp3 ByteArray。

0
在我的情况下,问题不是我想要读取的ByteArray的大小。我可以毫无问题地读取和播放30 Mb的mp3文件(我知道这很多!)。问题是我多次读取文件,而在第一次之后,ByteArray的位置就在末尾。因此,每次想要读取该ByteArray时,您都必须重新启动位置为0。出于安全考虑,我认为这是一个好习惯。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接