我读了How to play MP3 sound from buffer (ByteArray/Stream) in ActionScript 3?。真的很想这样做。
我的代码:
private function playBase64(content:String):void {
var mp3Bytes:ByteArray;
var mp3Sound:Sound = new Sound();
mp3Bytes = Base64.decodeToByteArray(content);
mp3Bytes.position = 0;
mp3Sound.loadCompressedDataFromByteArray(mp3Bytes, mp3Bytes.length);
mp3Sound.play();
}
但我明白了:
Warning: Running "mxmlc:all" (mxmlc) task
>> Error: Command failed: /Users/michaeljin/git/yinlang/training/node_modules/flex-sdk/lib/flex_sdk/bin/mxmlc -debug=true -optimize=true -library-path=client/assets/flash/libs -output client/assets/flash/YLSoundPlayer.swf -- client/assets/flash/YLSoundPlayer.as
>> /Users/michaeljin/git/yinlang/training/client/assets/flash/YLSoundPlayer.as(59): col: 16 Error: Call to a possibly undefined method loadCompressedDataFromByteArray through a reference with static type flash.media:Sound.
>>
>> mp3Sound.loadCompressedDataFromByteArray(mp3Bytes, mp3Bytes.length);
>> ^
Warning: FAILED Use --force to continue.
Aborted due to warnings.
编辑:发现它适用于mxmlc 4.6,但不适用于4.0
答案 0 :(得分:0)
您正在定位FP版本< 11,目标Flash Player 11至少要使用此方法。