闪光 - 通过音频数据的ByteArray的JavaScript [英] Flash - passing audio data ByteArray to javascript

查看:257
本文介绍了闪光 - 通过音频数据的ByteArray的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够与嵌入在我的网站上的Flash应用程序录制声音,这个声音将被保存到一个字节数组,我需要传递给启用Javascript才能张贴到我的服务器以及其他必需的数据。

I'm able to record sound with a Flash application embedded in my website, this audio is saved to a ByteArray, which I need to pass to Javascript in order to post to my server along with other required data.

我知道我可以使用AS3 ExternalInterface类使用Flash从Javascript通信,但是这将是合适的格式或变量类型的JavaScript举行字节数组,我怎么能保证我不会失去太多的音频数据时,这样做的?

I know I can use AS3 ExternalInterface class to communicate with Flash from Javascript, but what would be the appropriate format or variable type in javascript to hold the ByteArray, and how can I ensure that I won't lose much audio data when doing so?

推荐答案

也许这是不可能的,你出于某种原因我不知道,但如果不是这种情况,我会直接从ActionScript发布的数据(您可以发送二进制数据)。

Maybe it's not possible for you for some reason I'm not aware of, but if that's not the case, I'd post the data directly from Actionscript (you can send binary data).

无论如何,如果你要传递的数据,JS,最安全的方法是使用Base64编码的ByteArray。之后,你有不会有任何控件的字符串(读:有问题的)。字

Anyway, if you have to relay the data to JS, the safest way would be base64-encoding the ByteArray. After that you have a string that will not have any control (read: problematic) characters.

尺寸当然是东西要考虑到。我不知道什么是ExternalInterface的(我只用过它来传递数据的小ammounts)的限制,但你很有可能碰到硬限制存在。 LocalConnection对象为100 KB左右的限制,如果我没有记错(这些不相关的ExternalInterface的API - 至少不是直截了当地,但我提到它只是作为一个可能的限制,余数)。如果您正在使用原始音频,您的数据将是相当大的,所以你必须要弄清楚如何COM preSS它(DECOM preSS它在JS端或服务器)和也可能是,如何将其以块的形式发送,如发送一次全部将可能是不可能的,如果数据量太大。

Size is of course something to take into account. I don't know what are the limitations of ExternalInterface (I've only ever used it to pass small ammounts of data), but you'll most likely hit a hard limit there. LocalConnection objects have a limit of 100 kb or so if I recall correctly (these are not related to the ExternalInterface api -at least not directly- but I mention it just as a remainder of the possible limitations). If you're working with raw audio, your data will be rather big, so you'd have to figure out how to compress it (and decompress it in the JS end or in the server) and also, probably, how to send it in chunks, as sending it all at once will likely be impossible if the data is too big.

此外,如果可能的话,我会直接从ActionScript张贴和发送数据之前将至少使用ByteArray中的COM preSS方法。

Again, if possible, I'd post directly from Actionscript and would use at least the ByteArray's compress method before sending the data.

这篇关于闪光 - 通过音频数据的ByteArray的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆