Embedding wav files in an AS3 Flash / Flex project?

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

However, the [Embed] tag seems to allow you to embed mp3 files. Is it really impossible to embed an uncompressed wav file, or am I missing some kind of magical, 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 is possible to embed wav or another format as an octet stream and parsing at runtime, but I think this is pretty heavy.

I am surprised that although the Flash IDE can insert uncompressed audio data, [Embed] cannot, given that the swf specification may contain uncompressed audio data.

Any members?

+6
flash actionscript-3 audio wav embed
source share
3 answers

From LiveDocs - Sound Basics :

[...] Although there are various audio file formats used for encoding digital audio, ActionScript 3.0, Flash Player and AIR support audio files that are stored in mp3 format. They cannot directly download or play sound files in other formats, such as WAV or AIFF. [...]

But, apparently, there is a workaround. Check out post # 3 in this thread from actionscript.org :

Answering the question if someone has the same question in the future and looking for an answer.

I could not find direct support for embedding WAV files in Flex Builder 3 / ActionScript 3 application. What I tried and was glad to see it works creating a Flash movie in Flash CS 3 (you will need to own it or get an estimate) and import sounds in library and associates them with being exported using ActionScript. Export the Flash CS3 project for the SWF movie and save it in your project (I added this to the "lib" folder).

The ActionScript code for creating and playing 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); 
+14
source share

There is a library there that you can use

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

+7
source share

The flash player does not know how to directly play wav files. It’s true that you can import them into a development tool, but when you publish SWF, your sound will be converted to mp3 or adpcm or what you choose in the publishing settings. Even if you read in wav at runtime, the only way to reproduce this is by parsing the binary stream, so naturally, the same restriction applies if you insert a file.

Some related information on this subject . Which with curiosity you seem to have commented on last year! :)

+1
source share

All Articles