在 AS3 Flash/Flex 项目中嵌入 wav 文件?

发布于 2024-09-01 00:52:07 字数 482 浏览 10 评论 0原文

Flash IDE 能够嵌入多种类型的未压缩声音文件(包括 wav),并在发布时提供可选的压缩。

然而,[Embed] 标签似乎只允许嵌入 mp3 文件。嵌入未压缩的 wav 文件真的不可能,还是我错过了一些神奇的、未记录的 mimeType?

我希望得到类似的东西:

[Embed source="../../audio/wibble.wav" mimeType="audio/wav"]

...但是我得到了

no transcoder registered for mimeType 'audio/wav'

可以将 wav 或其他格式嵌入为八位字节流并在运行时解析,但我认为这是相当严厉的。

令我惊讶的是,尽管 Flash IDE 可以嵌入未压缩的声音数据,但 [Embed] 却不能,因为 swf 规范可以包含未压缩的声音数据。

有接受者吗?

The Flash IDE is capable of embedding many types of uncompressed sound files, including wav, and offers optional compression when publishing.

However, the [Embed] tag, only seems to allow embedding of mp3 files. Is it truly impossible to embed an uncompressed wav file, or am I missing some magic, undocumented mimeType?

I was hoping for something like:

[Embed source="../../audio/wibble.wav" mimeType="audio/wav"]

...but I get

no transcoder registered for mimeType 'audio/wav'

It's possible to embed wav or other format as an octet-stream and parse at runtime, but that's pretty heavy handed I think.

I'm surprised that even though the Flash IDE can embed uncompressed sound data, [Embed] cannot, given that the swf spec can contain uncompressed sound data.

Any takers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

無心 2024-09-08 00:52:07

来自 LiveDocs - 使用声音的基础知识

[...]
虽然有各种声音文件
用于编码数字音频的格式,
ActionScript 3.0、Flash Player 和 AIR
支持存储在的声音文件
mp3 格式。他们不能直接
加载或播放其他声音文件
格式如 WAV 或 AIFF。
[...]

但显然有一个解决方法。检查来自actionscript.org的此帖子中的帖子#3:

如果有人有的话,请回复我自己
未来同样的问题是
寻找答案。

我找不到任何直接支持
在 Flex Builder 中嵌入 WAV 文件
3 / ActionScript 3 应用程序。我什么
确实尝试过并且很高兴看到它
作品是创建一个Flash电影
Flash CS 3(您需要拥有它
或获得评估)并导入您的
声音到库并将它们链接到
由 ActionScript 导出。出口
将 Flash CS3 项目转换为 SWF 影片
并将其保存在您的项目中(我添加了
它到“lib 文件夹”)。

您要创建和的 ActionScript 代码
播放声音应该是:

[嵌入(source=“lib/Sounds.swf”,符号=“BigShipSound”)]
私有静态 var BigShipSound:类;
...
var bigShipSound : Sound = BigShipSound as Sound;
bigShipSound.play(0, 20);

From the LiveDocs - Basics of working with sound:

[...]
Although there are various sound file
formats used to encode digital audio,
ActionScript 3.0, Flash Player and AIR
support sound files that are stored in
the mp3 format. They cannot directly
load or play sound files in other
formats like WAV or AIFF.
[...]

But apparently there's a workaround. Check post #3 in this thread from actionscript.org:

Replying to myself in case anyone has
the same question in the future and is
searching for an answer.

I couldn't find any direct support for
embedding WAV files in a Flex Builder
3 / ActionScript 3 application. What I
did try and was delighted to see it
works is to create a Flash Movie in
Flash CS 3 (you will need to own that
or get an evaluation) and import your
sounds to the library and link them to
be exported by ActionScript. Export
the Flash CS3 project to a SWF movie
and save it in your project (I added
it to a "lib folder").

Your ActionScript code to create and
play the sound should be:

[Embed(source="lib/Sounds.swf", symbol="BigShipSound")]
private static var BigShipSound: Class;
...
var bigShipSound : Sound = BigShipSound as Sound;
bigShipSound.play(0, 20);
枕梦 2024-09-08 00:52:07

There's a library you can use

http://code.google.com/p/as3wavsound/

霊感 2024-09-08 00:52:07

Flash播放器不知道如何直接播放wav文件。确实,您可以将它们导入到创作工具中,但是当您发布 SWF 时,您的音频将被转换为 mp3 或 adpcm 或您在发布设置中选择的任何格式。即使您在运行时读取 wav,播放它的唯一方法是解析二进制流,因此如果您嵌入该文件,自然也会应用相同的限制。

此问题中的一些相关信息。奇怪的是你去年似乎对此发表过评论! :)

The Flash player doesn't know how to directly play wav files. It's true that you can import them to the authoring tool, but when you publish the SWF your audio will be converted to mp3 or adpcm or whatever you select in your publish settings. Even if you read in a wav at runtime, the only way to play it is by parsing the binary stream, so naturally the same limitation applies if you embed the file.

Some related info at this question. Which curiously you seem to have commented on last year! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文