问题描述
我有一个包含嵌入在它的声音(不同的编码)遗留的文件格式。我希望能够在Flash(空气?)播放这些声音通过读取声音字节出来的文件和实例化一个Sound对象他们。
I have a legacy file format that contains sounds embedded in it (in various encodings). I would like to be able to play these sounds in Flash (Air?) by reading the sound bytes out of the file and instantiating a Sound object with them.
如果声音unen codeD(如原始的PCM),我发现,我可以使用新的Flex 4的SampleDataEvent.SAMPLE_DATA事件要播放的声音。
If the sound is unencoded (e.g., raw pcm), I've found that I can use the new flex 4 SampleDataEvent.SAMPLE_DATA event to play the sound.
但是,如果声音是EN codeD(如MP3),那么我无所适从。预期的SampleDataEvent.SAMPLE_DATA声音必须是原始的PCM。从我所看到的,连接codeD声音只能通过[嵌入]荷兰国际集团他们被实例化,或者通过使用调用Sound.load()的URLRequest。
However, if the sound is encoded (e.g., mp3), then I'm at a loss. The sound expected by SampleDataEvent.SAMPLE_DATA has to be raw pcm. From what I've seen, encoded Sounds can only be instantiated by [Embed]ing them, or by using a URLRequest with Sound.load().
当然,还有第三条路? AMF或E4X?
Surely there's a third way? AMF or e4x?
推荐答案
有真的只有两个你去的路线。首先是写一个去codeR ActionScript中。您可以使用炼金术端口超过一些C / C ++ code,以使这项工作更容易显著(也可能是更好的性能)。这正是我是如何得到的Ogg Vorbis播放与Flash的工作。
There are really only two routes for you to go. The first is to write a decoder in ActionScript. You may be able to use Alchemy to port over some C/C++ code to make this job significantly easier (and possibly more performant). This is exactly how I got Ogg Vorbis playback to work with Flash.
另外一种选择是动态创建一个有效的SWF的ByteArray内。这SWF可能包含是由你的声音数据的嵌入声音对象。许多人都被拉断过类似的黑客攻击之前的Flash Player 10是可用的。我相信你可以找到一个很好的起点在安德烈·米歇尔和JOA艾伯特的PopForge codeBase的。
The other option is to dynamically create a valid SWF inside of a ByteArray. That SWF could contain an embedded sound object that was made up of your sound data. A number of folks have pulled off similar hacks in the past before Flash Player 10 was available. I believe you can find a good place to start in Andre Michelle's and Joa Ebert's PopForge codebase.
这篇关于在柔性,动态地从连接codeD字节加载的Sound对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!